Rename libustd to libustconsumer and ustd to ust-consumerd
[lttng-ust.git] / libust / header-inline.h
1 /*
2 * Copyright (C) 2008 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef UST_HEADER_INLINE_H
20 #define UST_HEADER_INLINE_H
21
22 #include <ust/core.h>
23
24 /*
25 * ust_get_header_size
26 *
27 * Calculate alignment offset to 32-bits. This is the alignment offset of the
28 * event header.
29 *
30 * Important note :
31 * The event header must be 32-bits. The total offset calculated here :
32 *
33 * Alignment of header struct on 32 bits (min arch size, header size)
34 * + sizeof(header struct) (32-bits)
35 * + (opt) u16 (ext. event id)
36 * + (opt) u16 (event_size) (if event_size == 0xFFFFUL, has ext. event size)
37 * + (opt) u32 (ext. event size)
38 * + (opt) u64 full TSC (aligned on min(64-bits, arch size))
39 *
40 * The payload must itself determine its own alignment from the biggest type it
41 * contains.
42 * */
43 static __inline__ unsigned char ust_get_header_size(
44 struct ust_channel *channel,
45 size_t offset,
46 size_t data_size,
47 size_t *before_hdr_pad,
48 unsigned int rflags)
49 {
50 size_t orig_offset = offset;
51 size_t padding;
52
53 padding = ltt_align(offset, sizeof(struct ltt_event_header));
54 offset += padding;
55 offset += sizeof(struct ltt_event_header);
56
57 if(unlikely(rflags)) {
58 switch (rflags) {
59 case LTT_RFLAG_ID_SIZE_TSC:
60 offset += sizeof(u16) + sizeof(u16);
61 if (data_size >= 0xFFFFU)
62 offset += sizeof(u32);
63 offset += ltt_align(offset, sizeof(u64));
64 offset += sizeof(u64);
65 break;
66 case LTT_RFLAG_ID_SIZE:
67 offset += sizeof(u16) + sizeof(u16);
68 if (data_size >= 0xFFFFU)
69 offset += sizeof(u32);
70 break;
71 case LTT_RFLAG_ID:
72 offset += sizeof(u16);
73 break;
74 }
75 }
76
77 *before_hdr_pad = padding;
78 return offset - orig_offset;
79 }
80
81 #endif /* UST_HEADER_INLINE_H */
This page took 0.031611 seconds and 4 git commands to generate.