Silence compiler "always false comparison" warning
[lttng-modules.git] / lttng-kernel-version.h
1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
2 *
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>
8 */
9
10 #ifndef _LTTNG_KERNEL_VERSION_H
11 #define _LTTNG_KERNEL_VERSION_H
12
13 #include <linux/version.h>
14
15 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
16 #include <generated/utsrelease.h>
17 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) */
18 #include <linux/utsrelease.h>
19 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) */
20
21 /*
22 * This macro checks if the kernel version is between the two specified
23 * versions (lower limit inclusive, upper limit exclusive).
24 */
25 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
26 (LINUX_VERSION_CODE >= KERNEL_VERSION(a_low, b_low, c_low) && \
27 LINUX_VERSION_CODE < KERNEL_VERSION(a_high, b_high, c_high))
28
29 /* Ubuntu */
30
31 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
32 (((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
33
34 #ifdef UTS_UBUNTU_RELEASE_ABI
35 #define LTTNG_UBUNTU_VERSION_CODE \
36 ((LINUX_VERSION_CODE << 8) + UTS_UBUNTU_RELEASE_ABI)
37 #else
38 #define LTTNG_UBUNTU_VERSION_CODE 0
39 #endif
40
41 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
42 a_high, b_high, c_high, d_high) \
43 (LTTNG_UBUNTU_VERSION_CODE >= \
44 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
45 LTTNG_UBUNTU_VERSION_CODE < \
46 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
47
48 /* Debian */
49
50 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
51 (((((a) << 16) + ((b) << 8) + (c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
52
53 #ifdef DEBIAN_API_VERSION
54 #define LTTNG_DEBIAN_VERSION_CODE \
55 ((LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
56 #else
57 #define LTTNG_DEBIAN_VERSION_CODE 0
58 #endif
59
60 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
61 a_high, b_high, c_high, d_high, e_high, f_high) \
62 (LTTNG_DEBIAN_VERSION_CODE >= \
63 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
64 LTTNG_DEBIAN_VERSION_CODE < \
65 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
66
67 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
68 (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
69
70 /* RHEL */
71
72 #ifdef RHEL_API_VERSION
73 #define LTTNG_RHEL_VERSION_CODE \
74 ((LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
75 #else
76 #define LTTNG_RHEL_VERSION_CODE 0
77 #endif
78
79 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
80 a_high, b_high, c_high, d_high, e_high, f_high) \
81 (LTTNG_RHEL_VERSION_CODE >= \
82 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
83 LTTNG_RHEL_VERSION_CODE < \
84 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
85
86 /* SUSE Linux enterprise */
87
88 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
89 (((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
90
91 #ifdef SLE_API_VERSION
92 #define LTTNG_SLE_VERSION_CODE \
93 ((LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION)
94 #else
95 #define LTTNG_SLE_VERSION_CODE 0
96 #endif
97
98 #define LTTNG_SLE_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_SLE_VERSION_CODE >= \
101 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
102 LTTNG_SLE_VERSION_CODE < \
103 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
104
105 /* Fedora */
106
107 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
108 (((((a) << 16) + ((b) << 8) + (c)) * 10000ULL) + (d))
109
110 #ifdef FEDORA_REVISION_VERSION
111 #define LTTNG_FEDORA_VERSION_CODE \
112 ((LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
113 #else
114 #define LTTNG_FEDORA_VERSION_CODE 0
115 #endif
116
117 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
118 a_high, b_high, c_high, d_high) \
119 (LTTNG_FEDORA_VERSION_CODE >= \
120 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
121 LTTNG_FEDORA_VERSION_CODE < \
122 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
123
124 /* RT patch */
125
126 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
127 (((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
128
129 #ifdef RT_PATCH_VERSION
130 #define LTTNG_RT_VERSION_CODE \
131 ((LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION)
132 #else
133 #define LTTNG_RT_VERSION_CODE 0
134 #endif
135
136 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
137 a_high, b_high, c_high, d_high) \
138 (LTTNG_RT_VERSION_CODE >= \
139 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
140 LTTNG_RT_VERSION_CODE < \
141 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
142
143 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.056311 seconds and 4 git commands to generate.