Move types.c to types/
[babeltrace.git] / include / ctf / ctf-types.h
1 #ifndef _CTF_TYPES_H
2 #define _CTF_TYPES_H
3
4 /*
5 * Common Trace Format
6 *
7 * Type header
8 *
9 * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
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
24 */
25
26 #include <stdint.h>
27 #include <glib.h>
28
29 /*
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
34 * receive a NULL ptr/dest parameter. In this case, no write is performed, but
35 * the size is returned.
36 */
37
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);
42
43 /*
44 * ctf-types-bitfield.h declares:
45 *
46 * ctf_bitfield_unsigned_read
47 * ctf_bitfield_signed_read
48 * ctf_bitfield_unsigned_write
49 * ctf_bitfield_signed_write
50 */
51 #include <ctf/ctf-types-bitfield.h>
52
53 double ctf_double_read(const unsigned char *ptr, const struct ctf_float *src)
54 size_t ctf_double_write(unsigned char *ptr, const struct ctf_float *dest,
55 double v);
56 long double ctf_ldouble_read(const unsigned char *ptr,
57 const struct ctf_float *src)
58 size_t ctf_ldouble_write(unsigned char *ptr, const struct ctf_float *dest,
59 long double v);
60 struct ctf_float {
61 size_t exp_len;
62 size_t mantissa_len; /* Including sign bit */
63 int byte_order;
64 };
65 void ctf_float_copy(unsigned char *destp, const struct ctf_float *dest,
66 const unsigned char *srcp, const struct ctf_float *src);
67
68 size_t ctf_string_copy(unsigned char *dest, const unsigned char *src);
69
70 /*
71 * A GQuark can be translated to/from strings with g_quark_from_string() and
72 * g_quark_to_string().
73 */
74 GQuark ctf_enum_uint_to_quark(const struct enum_table *table, uint64_t v);
75 GQuark ctf_enum_int_to_quark(const struct enum_table *table, uint64_t v);
76 uint64_t ctf_enum_quark_to_uint(size_t len, int byte_order, GQuark q);
77 int64_t ctf_enum_quark_to_int(size_t len, int byte_order, GQuark q);
78 void ctf_enum_signed_insert(struct enum_table *table, int64_t v, GQuark q);
79 void ctf_enum_unsigned_insert(struct enum_table *table, uint64_t v, GQuark q);
80 struct enum_table *ctf_enum_new(void);
81 void ctf_enum_destroy(struct enum_table *table);
82
83 #endif /* _CTF_TYPES_H */
This page took 0.03019 seconds and 4 git commands to generate.