Document last supported kernel version for stable-2.11 branch
[lttng-modules.git] / lttng-kernel-version.h
1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
3 * lttng-kernel-version.h
4 *
5 * Contains helpers to check kernel version conditions.
6 *
7 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 */
9
10 #ifndef _LTTNG_KERNEL_VERSION_H
11 #define _LTTNG_KERNEL_VERSION_H
12
13 #include <linux/version.h>
14
15 /*
16 * The following defines are extracted from the toplevel Linux Makefile and
17 * passed on the command line -with '-D'.
18 */
19
20 #ifndef LTTNG_LINUX_MAJOR
21 #define LTTNG_LINUX_MAJOR 0
22 #endif
23
24 #ifndef LTTNG_LINUX_MINOR
25 #define LTTNG_LINUX_MINOR 0
26 #endif
27
28 #ifndef LTTNG_LINUX_PATCH
29 #define LTTNG_LINUX_PATCH 0
30 #endif
31
32 /*
33 * Some stable releases have overflowed the 8bits allocated to the sublevel in
34 * the version code. To determine if the current kernel is affected, use the
35 * sublevel version from the Makefile. This is currently true for the 4.4.256
36 * and 4.9.256 stable releases.
37 *
38 * When the sublevel has overflowed, use the values from the Makefile instead
39 * of LINUX_VERSION_CODE from the kernel headers and allocate 16bits.
40 * Otherwise, keep using the version code from the headers to minimise the
41 * behavior change and avoid regressions.
42 *
43 * Cast the result to uint64_t to prevent overflowing when we append distro
44 * specific version information.
45 */
46 #if (LTTNG_LINUX_PATCH >= 256)
47
48 #define LTTNG_KERNEL_VERSION(a, b, c) \
49 ((((a) << 24) + ((b) << 16) + (c)) * 1ULL)
50
51 #define LTTNG_LINUX_VERSION_CODE \
52 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
53
54 #else
55
56 #define LTTNG_KERNEL_VERSION(a, b, c) (KERNEL_VERSION(a, b, c) * 1ULL)
57 #define LTTNG_LINUX_VERSION_CODE (LINUX_VERSION_CODE * 1ULL)
58
59 #endif
60
61 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33))
62 #include <generated/utsrelease.h>
63 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
64 #include <linux/utsrelease.h>
65 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
66
67 /*
68 * This macro checks if the kernel version is between the two specified
69 * versions (lower limit inclusive, upper limit exclusive).
70 */
71 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
72 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(a_low, b_low, c_low) && \
73 LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(a_high, b_high, c_high))
74
75 /* Ubuntu */
76
77 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
78 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
79
80 #ifdef UTS_UBUNTU_RELEASE_ABI
81 #define LTTNG_UBUNTU_VERSION_CODE \
82 ((LTTNG_LINUX_VERSION_CODE << 16) + UTS_UBUNTU_RELEASE_ABI)
83 #else
84 #define LTTNG_UBUNTU_VERSION_CODE 0
85 #endif
86
87 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
88 a_high, b_high, c_high, d_high) \
89 (LTTNG_UBUNTU_VERSION_CODE >= \
90 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
91 LTTNG_UBUNTU_VERSION_CODE < \
92 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
93
94 /* Debian */
95
96 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
97 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
98
99 #ifdef DEBIAN_API_VERSION
100 #define LTTNG_DEBIAN_VERSION_CODE \
101 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
102 #else
103 #define LTTNG_DEBIAN_VERSION_CODE 0
104 #endif
105
106 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
107 a_high, b_high, c_high, d_high, e_high, f_high) \
108 (LTTNG_DEBIAN_VERSION_CODE >= \
109 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
110 LTTNG_DEBIAN_VERSION_CODE < \
111 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
112
113 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
114 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
115
116 /* RHEL */
117
118 #ifdef RHEL_API_VERSION
119 #define LTTNG_RHEL_VERSION_CODE \
120 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + RHEL_API_VERSION)
121 #else
122 #define LTTNG_RHEL_VERSION_CODE 0
123 #endif
124
125 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
126 a_high, b_high, c_high, d_high, e_high, f_high) \
127 (LTTNG_RHEL_VERSION_CODE >= \
128 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
129 LTTNG_RHEL_VERSION_CODE < \
130 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
131
132 /* SUSE Linux enterprise */
133
134 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
135 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 100000) + ((e) * 100) + (f))
136
137 #ifdef SLE_API_VERSION
138 #define LTTNG_SLE_VERSION_CODE \
139 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + SLE_API_VERSION)
140 #else
141 #define LTTNG_SLE_VERSION_CODE 0
142 #endif
143
144 #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
145 a_high, b_high, c_high, d_high, e_high, f_high) \
146 (LTTNG_SLE_VERSION_CODE >= \
147 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
148 LTTNG_SLE_VERSION_CODE < \
149 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
150
151 /* Fedora */
152
153 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
154 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
155
156 #ifdef FEDORA_REVISION_VERSION
157 #define LTTNG_FEDORA_VERSION_CODE \
158 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
159 #else
160 #define LTTNG_FEDORA_VERSION_CODE 0
161 #endif
162
163 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
164 a_high, b_high, c_high, d_high) \
165 (LTTNG_FEDORA_VERSION_CODE >= \
166 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
167 LTTNG_FEDORA_VERSION_CODE < \
168 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
169
170 /* RT patch */
171
172 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
173 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
174
175 #ifdef RT_PATCH_VERSION
176 #define LTTNG_RT_VERSION_CODE \
177 ((LTTNG_LINUX_VERSION_CODE << 16) + RT_PATCH_VERSION)
178 #else
179 #define LTTNG_RT_VERSION_CODE 0
180 #endif
181
182 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
183 a_high, b_high, c_high, d_high) \
184 (LTTNG_RT_VERSION_CODE >= \
185 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
186 LTTNG_RT_VERSION_CODE < \
187 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
188
189 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.032964 seconds and 4 git commands to generate.