Commit | Line | Data |
---|---|---|
1d00109f MJ |
1 | /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
2 | * | |
3 | * wrapper/compiler_attributes.h | |
4 | * | |
5 | * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com> | |
6 | */ | |
7 | ||
8 | #ifndef _LTTNG_WRAPPER_COMPILER_ATTRIBUTES_H | |
9 | #define _LTTNG_WRAPPER_COMPILER_ATTRIBUTES_H | |
10 | ||
11 | #include <lttng-kernel-version.h> | |
12 | ||
13 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,20,0)) | |
14 | #include <linux/compiler_attributes.h> | |
15 | #endif | |
16 | ||
17 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0)) | |
18 | ||
19 | /* | |
20 | * Use the kernel provided fallthrough attribute macro. | |
21 | */ | |
22 | #define lttng_fallthrough fallthrough | |
23 | ||
24 | #else /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0) */ | |
25 | ||
26 | /* | |
27 | * Fallback to the comment for kernels pre 5.15 that don't build with | |
28 | * '-Wimplicit-fallthrough=5'. | |
29 | */ | |
30 | #define lttng_fallthrough do {} while (0) /* fallthrough */ | |
31 | ||
32 | #endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,4,0) */ | |
33 | ||
34 | #endif /* _LTTNG_WRAPPER_COMPILER_ATTRIBUTES_H */ |