Commit | Line | Data |
---|---|---|
b73a4c47 PMF |
1 | #ifndef UST_HEADER_INLINE_H |
2 | #define UST_HEADER_INLINE_H | |
3 | ||
4 | #include "tracercore.h" | |
5 | ||
6 | /* | |
7 | * ust_get_header_size | |
8 | * | |
9 | * Calculate alignment offset to 32-bits. This is the alignment offset of the | |
10 | * event header. | |
11 | * | |
12 | * Important note : | |
13 | * The event header must be 32-bits. The total offset calculated here : | |
14 | * | |
15 | * Alignment of header struct on 32 bits (min arch size, header size) | |
16 | * + sizeof(header struct) (32-bits) | |
17 | * + (opt) u16 (ext. event id) | |
18 | * + (opt) u16 (event_size) (if event_size == 0xFFFFUL, has ext. event size) | |
19 | * + (opt) u32 (ext. event size) | |
20 | * + (opt) u64 full TSC (aligned on min(64-bits, arch size)) | |
21 | * | |
22 | * The payload must itself determine its own alignment from the biggest type it | |
23 | * contains. | |
24 | * */ | |
25 | static __inline__ unsigned char ust_get_header_size( | |
26 | struct ust_channel *channel, | |
27 | size_t offset, | |
28 | size_t data_size, | |
29 | size_t *before_hdr_pad, | |
30 | unsigned int rflags) | |
31 | { | |
32 | size_t orig_offset = offset; | |
33 | size_t padding; | |
34 | ||
35 | padding = ltt_align(offset, sizeof(struct ltt_event_header)); | |
36 | offset += padding; | |
37 | offset += sizeof(struct ltt_event_header); | |
38 | ||
39 | if(unlikely(rflags)) { | |
40 | switch (rflags) { | |
41 | case LTT_RFLAG_ID_SIZE_TSC: | |
42 | offset += sizeof(u16) + sizeof(u16); | |
43 | if (data_size >= 0xFFFFU) | |
44 | offset += sizeof(u32); | |
45 | offset += ltt_align(offset, sizeof(u64)); | |
46 | offset += sizeof(u64); | |
47 | break; | |
48 | case LTT_RFLAG_ID_SIZE: | |
49 | offset += sizeof(u16) + sizeof(u16); | |
50 | if (data_size >= 0xFFFFU) | |
51 | offset += sizeof(u32); | |
52 | break; | |
53 | case LTT_RFLAG_ID: | |
54 | offset += sizeof(u16); | |
55 | break; | |
56 | } | |
57 | } | |
58 | ||
59 | *before_hdr_pad = padding; | |
60 | return offset - orig_offset; | |
61 | } | |
62 | ||
63 | #endif /* UST_HEADER_INLINE_H */ |