Document last supported kernel version for stable-2.11 branch
[lttng-modules.git] / lttng-kernel-version.h
CommitLineData
9f36eaed
MJ
1/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
5fa38800
MD
3 * lttng-kernel-version.h
4 *
b78104db 5 * Contains helpers to check kernel version conditions.
5fa38800
MD
6 *
7 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5fa38800
MD
8 */
9
9f36eaed
MJ
10#ifndef _LTTNG_KERNEL_VERSION_H
11#define _LTTNG_KERNEL_VERSION_H
12
5fa38800 13#include <linux/version.h>
9f61c55f 14
2a51de8b
MJ
15/*
16 * The following defines are extracted from the toplevel Linux Makefile and
17 * passed on the command line -with '-D'.
18 */
19
20#ifndef LTTNG_LINUX_MAJOR
21#define LTTNG_LINUX_MAJOR 0
22#endif
23
24#ifndef LTTNG_LINUX_MINOR
25#define LTTNG_LINUX_MINOR 0
26#endif
27
28#ifndef LTTNG_LINUX_PATCH
29#define LTTNG_LINUX_PATCH 0
30#endif
31
32/*
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.
37 *
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.
beb39c21
MJ
42 *
43 * Cast the result to uint64_t to prevent overflowing when we append distro
44 * specific version information.
2a51de8b
MJ
45 */
46#if (LTTNG_LINUX_PATCH >= 256)
47
48#define LTTNG_KERNEL_VERSION(a, b, c) \
beb39c21 49 ((((a) << 24) + ((b) << 16) + (c)) * 1ULL)
2a51de8b
MJ
50
51#define LTTNG_LINUX_VERSION_CODE \
52 LTTNG_KERNEL_VERSION(LTTNG_LINUX_MAJOR, LTTNG_LINUX_MINOR, LTTNG_LINUX_PATCH)
53
54#else
55
beb39c21
MJ
56#define LTTNG_KERNEL_VERSION(a, b, c) (KERNEL_VERSION(a, b, c) * 1ULL)
57#define LTTNG_LINUX_VERSION_CODE (LINUX_VERSION_CODE * 1ULL)
b78104db 58
2a51de8b
MJ
59#endif
60
b78104db 61#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33))
9f61c55f 62#include <generated/utsrelease.h>
b78104db 63#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
7b10d281 64#include <linux/utsrelease.h>
b78104db 65#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
5fa38800
MD
66
67/*
68 * This macro checks if the kernel version is between the two specified
144bbfd5 69 * versions (lower limit inclusive, upper limit exclusive).
5fa38800
MD
70 */
71#define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
b78104db
MJ
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))
5fa38800 74
c94ac1ac
MJ
75/* Ubuntu */
76
3e5941df 77#define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
66106375 78 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
3e5941df 79
05732a66 80#ifdef UTS_UBUNTU_RELEASE_ABI
3e5941df 81#define LTTNG_UBUNTU_VERSION_CODE \
66106375 82 ((LTTNG_LINUX_VERSION_CODE << 16) + UTS_UBUNTU_RELEASE_ABI)
05732a66
MD
83#else
84#define LTTNG_UBUNTU_VERSION_CODE 0
85#endif
3e5941df
JD
86
87#define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
88 a_high, b_high, c_high, d_high) \
05732a66 89 (LTTNG_UBUNTU_VERSION_CODE >= \
3e5941df
JD
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))
93
c94ac1ac
MJ
94/* Debian */
95
72e6c528 96#define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
b78104db 97 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
72e6c528 98
05732a66 99#ifdef DEBIAN_API_VERSION
72e6c528 100#define LTTNG_DEBIAN_VERSION_CODE \
b78104db 101 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
05732a66
MD
102#else
103#define LTTNG_DEBIAN_VERSION_CODE 0
104#endif
72e6c528
MD
105
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) \
05732a66 108 (LTTNG_DEBIAN_VERSION_CODE >= \
72e6c528
MD
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))
112
c94ac1ac 113#define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
9ecc902d 114 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
c94ac1ac
MJ
115
116/* RHEL */
f30ae671 117
c94ac1ac 118#ifdef RHEL_API_VERSION
f30ae671 119#define LTTNG_RHEL_VERSION_CODE \
9ecc902d 120 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + RHEL_API_VERSION)
f30ae671
MD
121#else
122#define LTTNG_RHEL_VERSION_CODE 0
123#endif
124
c94ac1ac
MJ
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) \
f30ae671 127 (LTTNG_RHEL_VERSION_CODE >= \
c94ac1ac 128 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
f30ae671 129 LTTNG_RHEL_VERSION_CODE < \
c94ac1ac
MJ
130 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
131
ce66b486
MJ
132/* SUSE Linux enterprise */
133
134#define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
cdf4b41c 135 (((LTTNG_KERNEL_VERSION(a, b, c)) * 100000000ULL) + ((d) * 100000) + ((e) * 100) + (f))
ce66b486
MJ
136
137#ifdef SLE_API_VERSION
138#define LTTNG_SLE_VERSION_CODE \
cdf4b41c 139 ((LTTNG_LINUX_VERSION_CODE * 100000000ULL) + SLE_API_VERSION)
ce66b486
MJ
140#else
141#define LTTNG_SLE_VERSION_CODE 0
142#endif
143
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))
150
e4838da1
LG
151/* Fedora */
152
153#define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
b78104db 154 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
e4838da1
LG
155
156#ifdef FEDORA_REVISION_VERSION
157#define LTTNG_FEDORA_VERSION_CODE \
b78104db 158 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
e4838da1
LG
159#else
160#define LTTNG_FEDORA_VERSION_CODE 0
161#endif
162
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))
169
c94ac1ac 170/* RT patch */
f30ae671 171
b4c8e4d3 172#define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
d8f24060 173 (((LTTNG_KERNEL_VERSION(a, b, c)) << 16) + (d))
b4c8e4d3
MJ
174
175#ifdef RT_PATCH_VERSION
176#define LTTNG_RT_VERSION_CODE \
d8f24060 177 ((LTTNG_LINUX_VERSION_CODE << 16) + RT_PATCH_VERSION)
b4c8e4d3
MJ
178#else
179#define LTTNG_RT_VERSION_CODE 0
180#endif
181
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))
188
5fa38800 189#endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.046459 seconds and 4 git commands to generate.