00b4987c62c21f6ce9a4db4580668a3a2661a905
[citadel.git] / citadel / typesize.h
1 /* $Id$ */
2
3 /*
4    This file defines macros for 8, 16, and 32 bit integers.  The macros are:
5    cit_int8_t   default 8-bit int
6    cit_int16_t  default 16-bit int
7    cit_int32_t  default 32-bit int
8    cit_int64_t  default 64-bit int (not implemented yet)
9    cit_sint8_t  signed 8-bit int
10    cit_sint16_t signed 16-bit int
11    cit_sint32_t signed 32-bit int
12    cit_sint64_t signed 64-bit int (not implemented yet)
13    cit_uint8_t  unsigned 8-bit int
14    cit_uint16_t unsigned 16-bit int
15    cit_uint32_t unsigned 32-bit int
16    cit_uint64_t unsigned 64-bit int (not implemented yet)
17
18    The sizes are determined during the configure process; see the 
19    AC_CHECK_SIZEOF macros in configure.in.  In no way do we assume that any
20    given datatype is any particular width, e.g. we don't assume char is one
21    byte; we check for it specifically.
22
23    This might seem excessively paranoid, but I've seen some WEIRD systems
24    and some bizarre compilers (Domain/OS for instance) in my time.
25 */
26
27 #ifndef _CITADEL_UX_TYPESIZE_H
28 #define _CITADEL_UX_TYPESIZE_H
29
30 /* Include sysdep.h if not already included */
31 #ifndef BBSDIR
32 # include "sysdep.h"
33 #endif
34
35 /* 8-bit */
36 #if SIZEOF_CHAR == 1
37 # define cit_int8_t     char
38 #elif SIZEOF_SHORT == 1
39 # define cit_int8_t     short
40 #else
41 # error Unable to find an 8-bit integer datatype
42 #endif
43
44 /* 16-bit */
45 #if SIZEOF_SHORT == 2
46 # define cit_int16_t    short
47 #elif SIZEOF_INT == 2
48 # define cit_int16_t    int
49 #elif SIZEOF_CHAR == 2
50 # define cit_int16_t    char
51 #else
52 # error Unable to find a 16-bit integer datatype
53 #endif
54
55 /* 32-bit */
56 #if SIZEOF_INT == 4
57 # define cit_int32_t    int
58 #elif SIZEOF_SHORT == 4
59 # define cit_int32_t    short
60 #elif SIZEOF_LONG == 4
61 # define cit_int32_t    long
62 #else
63 # error Unable to find a 32-bit integer datatype
64 #endif
65
66 /* signed */
67 #define cit_sint8_t     signed cit_int8_t
68 #define cit_sint16_t    signed cit_int16_t
69 #define cit_sint32_t    signed cit_int32_t
70
71 /* unsigned */
72 #define cit_uint8_t     unsigned cit_int8_t
73 #define cit_uint16_t    unsigned cit_int16_t
74 #define cit_uint32_t    unsigned cit_int32_t
75
76 #endif /* _CITADEL_UX_TYPESIZE_H */