chiark / gitweb /
b316f225b669c8f78c67393fdd2c13852efa768c
[secnet] / fake-mLib-bits.h
1 /*
2  * This file is part of secnet.
3  * See README for full list of copyright holders.
4  *
5  * secnet is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version d of the License, or
8  * (at your option) any later version.
9  *
10  * secnet is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * version 3 along with secnet; if not, see
17  * https://www.gnu.org/licenses/gpl.html.
18  */
19
20 #ifndef fake_mLib_bits_h
21 #define fake_mLib_bits_h
22
23 /* The <mLib/bits.h> header defines a large number of types and macros for
24  * various kinds of bithacking.  Notably, it has machinery for autodetecting
25  * suitable types holding (at least) various numbers of bits -- a service
26  * which C99 provides through other means.
27  *
28  * This file provides a small portion of the <mLib/bits.h> interface, just
29  * enough to make the pieces of code lifted from Catacomb feel at home.
30  */
31
32 #include <stdint.h>
33 #include "unaligned.h"
34
35 typedef uint8_t octet;
36 typedef uint32_t uint32;
37 typedef uint64_t uint64;
38
39 typedef int32_t int32;
40 typedef int64_t int64;
41
42 #define LOAD32_L(p) (get_uint32_le(p))
43 #define STORE32_L(p, x) put_uint32_le((p), (x))
44
45 #define U32(x) ((uint32)(x) & 0xffffffffu)
46
47 #endif /* fake_mLib_bits_h */