Namespace kernel version macros
[lttng-modules.git] / lttng-kernel-version.h
1 #ifndef _LTTNG_KERNEL_VERSION_H
2 #define _LTTNG_KERNEL_VERSION_H
3
4 /*
5 * lttng-kernel-version.h
6 *
7 * Contains helpers to check more complex kernel version conditions.
8 *
9 * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #include <linux/version.h>
27
28 #define LTTNG_KERNEL_VERSION(a, b, c) KERNEL_VERSION(a, b, c)
29 #define LTTNG_LINUX_VERSION_CODE LINUX_VERSION_CODE
30
31 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33))
32 #include <generated/utsrelease.h>
33 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
34 #include <linux/utsrelease.h>
35 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
36
37 /*
38 * This macro checks if the kernel version is between the two specified
39 * versions (lower limit inclusive, upper limit exclusive).
40 */
41 #define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
42 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(a_low, b_low, c_low) && \
43 LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(a_high, b_high, c_high))
44
45 /* Ubuntu */
46
47 #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
48 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
49
50 #ifdef UTS_UBUNTU_RELEASE_ABI
51 #define LTTNG_UBUNTU_VERSION_CODE \
52 ((LTTNG_LINUX_VERSION_CODE << 8) + UTS_UBUNTU_RELEASE_ABI)
53 #else
54 #define LTTNG_UBUNTU_VERSION_CODE 0
55 #endif
56
57 #define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
58 a_high, b_high, c_high, d_high) \
59 (LTTNG_UBUNTU_VERSION_CODE >= \
60 LTTNG_UBUNTU_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
61 LTTNG_UBUNTU_VERSION_CODE < \
62 LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
63
64 /* Debian */
65
66 #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
67 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
68
69 #ifdef DEBIAN_API_VERSION
70 #define LTTNG_DEBIAN_VERSION_CODE \
71 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
72 #else
73 #define LTTNG_DEBIAN_VERSION_CODE 0
74 #endif
75
76 #define LTTNG_DEBIAN_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
77 a_high, b_high, c_high, d_high, e_high, f_high) \
78 (LTTNG_DEBIAN_VERSION_CODE >= \
79 LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
80 LTTNG_DEBIAN_VERSION_CODE < \
81 LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
82
83 #define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
84 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
85
86 /* RHEL */
87
88 #ifdef RHEL_API_VERSION
89 #define LTTNG_RHEL_VERSION_CODE \
90 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
91 #else
92 #define LTTNG_RHEL_VERSION_CODE 0
93 #endif
94
95 #define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
96 a_high, b_high, c_high, d_high, e_high, f_high) \
97 (LTTNG_RHEL_VERSION_CODE >= \
98 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
99 LTTNG_RHEL_VERSION_CODE < \
100 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
101
102 /* SUSE Linux enterprise */
103
104 #define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
105 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
106
107 #ifdef SLE_API_VERSION
108 #define LTTNG_SLE_VERSION_CODE \
109 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION)
110 #else
111 #define LTTNG_SLE_VERSION_CODE 0
112 #endif
113
114 #define LTTNG_SLE_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
115 a_high, b_high, c_high, d_high, e_high, f_high) \
116 (LTTNG_SLE_VERSION_CODE >= \
117 LTTNG_SLE_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
118 LTTNG_SLE_VERSION_CODE < \
119 LTTNG_SLE_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
120
121 /* Fedora */
122
123 #define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
124 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
125
126 #ifdef FEDORA_REVISION_VERSION
127 #define LTTNG_FEDORA_VERSION_CODE \
128 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
129 #else
130 #define LTTNG_FEDORA_VERSION_CODE 0
131 #endif
132
133 #define LTTNG_FEDORA_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
134 a_high, b_high, c_high, d_high) \
135 (LTTNG_FEDORA_VERSION_CODE >= \
136 LTTNG_FEDORA_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
137 LTTNG_FEDORA_VERSION_CODE < \
138 LTTNG_FEDORA_KERNEL_VERSION(a_high, b_high, c_high, d_high))
139
140 /* RT patch */
141
142 #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
143 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
144
145 #ifdef RT_PATCH_VERSION
146 #define LTTNG_RT_VERSION_CODE \
147 ((LTTNG_LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION)
148 #else
149 #define LTTNG_RT_VERSION_CODE 0
150 #endif
151
152 #define LTTNG_RT_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
153 a_high, b_high, c_high, d_high) \
154 (LTTNG_RT_VERSION_CODE >= \
155 LTTNG_RT_KERNEL_VERSION(a_low, b_low, c_low, d_low) && \
156 LTTNG_RT_VERSION_CODE < \
157 LTTNG_RT_KERNEL_VERSION(a_high, b_high, c_high, d_high))
158
159 #endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.032341 seconds and 4 git commands to generate.