2 * BabelTrace - Float Type Converter
4 * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <babeltrace/compiler.h>
22 #include <babeltrace/types.h>
24 void float_copy(struct stream_pos
*dest
, const struct format
*fdest
,
25 struct stream_pos
*src
, const struct format
*fsrc
,
26 const struct type_class
*type_class
)
28 struct type_class_float
*float_class
=
29 container_of(type_class
, struct type_class_float
, p
);
31 if (fsrc
->float_copy
== fdest
->float_copy
) {
32 fsrc
->float_copy(dest
, src
, float_class
);
36 v
= fsrc
->double_read(src
, float_class
);
37 fdest
->double_write(dest
, float_class
, v
);
41 void float_type_free(struct type_class_float
*float_class
)
46 static void _float_type_free(struct type_class
*type_class
)
48 struct type_class_float
*float_class
=
49 container_of(type_class
, struct type_class_float
, p
);
50 float_type_free(float_class
);
53 struct type_class_float
*float_type_new(const char *name
,
55 size_t exp_len
, int byte_order
,
58 struct type_class_float
*float_class
;
59 struct type_class_integer
*int_class
;
60 struct type_class
*type_class
;
63 float_class
= g_new(struct type_class_float
, 1);
64 type_class
= &float_class
->p
;
66 type_class
->name
= g_quark_from_string(name
);
67 type_class
->alignment
= alignment
;
68 type_class
->copy
= float_copy
;
69 type_class
->free
= _float_type_free
;
70 float_class
->byte_order
= byte_order
;
72 float_class
->sign
= integer_type_new(NULL
, 1,
73 byte_order
, false, 1);
74 if (!float_class
->mantissa
)
76 float_class
->mantissa
= integer_type_new(NULL
, mantissa_len
- 1,
77 byte_order
, false, 1);
78 if (!float_class
->mantissa
)
80 float_class
->exp
= integer_type_new(NULL
, exp_len
,
82 if (!float_class
->exp
)
85 if (float_class
->p
.name
) {
86 ret
= ctf_register_type(&float_class
->p
);
93 integer_type_free(float_class
->exp
);
95 integer_type_free(float_class
->mantissa
);
97 integer_type_free(float_class
->sign
);
This page took 0.032833 seconds and 6 git commands to generate.