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 * Cast the result to uint64_t to prevent overflowing when we append distro
44 * specific version information.
46 #if (LTTNG_LINUX_PATCH >= 256)
48 #define LTTNG_KERNEL_VERSION(a, b, c) \
49 ((((a) << 24) + ((b) << 16) + (c)) * 1ULL)
51 #define LTTNG_LINUX_VERSION_CODE \
52 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
56 #define LTTNG_KERNEL_VERSION(a, b, c) (KERNEL_VERSION(a, b, c) * 1ULL)
57 #define LTTNG_LINUX_VERSION_CODE (LINUX_VERSION_CODE * 1ULL)
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)) */
68 * This macro checks if the kernel version is between the two specified
69 * versions (lower limit inclusive, upper limit exclusive).
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))
77 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
78 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
80 #ifdef UTS_UBUNTU_RELEASE_ABI
81 #define LTTNG_UBUNTU_VERSION_CODE \
82 ((LTTNG_LINUX_VERSION_CODE << 16) + UTS_UBUNTU_RELEASE_ABI)
84 #define LTTNG_UBUNTU_VERSION_CODE 0
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))
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))
99 #ifdef DEBIAN_API_VERSION
100 #define LTTNG_DEBIAN_VERSION_CODE \
101 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
103 #define LTTNG_DEBIAN_VERSION_CODE 0
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))
113 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
114 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
118 #ifdef RHEL_API_VERSION
119 #define LTTNG_RHEL_VERSION_CODE \
120 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
122 #define LTTNG_RHEL_VERSION_CODE 0
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))
132 /* SUSE Linux enterprise */
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))
137 #ifdef SLE_API_VERSION
138 #define LTTNG_SLE_VERSION_CODE \
139 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + SLE_API_VERSION)
141 #define LTTNG_SLE_VERSION_CODE 0
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))
153 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
154 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
156 #ifdef FEDORA_REVISION_VERSION
157 #define LTTNG_FEDORA_VERSION_CODE \
158 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
160 #define LTTNG_FEDORA_VERSION_CODE 0
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))
172 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
173 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
175 #ifdef RT_PATCH_VERSION
176 #define LTTNG_RT_VERSION_CODE \
177 ((LTTNG_LINUX_VERSION_CODE << 16) + RT_PATCH_VERSION)
179 #define LTTNG_RT_VERSION_CODE 0
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))
189 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.041826 seconds and 4 git commands to generate.