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