Commit | Line | Data |
---|---|---|
9f36eaed MJ |
1 | /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) |
2 | * | |
5fa38800 MD |
3 | * lttng-kernel-version.h |
4 | * | |
5 | * Contains helpers to check more complex kernel version conditions. | |
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 | #include <generated/utsrelease.h> |
5fa38800 MD |
15 | |
16 | /* | |
17 | * This macro checks if the kernel version is between the two specified | |
144bbfd5 | 18 | * versions (lower limit inclusive, upper limit exclusive). |
5fa38800 MD |
19 | */ |
20 | #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \ | |
21 | (LINUX_VERSION_CODE >= KERNEL_VERSION(a_low, b_low, c_low) && \ | |
144bbfd5 | 22 | LINUX_VERSION_CODE < KERNEL_VERSION(a_high, b_high, c_high)) |
5fa38800 | 23 | |
c94ac1ac MJ |
24 | /* Ubuntu */ |
25 | ||
3e5941df | 26 | #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \ |
5c7af523 | 27 | (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) |
3e5941df | 28 | |
05732a66 | 29 | #ifdef UTS_UBUNTU_RELEASE_ABI |
3e5941df JD |
30 | #define LTTNG_UBUNTU_VERSION_CODE \ |
31 | ((LINUX_VERSION_CODE << 8) + UTS_UBUNTU_RELEASE_ABI) | |
05732a66 MD |
32 | #else |
33 | #define LTTNG_UBUNTU_VERSION_CODE 0 | |
34 | #endif | |
3e5941df JD |
35 | |
36 | #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ | |
37 | a_high, b_high, c_high, d_high) \ | |
05732a66 | 38 | (LTTNG_UBUNTU_VERSION_CODE >= \ |
3e5941df JD |
39 | LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ |
40 | LTTNG_UBUNTU_VERSION_CODE < \ | |
41 | LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high)) | |
42 | ||
c94ac1ac MJ |
43 | /* Debian */ |
44 | ||
72e6c528 MD |
45 | #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \ |
46 | (((((a) << 16) + ((b) << 8) + (c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) | |
47 | ||
05732a66 | 48 | #ifdef DEBIAN_API_VERSION |
72e6c528 MD |
49 | #define LTTNG_DEBIAN_VERSION_CODE \ |
50 | ((LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION) | |
05732a66 MD |
51 | #else |
52 | #define LTTNG_DEBIAN_VERSION_CODE 0 | |
53 | #endif | |
72e6c528 MD |
54 | |
55 | #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ | |
56 | a_high, b_high, c_high, d_high, e_high, f_high) \ | |
05732a66 | 57 | (LTTNG_DEBIAN_VERSION_CODE >= \ |
72e6c528 MD |
58 | LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ |
59 | LTTNG_DEBIAN_VERSION_CODE < \ | |
60 | LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) | |
61 | ||
c94ac1ac MJ |
62 | #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \ |
63 | (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) | |
64 | ||
65 | /* RHEL */ | |
f30ae671 | 66 | |
c94ac1ac | 67 | #ifdef RHEL_API_VERSION |
f30ae671 | 68 | #define LTTNG_RHEL_VERSION_CODE \ |
c94ac1ac | 69 | ((LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION) |
f30ae671 MD |
70 | #else |
71 | #define LTTNG_RHEL_VERSION_CODE 0 | |
72 | #endif | |
73 | ||
c94ac1ac MJ |
74 | #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ |
75 | a_high, b_high, c_high, d_high, e_high, f_high) \ | |
f30ae671 | 76 | (LTTNG_RHEL_VERSION_CODE >= \ |
c94ac1ac | 77 | LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ |
f30ae671 | 78 | LTTNG_RHEL_VERSION_CODE < \ |
c94ac1ac MJ |
79 | LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) |
80 | ||
ce66b486 MJ |
81 | /* SUSE Linux enterprise */ |
82 | ||
83 | #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \ | |
84 | (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f)) | |
85 | ||
86 | #ifdef SLE_API_VERSION | |
87 | #define LTTNG_SLE_VERSION_CODE \ | |
88 | ((LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION) | |
89 | #else | |
90 | #define LTTNG_SLE_VERSION_CODE 0 | |
91 | #endif | |
92 | ||
93 | #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \ | |
94 | a_high, b_high, c_high, d_high, e_high, f_high) \ | |
95 | (LTTNG_SLE_VERSION_CODE >= \ | |
96 | LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \ | |
97 | LTTNG_SLE_VERSION_CODE < \ | |
98 | LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high)) | |
99 | ||
e4838da1 LG |
100 | /* Fedora */ |
101 | ||
102 | #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \ | |
103 | (((((a) << 16) + ((b) << 8) + (c)) * 10000ULL) + (d)) | |
104 | ||
105 | #ifdef FEDORA_REVISION_VERSION | |
106 | #define LTTNG_FEDORA_VERSION_CODE \ | |
107 | ((LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION) | |
108 | #else | |
109 | #define LTTNG_FEDORA_VERSION_CODE 0 | |
110 | #endif | |
111 | ||
112 | #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ | |
113 | a_high, b_high, c_high, d_high) \ | |
114 | (LTTNG_FEDORA_VERSION_CODE >= \ | |
115 | LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ | |
116 | LTTNG_FEDORA_VERSION_CODE < \ | |
117 | LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high)) | |
118 | ||
c94ac1ac | 119 | /* RT patch */ |
f30ae671 | 120 | |
b4c8e4d3 MJ |
121 | #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \ |
122 | (((a) << 24) + ((b) << 16) + ((c) << 8) + (d)) | |
123 | ||
124 | #ifdef RT_PATCH_VERSION | |
125 | #define LTTNG_RT_VERSION_CODE \ | |
126 | ((LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION) | |
127 | #else | |
128 | #define LTTNG_RT_VERSION_CODE 0 | |
129 | #endif | |
130 | ||
131 | #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \ | |
132 | a_high, b_high, c_high, d_high) \ | |
133 | (LTTNG_RT_VERSION_CODE >= \ | |
134 | LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \ | |
135 | LTTNG_RT_VERSION_CODE < \ | |
136 | LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high)) | |
137 | ||
5fa38800 | 138 | #endif /* _LTTNG_KERNEL_VERSION_H */ |