42d748f9c415653202da20e0633a35b2cd1d0b68
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 #if (LTTNG_LINUX_PATCH >= 256)
46 #define LTTNG_KERNEL_VERSION(a, b, c) \
47 (((a) << 24) + ((b) << 16) + (c))
49 #define LTTNG_LINUX_VERSION_CODE \
50 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
54 #define LTTNG_KERNEL_VERSION(a, b, c) KERNEL_VERSION(a, b, c)
55 #define LTTNG_LINUX_VERSION_CODE LINUX_VERSION_CODE
60 * This macro checks if the kernel version is between the two specified
61 * versions (lower limit inclusive, upper limit exclusive).
63 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
64 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(a_low, b_low, c_low) && \
65 LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(a_high, b_high, c_high))
69 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
70 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
72 #ifdef UTS_UBUNTU_RELEASE_ABI
73 #define LTTNG_UBUNTU_VERSION_CODE \
74 ((LTTNG_LINUX_VERSION_CODE << 16) + UTS_UBUNTU_RELEASE_ABI)
76 #define LTTNG_UBUNTU_VERSION_CODE 0
79 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
80 a_high, b_high, c_high, d_high) \
81 (LTTNG_UBUNTU_VERSION_CODE >= \
82 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
83 LTTNG_UBUNTU_VERSION_CODE < \
84 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
88 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
89 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
91 #ifdef DEBIAN_API_VERSION
92 #define LTTNG_DEBIAN_VERSION_CODE \
93 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
95 #define LTTNG_DEBIAN_VERSION_CODE 0
98 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
99 a_high, b_high, c_high, d_high, e_high, f_high) \
100 (LTTNG_DEBIAN_VERSION_CODE >= \
101 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
102 LTTNG_DEBIAN_VERSION_CODE < \
103 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
105 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
106 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
110 #ifdef RHEL_API_VERSION
111 #define LTTNG_RHEL_VERSION_CODE \
112 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
114 #define LTTNG_RHEL_VERSION_CODE 0
117 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
118 a_high, b_high, c_high, d_high, e_high, f_high) \
119 (LTTNG_RHEL_VERSION_CODE >= \
120 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
121 LTTNG_RHEL_VERSION_CODE < \
122 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
124 /* SUSE Linux enterprise */
126 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
127 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
129 #ifdef SLE_API_VERSION
130 #define LTTNG_SLE_VERSION_CODE \
131 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION)
133 #define LTTNG_SLE_VERSION_CODE 0
136 #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
137 a_high, b_high, c_high, d_high, e_high, f_high) \
138 (LTTNG_SLE_VERSION_CODE >= \
139 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
140 LTTNG_SLE_VERSION_CODE < \
141 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
145 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
146 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
148 #ifdef FEDORA_REVISION_VERSION
149 #define LTTNG_FEDORA_VERSION_CODE \
150 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
152 #define LTTNG_FEDORA_VERSION_CODE 0
155 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
156 a_high, b_high, c_high, d_high) \
157 (LTTNG_FEDORA_VERSION_CODE >= \
158 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
159 LTTNG_FEDORA_VERSION_CODE < \
160 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
164 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
165 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
167 #ifdef RT_PATCH_VERSION
168 #define LTTNG_RT_VERSION_CODE \
169 ((LTTNG_LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION)
171 #define LTTNG_RT_VERSION_CODE 0
174 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
175 a_high, b_high, c_high, d_high) \
176 (LTTNG_RT_VERSION_CODE >= \
177 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
178 LTTNG_RT_VERSION_CODE < \
179 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
181 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.052939 seconds and 4 git commands to generate.