Commit | Line | Data |
---|---|---|
d79865b9 MD |
1 | #ifndef _BABELTRACE_CTF_TYPES_H |
2 | #define _BABELTRACE_CTF_TYPES_H | |
6dc2ca62 MD |
3 | |
4 | /* | |
5 | * Common Trace Format | |
6 | * | |
7 | * Type header | |
8 | * | |
de0ba614 | 9 | * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
6dc2ca62 | 10 | * |
de0ba614 MD |
11 | * This library is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Lesser General Public | |
13 | * License as published by the Free Software Foundation; either | |
14 | * version 2.1 of the License, or (at your option) any later version. | |
15 | * | |
16 | * This library is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | * Lesser General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU Lesser General Public | |
22 | * License along with this library; if not, write to the Free Software | |
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
6dc2ca62 MD |
24 | */ |
25 | ||
26 | #include <stdint.h> | |
27 | #include <glib.h> | |
28 | ||
29 | /* | |
de0ba614 MD |
30 | * IMPORTANT: All lengths (len) and offsets (start, end) are expressed in bits, |
31 | * *not* in bytes. | |
32 | * | |
33 | * All write primitives, as well as read for dynamically sized entities, can | |
6dc2ca62 MD |
34 | * receive a NULL ptr/dest parameter. In this case, no write is performed, but |
35 | * the size is returned. | |
36 | */ | |
37 | ||
de0ba614 MD |
38 | uint64_t ctf_uint_read(const unsigned char *ptr, int byte_order, size_t len); |
39 | int64_t ctf_int_read(const unsigned char *ptr, int byte_order, size_t len); | |
40 | size_t ctf_uint_write(unsigned char *ptr, int byte_order, size_t len, uint64_t v); | |
41 | size_t ctf_int_write(unsigned char *ptr, int byte_order, size_t len, int64_t v); | |
6dc2ca62 | 42 | |
fc93b2bd MD |
43 | uint64_t ctf_bitfield_unsigned_read(const unsigned char *ptr, |
44 | unsigned long start, unsigned long len, | |
45 | int byte_order); | |
46 | int64_t ctf_bitfield_signed_read(const unsigned char *ptr, | |
47 | unsigned long start, unsigned long len, | |
48 | int byte_order); | |
49 | size_t ctf_bitfield_unsigned_write(unsigned char *ptr, | |
50 | unsigned long start, unsigned long len, | |
51 | int byte_order, uint64_t v); | |
52 | size_t ctf_bitfield_signed_write(unsigned char *ptr, | |
53 | unsigned long start, unsigned long len, | |
54 | int byte_order, int64_t v); | |
6dc2ca62 | 55 | |
fc93b2bd MD |
56 | double ctf_double_read(const unsigned char *ptr, const struct type_class_float *src) |
57 | size_t ctf_double_write(unsigned char *ptr, const struct type_class_float *dest, | |
de0ba614 MD |
58 | double v); |
59 | long double ctf_ldouble_read(const unsigned char *ptr, | |
fc93b2bd MD |
60 | const struct type_class_float *src) |
61 | size_t ctf_ldouble_write(unsigned char *ptr, const struct type_class_float *dest, | |
de0ba614 | 62 | long double v); |
fc93b2bd MD |
63 | void ctf_float_copy(unsigned char *destp, const struct type_class_float *dest, |
64 | const unsigned char *srcp, const struct type_class_float *src); | |
6dc2ca62 | 65 | |
de0ba614 | 66 | size_t ctf_string_copy(unsigned char *dest, const unsigned char *src); |
6dc2ca62 MD |
67 | |
68 | /* | |
69 | * A GQuark can be translated to/from strings with g_quark_from_string() and | |
70 | * g_quark_to_string(). | |
71 | */ | |
72 | GQuark ctf_enum_uint_to_quark(const struct enum_table *table, uint64_t v); | |
73 | GQuark ctf_enum_int_to_quark(const struct enum_table *table, uint64_t v); | |
74 | uint64_t ctf_enum_quark_to_uint(size_t len, int byte_order, GQuark q); | |
75 | int64_t ctf_enum_quark_to_int(size_t len, int byte_order, GQuark q); | |
76 | void ctf_enum_signed_insert(struct enum_table *table, int64_t v, GQuark q); | |
77 | void ctf_enum_unsigned_insert(struct enum_table *table, uint64_t v, GQuark q); | |
78 | struct enum_table *ctf_enum_new(void); | |
79 | void ctf_enum_destroy(struct enum_table *table); | |
80 | ||
d79865b9 | 81 | #endif /* _BABELTRACE_CTF_TYPES_H */ |