Move declarations to global header
[lttng-modules.git] / probes / lttng-types.h
1 /*
2 * Protect against multiple inclusion of structure declarations, but run the
3 * stages below each time.
4 */
5 #ifndef _LTTNG_PROBES_LTTNG_TYPES_H
6 #define _LTTNG_PROBES_LTTNG_TYPES_H
7
8 #include <linux/seq_file.h>
9 #include "lttng.h"
10 #include "../ltt-events.h"
11
12 #ifdef __KERNEL__
13 # include <asm/byteorder.h>
14 # ifdef __BIG_ENDIAN
15 # define __BYTE_ORDER __BIG_ENDIAN
16 # elif defined(__LITTLE_ENDIAN)
17 # define __BYTE_ORDER __LITTLE_ENDIAN
18 # else
19 # error "unknown endianness"
20 # endif
21 #ifndef __BIG_ENDIAN
22 # define __BIG_ENDIAN 4321
23 #endif
24 #ifndef __LITTLE_ENDIAN
25 # define __LITTLE_ENDIAN 1234
26 #endif
27 #else
28 # include <endian.h>
29 #endif
30
31 void lttng_print_event_type(struct seq_file *m, unsigned int indent,
32 const struct lttng_type *type);
33
34 #endif /* _LTTNG_PROBES_LTTNG_TYPES_H */
35
36
37 /* Export enumerations */
38
39 #ifdef STAGE_EXPORT_ENUMS
40
41 #undef TRACE_EVENT_TYPE
42 #define TRACE_EVENT_TYPE(_name, _abstract_type, args...)
43
44 #undef TRACE_EVENT_ENUM
45 #define TRACE_EVENT_ENUM(_name, _entries...) \
46 const struct lttng_enum_entry __trace_event_enum_##_name[] = { \
47 PARAMS(_entries) \
48 };
49
50 /* Enumeration entry (single value) */
51 #undef V
52 #define V(_string) { _string, _string, #_string}
53
54 /* Enumeration entry (range) */
55 #undef R
56 #define R(_string, _range_start, _range_end) \
57 { _range_start, _range_end, #_string }
58
59 #endif /* STAGE_EXPORT_ENUMS */
60
61
62 /* Export named types */
63
64 #ifdef STAGE_EXPORT_TYPES
65
66 #undef TRACE_EVENT_TYPE___integer_ext
67 #define TRACE_EVENT_TYPE___integer_ext(_name, _byte_order) \
68 { \
69 .atype = atype_integer, \
70 .name = #_name, \
71 .u.integer.size = sizeof(_name) * 8, \
72 .u.integer.alignment = __alignof__(_name) * 8,\
73 .u.integer.signedness = is_signed_type(_name),\
74 .u.integer.reverse_byte_order = ((_byte_order) != __BYTE_ORDER),\
75 },
76
77 #undef TRACE_EVENT_TYPE___integer
78 #define TRACE_EVENT_TYPE___integer(_name, _unused) \
79 TRACE_EVENT_TYPE___integer_ext(_name, __BYTE_ORDER)
80
81 #undef TRACE_EVENT_TYPE___enum
82 #define TRACE_EVENT_TYPE___enum(_name, _parent_type) \
83 { \
84 .atype = atype_enum, \
85 .name = #_name, \
86 .u.enumeration.parent_type = #_parent_type, \
87 .u.enumeration.def.entries = __trace_event_enum_##_name, \
88 .u.enumeration.def.len = ARRAY_SIZE(__trace_event_enum_##_name), \
89 },
90
91 #undef TRACE_EVENT_TYPE___array
92 #define TRACE_EVENT_TYPE___array(_name, _elem_type, _length) \
93 { \
94 .atype = atype_array, \
95 .name = #_name, \
96 .u.array.elem_type = #_elem_type, \
97 .u.array.length = _length, \
98 },
99
100 #undef TRACE_EVENT_TYPE___sequence
101 #define TRACE_EVENT_TYPE___sequence(_name, _elem_type, _length_type) \
102 { \
103 .atype = atype_sequence, \
104 .name = #_name, \
105 .u.sequence.elem_type = #_elem_type, \
106 .u.sequence.length_type = #_length_type, \
107 },
108
109 #undef TRACE_EVENT_TYPE___string
110 #define TRACE_EVENT_TYPE___string(_name, _encoding) \
111 { \
112 .atype = atype_string, \
113 .name = #_name, \
114 .u.string.encoding = lttng_encode_##_encoding,\
115 },
116
117
118 /* Local declaration */
119 #undef TRACE_EVENT_TYPE
120 #define TRACE_EVENT_TYPE(_name, _abstract_type, args...) \
121 TRACE_EVENT_TYPE___##_abstract_type(_name, args)
122
123 #undef TRACE_EVENT_ENUM
124 #define TRACE_EVENT_ENUM(_name, _entries...)
125
126 #endif /* STAGE_EXPORT_TYPES */
This page took 0.037364 seconds and 5 git commands to generate.