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>
14 #include <generated/utsrelease.h>
17 * The following defines are extracted from the toplevel Linux Makefile and
18 * passed on the command line -with '-D'.
21 #ifndef LTTNG_LINUX_MAJOR
22 #define LTTNG_LINUX_MAJOR 0
25 #ifndef LTTNG_LINUX_MINOR
26 #define LTTNG_LINUX_MINOR 0
29 #ifndef LTTNG_LINUX_PATCH
30 #define LTTNG_LINUX_PATCH 0
34 * Some stable releases have overflowed the 8bits allocated to the sublevel in
35 * the version code. To determine if the current kernel is affected, use the
36 * sublevel version from the Makefile. This is currently true for the 4.4.256
37 * and 4.9.256 stable releases.
39 * When the sublevel has overflowed, use the values from the Makefile instead
40 * of LINUX_VERSION_CODE from the kernel headers and allocate 16bits.
41 * Otherwise, keep using the version code from the headers to minimise the
42 * behavior change and avoid regressions.
44 * Cast the result to uint64_t to prevent overflowing when we append distro
45 * specific version information.
47 #if (LTTNG_LINUX_PATCH >= 256)
49 #define LTTNG_KERNEL_VERSION(a, b, c) \
50 ((((a) << 24) + ((b) << 16) + (c)) * 1ULL)
52 #define LTTNG_LINUX_VERSION_CODE \
53 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
57 #define LTTNG_KERNEL_VERSION(a, b, c) (KERNEL_VERSION(a, b, c) * 1ULL)
58 #define LTTNG_LINUX_VERSION_CODE (LINUX_VERSION_CODE * 1ULL)
63 * This macro checks if the kernel version is between the two specified
64 * versions (lower limit inclusive, upper limit exclusive).
66 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
67 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(a_low, b_low, c_low) && \
68 LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(a_high, b_high, c_high))
72 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
73 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
75 #ifdef UTS_UBUNTU_RELEASE_ABI
76 #define LTTNG_UBUNTU_VERSION_CODE \
77 ((LTTNG_LINUX_VERSION_CODE << 16) + UTS_UBUNTU_RELEASE_ABI)
79 #define LTTNG_UBUNTU_VERSION_CODE 0
82 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
83 a_high, b_high, c_high, d_high) \
84 (LTTNG_UBUNTU_VERSION_CODE >= \
85 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
86 LTTNG_UBUNTU_VERSION_CODE < \
87 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
91 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
92 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
94 #ifdef DEBIAN_API_VERSION
95 #define LTTNG_DEBIAN_VERSION_CODE \
96 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
98 #define LTTNG_DEBIAN_VERSION_CODE 0
101 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
102 a_high, b_high, c_high, d_high, e_high, f_high) \
103 (LTTNG_DEBIAN_VERSION_CODE >= \
104 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
105 LTTNG_DEBIAN_VERSION_CODE < \
106 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
108 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
109 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
113 #ifdef RHEL_API_VERSION
114 #define LTTNG_RHEL_VERSION_CODE \
115 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + RHEL_API_VERSION)
117 #define LTTNG_RHEL_VERSION_CODE 0
120 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
121 a_high, b_high, c_high, d_high, e_high, f_high) \
122 (LTTNG_RHEL_VERSION_CODE >= \
123 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
124 LTTNG_RHEL_VERSION_CODE < \
125 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
127 /* SUSE Linux enterprise */
129 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
130 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 100000) + ((e) * 100) + (f))
132 #ifdef SLE_API_VERSION
133 #define LTTNG_SLE_VERSION_CODE \
134 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + SLE_API_VERSION)
136 #define LTTNG_SLE_VERSION_CODE 0
139 #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
140 a_high, b_high, c_high, d_high, e_high, f_high) \
141 (LTTNG_SLE_VERSION_CODE >= \
142 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
143 LTTNG_SLE_VERSION_CODE < \
144 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
148 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
149 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
151 #ifdef FEDORA_REVISION_VERSION
152 #define LTTNG_FEDORA_VERSION_CODE \
153 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
155 #define LTTNG_FEDORA_VERSION_CODE 0
158 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
159 a_high, b_high, c_high, d_high) \
160 (LTTNG_FEDORA_VERSION_CODE >= \
161 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
162 LTTNG_FEDORA_VERSION_CODE < \
163 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
167 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
168 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
170 #ifdef RT_PATCH_VERSION
171 #define LTTNG_RT_VERSION_CODE \
172 ((LTTNG_LINUX_VERSION_CODE << 16) + RT_PATCH_VERSION)
174 #define LTTNG_RT_VERSION_CODE 0
177 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
178 a_high, b_high, c_high, d_high) \
179 (LTTNG_RT_VERSION_CODE >= \
180 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
181 LTTNG_RT_VERSION_CODE < \
182 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
184 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.034496 seconds and 4 git commands to generate.