e7fffe606a288bdf1dd4203abd01162ef94fbbc9
1 #ifndef _LTTNG_KERNEL_VERSION_H
2 #define _LTTNG_KERNEL_VERSION_H
5 * lttng-kernel-version.h
7 * Contains helpers to check more complex kernel version conditions.
9 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
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.
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
26 #include <linux/version.h>
29 * The following defines are extracted from the toplevel Linux Makefile and
30 * passed on the command line -with '-D'.
33 #ifndef LTTNG_LINUX_MAJOR
34 #define LTTNG_LINUX_MAJOR 0
37 #ifndef LTTNG_LINUX_MINOR
38 #define LTTNG_LINUX_MINOR 0
41 #ifndef LTTNG_LINUX_PATCH
42 #define LTTNG_LINUX_PATCH 0
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.
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.
56 #if (LTTNG_LINUX_PATCH >= 256)
58 #define LTTNG_KERNEL_VERSION(a, b, c) \
59 (((a) << 24) + ((b) << 16) + (c))
61 #define LTTNG_LINUX_VERSION_CODE \
62 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
66 #define LTTNG_KERNEL_VERSION(a, b, c) KERNEL_VERSION(a, b, c)
67 #define LTTNG_LINUX_VERSION_CODE LINUX_VERSION_CODE
71 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33))
72 #include <generated/utsrelease.h>
73 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
74 #include <linux/utsrelease.h>
75 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
78 * This macro checks if the kernel version is between the two specified
79 * versions (lower limit inclusive, upper limit exclusive).
81 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
82 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(a_low, b_low, c_low) && \
83 LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(a_high, b_high, c_high))
87 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
88 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
90 #ifdef UTS_UBUNTU_RELEASE_ABI
91 #define LTTNG_UBUNTU_VERSION_CODE \
92 ((LTTNG_LINUX_VERSION_CODE << 8) + UTS_UBUNTU_RELEASE_ABI)
94 #define LTTNG_UBUNTU_VERSION_CODE 0
97 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
98 a_high, b_high, c_high, d_high) \
99 (LTTNG_UBUNTU_VERSION_CODE >= \
100 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
101 LTTNG_UBUNTU_VERSION_CODE < \
102 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
106 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
107 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
109 #ifdef DEBIAN_API_VERSION
110 #define LTTNG_DEBIAN_VERSION_CODE \
111 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
113 #define LTTNG_DEBIAN_VERSION_CODE 0
116 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
117 a_high, b_high, c_high, d_high, e_high, f_high) \
118 (LTTNG_DEBIAN_VERSION_CODE >= \
119 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
120 LTTNG_DEBIAN_VERSION_CODE < \
121 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
123 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
124 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
128 #ifdef RHEL_API_VERSION
129 #define LTTNG_RHEL_VERSION_CODE \
130 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
132 #define LTTNG_RHEL_VERSION_CODE 0
135 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
136 a_high, b_high, c_high, d_high, e_high, f_high) \
137 (LTTNG_RHEL_VERSION_CODE >= \
138 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
139 LTTNG_RHEL_VERSION_CODE < \
140 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
142 /* SUSE Linux enterprise */
144 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
145 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
147 #ifdef SLE_API_VERSION
148 #define LTTNG_SLE_VERSION_CODE \
149 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION)
151 #define LTTNG_SLE_VERSION_CODE 0
154 #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
155 a_high, b_high, c_high, d_high, e_high, f_high) \
156 (LTTNG_SLE_VERSION_CODE >= \
157 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
158 LTTNG_SLE_VERSION_CODE < \
159 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
163 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
164 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
166 #ifdef FEDORA_REVISION_VERSION
167 #define LTTNG_FEDORA_VERSION_CODE \
168 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
170 #define LTTNG_FEDORA_VERSION_CODE 0
173 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
174 a_high, b_high, c_high, d_high) \
175 (LTTNG_FEDORA_VERSION_CODE >= \
176 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
177 LTTNG_FEDORA_VERSION_CODE < \
178 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
182 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
183 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
185 #ifdef RT_PATCH_VERSION
186 #define LTTNG_RT_VERSION_CODE \
187 ((LTTNG_LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION)
189 #define LTTNG_RT_VERSION_CODE 0
192 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
193 a_high, b_high, c_high, d_high) \
194 (LTTNG_RT_VERSION_CODE >= \
195 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
196 LTTNG_RT_VERSION_CODE < \
197 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
199 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.032521 seconds and 4 git commands to generate.