Namespace kernel version macros
[lttng-modules.git] / lttng-kernel-version.h
CommitLineData
5fa38800
MD
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>
9f61c55f 27
360d3efe
MJ
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))
9f61c55f 32#include <generated/utsrelease.h>
360d3efe 33#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
7b10d281 34#include <linux/utsrelease.h>
360d3efe 35#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(2,6,33)) */
5fa38800
MD
36
37/*
38 * This macro checks if the kernel version is between the two specified
144bbfd5 39 * versions (lower limit inclusive, upper limit exclusive).
5fa38800
MD
40 */
41#define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
360d3efe
MJ
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))
5fa38800 44
c94ac1ac
MJ
45/* Ubuntu */
46
3e5941df 47#define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
360d3efe 48 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
3e5941df 49
05732a66 50#ifdef UTS_UBUNTU_RELEASE_ABI
3e5941df 51#define LTTNG_UBUNTU_VERSION_CODE \
360d3efe 52 ((LTTNG_LINUX_VERSION_CODE << 8) + UTS_UBUNTU_RELEASE_ABI)
05732a66
MD
53#else
54#define LTTNG_UBUNTU_VERSION_CODE 0
55#endif
3e5941df
JD
56
57#define LTTNG_UBUNTU_KERNEL_RANGE(a_low, b_low, c_low, d_low, \
58 a_high, b_high, c_high, d_high) \
05732a66 59 (LTTNG_UBUNTU_VERSION_CODE >= \
3e5941df
JD
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
c94ac1ac
MJ
64/* Debian */
65
72e6c528 66#define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
360d3efe 67 (((LTTNG_KERNEL_VERSION(a, b, c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
72e6c528 68
05732a66 69#ifdef DEBIAN_API_VERSION
72e6c528 70#define LTTNG_DEBIAN_VERSION_CODE \
360d3efe 71 ((LTTNG_LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
05732a66
MD
72#else
73#define LTTNG_DEBIAN_VERSION_CODE 0
74#endif
72e6c528
MD
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) \
05732a66 78 (LTTNG_DEBIAN_VERSION_CODE >= \
72e6c528
MD
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
c94ac1ac 83#define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
360d3efe 84 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
c94ac1ac
MJ
85
86/* RHEL */
f30ae671 87
c94ac1ac 88#ifdef RHEL_API_VERSION
f30ae671 89#define LTTNG_RHEL_VERSION_CODE \
360d3efe 90 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
f30ae671
MD
91#else
92#define LTTNG_RHEL_VERSION_CODE 0
93#endif
94
c94ac1ac
MJ
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) \
f30ae671 97 (LTTNG_RHEL_VERSION_CODE >= \
c94ac1ac 98 LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
f30ae671 99 LTTNG_RHEL_VERSION_CODE < \
c94ac1ac
MJ
100 LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
101
ce66b486
MJ
102/* SUSE Linux enterprise */
103
104#define LTTNG_SLE_KERNEL_VERSION(a, b, c, d, e, f) \
360d3efe 105 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
ce66b486
MJ
106
107#ifdef SLE_API_VERSION
108#define LTTNG_SLE_VERSION_CODE \
360d3efe 109 ((LTTNG_LINUX_VERSION_CODE * 10000000ULL) + SLE_API_VERSION)
ce66b486
MJ
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
26d6737c
LG
121/* Fedora */
122
123#define LTTNG_FEDORA_KERNEL_VERSION(a, b, c, d) \
360d3efe 124 (((LTTNG_KERNEL_VERSION(a, b, c)) * 10000ULL) + (d))
26d6737c
LG
125
126#ifdef FEDORA_REVISION_VERSION
127#define LTTNG_FEDORA_VERSION_CODE \
360d3efe 128 ((LTTNG_LINUX_VERSION_CODE * 10000ULL) + FEDORA_REVISION_VERSION)
26d6737c
LG
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
c94ac1ac 140/* RT patch */
f30ae671 141
b4c8e4d3 142#define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
360d3efe 143 (((LTTNG_KERNEL_VERSION(a, b, c)) << 8) + (d))
b4c8e4d3
MJ
144
145#ifdef RT_PATCH_VERSION
146#define LTTNG_RT_VERSION_CODE \
360d3efe 147 ((LTTNG_LINUX_VERSION_CODE << 8) + RT_PATCH_VERSION)
b4c8e4d3
MJ
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
5fa38800 159#endif /* _LTTNG_KERNEL_VERSION_H */
This page took 0.054256 seconds and 4 git commands to generate.