4 * Bitfields read/write functions.
6 * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <ctf/bitfield.h>
26 uint64_t ctf_bitfield_unsigned_read(struct stream_pos
*pos
,
27 const struct type_class_bitfield
*bitfield_class
)
31 align_pos(pos
, bitfield_class
->p
.p
.alignment
);
32 if (bitfield_class
->p
.byte_order
== LITTLE_ENDIAN
)
33 ctf_bitfield_read_le(pos
->base
, pos
->offset
,
34 bitfield_class
->p
.len
, &v
);
36 ctf_bitfield_read_be(pos
->base
, pos
->offset
,
37 bitfield_class
->p
.len
, &v
);
38 move_pos(pos
, bitfield_class
->p
.len
);
42 int64_t ctf_bitfield_signed_read(struct stream_pos
*pos
,
43 const struct type_class_bitfield
*bitfield_class
)
47 align_pos(pos
, bitfield_class
->p
.p
.alignment
);
49 if (bitfield_class
->p
.byte_order
== LITTLE_ENDIAN
)
50 ctf_bitfield_read_le(pos
->base
, pos
->offset
,
51 bitfield_class
->p
.len
, &v
);
53 ctf_bitfield_read_be(pos
->base
, pos
->offset
,
54 bitfield_class
->p
.len
, &v
);
55 move_pos(pos
, bitfield_class
->p
.len
);
59 void ctf_bitfield_unsigned_write(struct stream_pos
*pos
,
60 const struct type_class_bitfield
*bitfield_class
,
63 align_pos(pos
, bitfield_class
->p
.p
.alignment
);
66 if (bitfield_class
->p
.byte_order
== LITTLE_ENDIAN
)
67 ctf_bitfield_write_le(pos
->base
, pos
->offset
,
68 bitfield_class
->p
.len
, v
);
70 ctf_bitfield_write_be(pos
->base
, pos
->offset
,
71 bitfield_class
->p
.len
,, v
);
73 move_pos(pos
, bitfield_class
->p
.len
);
76 void ctf_bitfield_signed_write(struct stream_pos
*pos
,
77 const struct type_class_bitfield
*bitfield_class
,
80 align_pos(pos
, bitfield_class
->p
.p
.alignment
);
83 if (bitfield_class
->p
.byte_order
== LITTLE_ENDIAN
)
84 ctf_bitfield_write_le(pos
->base
, pos
->offset
,
85 bitfield_class
->p
.len
, v
);
87 ctf_bitfield_write_be(pos
->base
, pos
->offset
,
88 bitfield_class
->p
.len
, v
);
90 move_pos(pos
, bitfield_class
->p
.len
);
This page took 0.036472 seconds and 4 git commands to generate.