41a3116120984f32fe74011476b11c00924aa85d
4 * BabelTrace - Integer Type Converter
6 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
19 #include <babeltrace/compiler.h>
20 #include <babeltrace/align.h>
21 #include <babeltrace/types.h>
24 size_t integer_copy(unsigned char *dest
, const struct format
*fdest
,
25 const unsigned char *src
, const struct format
*fsrc
,
26 const struct type_class
*type_class
)
28 struct type_class_integer
*int_class
=
29 container_of(type_class
, struct type_class_integer
, p
);
31 if (!int_class
->signedness
) {
34 v
= fsrc
->uint_read(src
, int_class
);
35 return fdest
->uint_write(dest
, int_class
, v
);
39 v
= fsrc
->int_read(src
, int_class
);
40 return fdest
->int_write(dest
, int_class
, v
);
44 void integer_type_free(struct type_class_integer
*int_class
)
49 static void _integer_type_free(struct type_class
*type_class
)
51 struct type_class_integer
*int_class
=
52 container_of(type_class
, struct type_class_integer
, p
);
53 integer_type_free(int_class
);
56 struct type_class_integer
*integer_type_new(const char *name
,
57 size_t len
, int byte_order
,
61 struct type_class_integer
*int_class
;
64 int_class
= g_new(struct type_class_integer
, 1);
65 int_class
->p
.name
= g_quark_from_string(name
);
66 int_class
->p
.alignment
= alignment
;
67 int_class
->p
.copy
= integer_copy
;
68 int_class
->p
.free
= _integer_type_free
;
70 int_class
->byte_order
= byte_order
;
71 int_class
->signedness
= signedness
;
72 if (int_class
->p
.name
) {
73 ret
= ctf_register_type(&int_class
->p
);
This page took 0.030162 seconds and 3 git commands to generate.