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(const unsigned char *ptr
,
27 unsigned long start
, unsigned long len
,
32 if (byte_order
== LITTLE_ENDIAN
)
33 ctf_bitfield_read_le(ptr
, start
, len
, &v
);
35 ctf_bitfield_read_be(ptr
, start
, len
, &v
);
39 int64_t ctf_bitfield_signed_read(const unsigned char *ptr
,
40 unsigned long start
, unsigned long len
,
45 if (byte_order
== LITTLE_ENDIAN
)
46 ctf_bitfield_read_le(ptr
, start
, len
, &v
);
48 ctf_bitfield_read_be(ptr
, start
, len
, &v
);
52 size_t ctf_bitfield_unsigned_write(unsigned char *ptr
,
53 unsigned long start
, unsigned long len
,
54 int byte_order
, uint64_t v
)
58 if (byte_order
== LITTLE_ENDIAN
)
59 ctf_bitfield_write_le(ptr
, start
, len
, v
);
61 ctf_bitfield_write_be(ptr
, start
, len
, v
);
66 size_t ctf_bitfield_signed_write(unsigned char *ptr
,
67 unsigned long start
, unsigned long len
,
68 int byte_order
, int64_t v
)
72 if (byte_order
== LITTLE_ENDIAN
)
73 ctf_bitfield_write_le(ptr
, start
, len
, v
);
75 ctf_bitfield_write_be(ptr
, start
, len
, v
);
This page took 0.039008 seconds and 4 git commands to generate.