1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
3 * lttng-kernel-version.h
5 * Contains helpers to check kernel version conditions.
7 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 #ifndef _LTTNG_KERNEL_VERSION_H
11 #define _LTTNG_KERNEL_VERSION_H
13 #include <linux/version.h>
16 * The following defines are extracted from the toplevel Linux Makefile and
17 * passed on the command line -with '-D'.
20 #ifndef LTTNG_LINUX_MAJOR
21 #define LTTNG_LINUX_MAJOR 0
24 #ifndef LTTNG_LINUX_MINOR
25 #define LTTNG_LINUX_MINOR 0
28 #ifndef LTTNG_LINUX_PATCH
29 #define LTTNG_LINUX_PATCH 0
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.
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.
43 #if (LTTNG_LINUX_PATCH >= 256)
45 #define LTTNG_KERNEL_VERSION(a, b, c) \
46 (((a) << 24) + ((b) << 16) + (c))
48 #define LTTNG_LINUX_VERSION_CODE \
49 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
53 #define LTTNG_KERNEL_VERSION(a, b, c) KERNEL_VERSION(a, b, c)
54 #define LTTNG_LINUX_VERSION_CODE LINUX_VERSION_CODE
58 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33))
59 #include <generated/utsrelease.h>
60 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
61 #include <linux/utsrelease.h>
62 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
65 * This macro checks if the kernel version is between the two specified
66 * versions (lower limit inclusive, upper limit exclusive).
68 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
69 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(a_low, b_low, c_low) && \
70 LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(a_high, b_high, c_high))
74 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
75 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
77 #ifdef UTS_UBUNTU_RELEASE_ABI
78 #define LTTNG_UBUNTU_VERSION_CODE \
79 ((LTTNG_LINUX_VERSION_CODE << 16) + UTS_UBUNTU_RELEASE_ABI)
81 #define LTTNG_UBUNTU_VERSION_CODE 0
84 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
85 a_high, b_high, c_high, d_high) \
86 (LTTNG_UBUNTU_VERSION_CODE >= \
87 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
88 LTTNG_UBUNTU_VERSION_CODE < \
89 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
93 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
94 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
96 #ifdef DEBIAN_API_VERSION
97 #define LTTNG_DEBIAN_VERSION_CODE \
98 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
100 #define LTTNG_DEBIAN_VERSION_CODE 0
103 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
104 a_high, b_high, c_high, d_high, e_high, f_high) \
105 (LTTNG_DEBIAN_VERSION_CODE >= \
106 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
107 LTTNG_DEBIAN_VERSION_CODE < \
108 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
110 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
111 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
115 #ifdef RHEL_API_VERSION
116 #define LTTNG_RHEL_VERSION_CODE \
117 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
119 #define LTTNG_RHEL_VERSION_CODE 0
122 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
123 a_high, b_high, c_high, d_high, e_high, f_high) \
124 (LTTNG_RHEL_VERSION_CODE >= \
125 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
126 LTTNG_RHEL_VERSION_CODE < \
127 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
129 /* SUSE Linux enterprise */
131 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
132 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
134 #ifdef SLE_API_VERSION
135 #define LTTNG_SLE_VERSION_CODE \
136 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION)
138 #define LTTNG_SLE_VERSION_CODE 0
141 #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
142 a_high, b_high, c_high, d_high, e_high, f_high) \
143 (LTTNG_SLE_VERSION_CODE >= \
144 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
145 LTTNG_SLE_VERSION_CODE < \
146 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
150 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
151 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
153 #ifdef FEDORA_REVISION_VERSION
154 #define LTTNG_FEDORA_VERSION_CODE \
155 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
157 #define LTTNG_FEDORA_VERSION_CODE 0
160 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
161 a_high, b_high, c_high, d_high) \
162 (LTTNG_FEDORA_VERSION_CODE >= \
163 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
164 LTTNG_FEDORA_VERSION_CODE < \
165 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
169 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
170 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
172 #ifdef RT_PATCH_VERSION
173 #define LTTNG_RT_VERSION_CODE \
174 ((LTTNG_LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION)
176 #define LTTNG_RT_VERSION_CODE 0
179 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
180 a_high, b_high, c_high, d_high) \
181 (LTTNG_RT_VERSION_CODE >= \
182 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
183 LTTNG_RT_VERSION_CODE < \
184 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
186 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.036212 seconds and 4 git commands to generate.