Use CHAR_BIT instead of 8 for float and string
[babeltrace.git] / include / babeltrace / ctf / types.h
CommitLineData
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
38uint64_t ctf_uint_read(const unsigned char *ptr, int byte_order, size_t len);
39int64_t ctf_int_read(const unsigned char *ptr, int byte_order, size_t len);
40size_t ctf_uint_write(unsigned char *ptr, int byte_order, size_t len, uint64_t v);
41size_t ctf_int_write(unsigned char *ptr, int byte_order, size_t len, int64_t v);
6dc2ca62
MD
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
de0ba614
MD
53double ctf_double_read(const unsigned char *ptr, const struct ctf_float *src)
54size_t ctf_double_write(unsigned char *ptr, const struct ctf_float *dest,
55 double v);
56long double ctf_ldouble_read(const unsigned char *ptr,
57 const struct ctf_float *src)
58size_t ctf_ldouble_write(unsigned char *ptr, const struct ctf_float *dest,
59 long double v);
60struct ctf_float {
61 size_t exp_len;
62 size_t mantissa_len; /* Including sign bit */
63 int byte_order;
64};
65void ctf_float_copy(unsigned char *destp, const struct ctf_float *dest,
66 const unsigned char *srcp, const struct ctf_float *src);
6dc2ca62 67
de0ba614 68size_t ctf_string_copy(unsigned char *dest, const unsigned char *src);
6dc2ca62
MD
69
70/*
71 * A GQuark can be translated to/from strings with g_quark_from_string() and
72 * g_quark_to_string().
73 */
74GQuark ctf_enum_uint_to_quark(const struct enum_table *table, uint64_t v);
75GQuark ctf_enum_int_to_quark(const struct enum_table *table, uint64_t v);
76uint64_t ctf_enum_quark_to_uint(size_t len, int byte_order, GQuark q);
77int64_t ctf_enum_quark_to_int(size_t len, int byte_order, GQuark q);
78void ctf_enum_signed_insert(struct enum_table *table, int64_t v, GQuark q);
79void ctf_enum_unsigned_insert(struct enum_table *table, uint64_t v, GQuark q);
80struct enum_table *ctf_enum_new(void);
81void ctf_enum_destroy(struct enum_table *table);
82
d79865b9 83#endif /* _BABELTRACE_CTF_TYPES_H */
This page took 0.025766 seconds and 4 git commands to generate.