1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
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>
14 #include <linux/types.h>
15 #include <generated/utsrelease.h>
18 * The following defines are extracted from the toplevel Linux Makefile and
19 * passed on the command line -with '-D'.
22 #ifndef LTTNG_LINUX_MAJOR
23 #define LTTNG_LINUX_MAJOR 0
26 #ifndef LTTNG_LINUX_MINOR
27 #define LTTNG_LINUX_MINOR 0
30 #ifndef LTTNG_LINUX_PATCH
31 #define LTTNG_LINUX_PATCH 0
35 * Some stable releases have overflowed the 8bits allocated to the sublevel in
36 * the version code. To determine if the current kernel is affected, use the
37 * sublevel version from the Makefile. This is currently true for the 4.4.256
38 * and 4.9.256 stable releases.
40 * When the sublevel has overflowed, use the values from the Makefile instead
41 * of LINUX_VERSION_CODE from the kernel headers and allocate 16bits.
42 * Otherwise, keep using the version code from the headers to minimise the
43 * behavior change and avoid regressions.
45 * Cast the result to uint64_t to prevent overflowing when we append distro
46 * specific version information.
48 #if (LTTNG_LINUX_PATCH >= 256)
50 #define LTTNG_KERNEL_VERSION(a, b, c) \
51 ((((a) << 24) + ((b) << 16) + (c)) * 1ULL)
53 #define LTTNG_LINUX_VERSION_CODE \
54 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
58 #define LTTNG_KERNEL_VERSION(a, b, c) (KERNEL_VERSION(a, b, c) * 1ULL)
59 #define LTTNG_LINUX_VERSION_CODE (LINUX_VERSION_CODE * 1ULL)
64 * This macro checks if the kernel version is between the two specified
65 * versions (lower limit inclusive, upper limit exclusive).
67 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
68 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(a_low, b_low, c_low) && \
69 LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(a_high, b_high, c_high))
73 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
74 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
76 #ifdef UTS_UBUNTU_RELEASE_ABI
77 #define LTTNG_UBUNTU_VERSION_CODE \
78 ((LTTNG_LINUX_VERSION_CODE << 16) + UTS_UBUNTU_RELEASE_ABI)
80 #define LTTNG_UBUNTU_VERSION_CODE 0
83 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
84 a_high, b_high, c_high, d_high) \
85 (LTTNG_UBUNTU_VERSION_CODE >= \
86 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
87 LTTNG_UBUNTU_VERSION_CODE < \
88 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
92 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
93 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
95 #ifdef DEBIAN_API_VERSION
96 #define LTTNG_DEBIAN_VERSION_CODE \
97 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
99 #define LTTNG_DEBIAN_VERSION_CODE 0
102 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
103 a_high, b_high, c_high, d_high, e_high, f_high) \
104 (LTTNG_DEBIAN_VERSION_CODE >= \
105 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
106 LTTNG_DEBIAN_VERSION_CODE < \
107 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
111 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
112 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
114 #ifdef RHEL_API_VERSION
115 #define LTTNG_RHEL_VERSION_CODE \
116 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + RHEL_API_VERSION)
118 #define LTTNG_RHEL_VERSION_CODE 0
121 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
122 a_high, b_high, c_high, d_high, e_high, f_high) \
123 (LTTNG_RHEL_VERSION_CODE >= \
124 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
125 LTTNG_RHEL_VERSION_CODE < \
126 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
128 /* SUSE Linux enterprise */
130 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
131 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 100000) + ((e) * 100) + (f))
133 #ifdef SLE_API_VERSION
134 #define LTTNG_SLE_VERSION_CODE \
135 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + SLE_API_VERSION)
137 #define LTTNG_SLE_VERSION_CODE 0
140 #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
141 a_high, b_high, c_high, d_high, e_high, f_high) \
142 (LTTNG_SLE_VERSION_CODE >= \
143 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
144 LTTNG_SLE_VERSION_CODE < \
145 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
149 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
150 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
152 #ifdef FEDORA_REVISION_VERSION
153 #define LTTNG_FEDORA_VERSION_CODE \
154 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
156 #define LTTNG_FEDORA_VERSION_CODE 0
159 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
160 a_high, b_high, c_high, d_high) \
161 (LTTNG_FEDORA_VERSION_CODE >= \
162 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
163 LTTNG_FEDORA_VERSION_CODE < \
164 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
168 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
169 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
171 #ifdef RT_PATCH_VERSION
172 #define LTTNG_RT_VERSION_CODE \
173 ((LTTNG_LINUX_VERSION_CODE << 16) + RT_PATCH_VERSION)
175 #define LTTNG_RT_VERSION_CODE 0
178 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
179 a_high, b_high, c_high, d_high) \
180 (LTTNG_RT_VERSION_CODE >= \
181 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
182 LTTNG_RT_VERSION_CODE < \
183 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
185 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.038233 seconds and 4 git commands to generate.