TRACE_EVENT: start work on type metadata declaration
[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 <lttng.h>
9
10 enum abstract_types {
11 atype_integer,
12 atype_enum,
13 atype_array,
14 NR_ABSTRACT_TYPES,
15 };
16
17 struct lttng_enum_entry {
18 unsigned long long start, end; /* start and end are inclusive */
19 const char *string;
20 };
21
22 struct lttng_enum {
23 const struct lttng_enum_entry *entries;
24 unsigned int len;
25 };
26
27 struct lttng_type {
28 enum abstract_types atype;
29 const char *name;
30 union {
31 struct {
32 unsigned int size; /* in bits */
33 unsigned short alignment; /* in bits */
34 unsigned int signedness:1;
35 } integer;
36 struct {
37 const char *parent_type;
38 const struct lttng_enum def;
39 } enumeration;
40 struct {
41 const char *elem_type;
42 unsigned int length; /* num. elems. */
43 } array;
44 } u;
45 } __attribute__((packed));
46
47 #endif /* _LTTNG_PROBES_LTTNG_TYPES_H */
48
49
50 /* Export enumerations */
51
52 #ifdef STAGE_EXPORT_ENUMS
53
54 #undef TRACE_EVENT_TYPE
55 #define TRACE_EVENT_TYPE(_name, _abstract_type, args...)
56
57 #undef TRACE_EVENT_ENUM
58 #define TRACE_EVENT_ENUM(_name, _entries...) \
59 const struct lttng_enum_entry __trace_event_enum_##_name[] = { \
60 PARAMS(_entries) \
61 };
62
63 /* Enumeration entry (single value) */
64 #undef V
65 #define V(_string) { _string, _string, #_string}
66
67 /* Enumeration entry (range) */
68 #undef R
69 #define R(_string, _range_start, _range_end) \
70 { _range_start, _range_end, #_string }
71
72 #endif /* STAGE_EXPORT_ENUMS */
73
74
75 /* Export named types */
76
77 #ifdef STAGE_EXPORT_TYPES
78
79 #undef TRACE_EVENT_TYPE___integer
80 #define TRACE_EVENT_TYPE___integer(_name, _unused) \
81 { \
82 .atype = atype_integer, \
83 .name = #_name, \
84 .u.integer.size = sizeof(_name) * 8, \
85 .u.integer.alignment = __alignof__(_name) * 8,\
86 .u.integer.signedness = is_signed_type(_name),\
87 },
88
89 #undef TRACE_EVENT_TYPE___enum
90 #define TRACE_EVENT_TYPE___enum(_name, _parent_type) \
91 { \
92 .atype = atype_enum, \
93 .name = #_name, \
94 .u.enumeration.parent_type = #_parent_type, \
95 .u.enumeration.def.entries = __trace_event_enum_##_name, \
96 .u.enumeration.def.len = ARRAY_SIZE(__trace_event_enum_##_name), \
97 },
98
99 #undef TRACE_EVENT_TYPE___array
100 #define TRACE_EVENT_TYPE___array(_name, _elem_type, _length) \
101 { \
102 .atype = atype_array, \
103 .name = #_name, \
104 .u.array.elem_type = #_elem_type, \
105 .u.array.length = _length, \
106 },
107
108 /* Local declaration */
109 #undef TRACE_EVENT_TYPE
110 #define TRACE_EVENT_TYPE(_name, _abstract_type, args...) \
111 TRACE_EVENT_TYPE___##_abstract_type(_name, args)
112
113 #undef TRACE_EVENT_ENUM
114 #define TRACE_EVENT_ENUM(_name, _entries...)
115
116 #endif /* STAGE_EXPORT_TYPES */
This page took 0.033009 seconds and 5 git commands to generate.