Commit | Line | Data |
---|---|---|
1ea11eab | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
1ea11eab | 3 | * |
c0c0989a | 4 | * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
e92f3e28 | 5 | * |
c0c0989a | 6 | * This contains the core definitions for the Linux Trace Toolkit. |
1ea11eab MD |
7 | */ |
8 | ||
c0c0989a MJ |
9 | #ifndef _LTTNG_UST_TRACER_H |
10 | #define _LTTNG_UST_TRACER_H | |
11 | ||
0a3faf2a MJ |
12 | #include <limits.h> |
13 | ||
2df82195 FD |
14 | #if defined (__cplusplus) |
15 | #include <type_traits> | |
16 | #endif | |
17 | ||
2eba8e39 | 18 | #include <lttng/ust-arch.h> |
2df82195 | 19 | #include <lttng/ust-compiler.h> |
562c813a | 20 | #include <lttng/ust-config.h> |
b728d87e | 21 | #include <lttng/ust-version.h> |
d4d59a97 | 22 | |
2eba8e39 | 23 | #ifndef LTTNG_UST_ARCH_HAS_EFFICIENT_UNALIGNED_ACCESS |
1ea11eab MD |
24 | /* Align data on its natural alignment */ |
25 | #define RING_BUFFER_ALIGN | |
26 | #endif | |
27 | ||
1ea11eab MD |
28 | #ifndef CHAR_BIT |
29 | #define CHAR_BIT 8 | |
30 | #endif | |
31 | ||
32 | #ifdef RING_BUFFER_ALIGN | |
33 | #define lttng_alignof(type) __alignof__(type) | |
34 | #else | |
35 | #define lttng_alignof(type) 1 | |
36 | #endif | |
37 | ||
72914f82 | 38 | #define lttng_is_signed_type(type) ((type) -1 < (type) 0) |
1ea11eab | 39 | |
2df82195 FD |
40 | /* |
41 | * This macro adds a compilation assertion that CTF arrays and sequences | |
42 | * declared by the users are of an integral type. | |
43 | */ | |
44 | ||
45 | #if defined(__cplusplus) | |
46 | #define _lttng_is_integer(type) (std::is_integral<type>::value) | |
47 | #else | |
48 | #define _lttng_is_integer(type) (__builtin_types_compatible_p(type, _Bool) || \ | |
49 | __builtin_types_compatible_p(type, char) || \ | |
029ba7b2 MD |
50 | __builtin_types_compatible_p(type, unsigned char) || \ |
51 | __builtin_types_compatible_p(type, short) || \ | |
52 | __builtin_types_compatible_p(type, unsigned short) || \ | |
53 | __builtin_types_compatible_p(type, int) || \ | |
54 | __builtin_types_compatible_p(type, unsigned int) || \ | |
55 | __builtin_types_compatible_p(type, long) || \ | |
56 | __builtin_types_compatible_p(type, unsigned long) || \ | |
57 | __builtin_types_compatible_p(type, long long) || \ | |
58 | __builtin_types_compatible_p(type, unsigned long long)) | |
2df82195 FD |
59 | #endif |
60 | ||
61 | #define _lttng_array_element_type_is_supported(_type, _item) \ | |
62 | lttng_static_assert(_lttng_is_integer(_type), \ | |
63 | "Non-integer type `" #_item "` not supported as element of CTF_ARRAY or CTF_SEQUENCE", \ | |
64 | Non_integer_type__##_item##__not_supported_as_element_of_CTF_ARRAY_or_CTF_SEQUENCE); | |
65 | ||
7dd08bec | 66 | #endif /* _LTTNG_UST_TRACER_H */ |