1 #ifndef _CTF_TYPES_BITFIELD_H
2 #define _CTF_TYPES_BITFIELD_H
7 * Bitfields read/write functions.
9 * Copyright (c) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
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.
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
26 #include <ctf/bitfield.h>
30 uint64_t ctf_bitfield_unsigned_read(const unsigned char *ptr
,
31 unsigned long start
, unsigned long len
,
36 if (byte_order
== LITTLE_ENDIAN
)
37 ctf_bitfield_read_le(ptr
, start
, len
, &v
);
39 ctf_bitfield_read_be(ptr
, start
, len
, &v
);
44 int64_t ctf_bitfield_signed_read(const unsigned char *ptr
,
45 unsigned long start
, unsigned long len
,
50 if (byte_order
== LITTLE_ENDIAN
)
51 ctf_bitfield_read_le(ptr
, start
, len
, &v
);
53 ctf_bitfield_read_be(ptr
, start
, len
, &v
);
58 size_t ctf_bitfield_unsigned_write(unsigned char *ptr
,
59 unsigned long start
, unsigned long len
,
60 int byte_order
, uint64_t v
)
64 if (byte_order
== LITTLE_ENDIAN
)
65 ctf_bitfield_write_le(ptr
, start
, len
, v
);
67 ctf_bitfield_write_be(ptr
, start
, len
, v
);
73 size_t ctf_bitfield_signed_write(unsigned char *ptr
,
74 unsigned long start
, unsigned long len
,
75 int byte_order
, int64_t v
)
79 if (byte_order
== LITTLE_ENDIAN
)
80 ctf_bitfield_write_le(ptr
, start
, len
, v
);
82 ctf_bitfield_write_be(ptr
, start
, len
, v
);
87 #endif /* _CTF_TYPES_BITFIELD_H */
This page took 0.037893 seconds and 5 git commands to generate.