GCS  0.2.3
gu_arch.h
1 // Copyright (C) 2012 Codership Oy <info@codership.com>
2 
9 #ifndef _gu_arch_h_
10 #define _gu_arch_h_
11 
12 #if defined(HAVE_ENDIAN_H)
13 # include <endian.h>
14 #elif defined(HAVE_SYS_ENDIAN_H) /* FreeBSD */
15 # include <sys/endian.h>
16 #elif defined(HAVE_SYS_BYTEORDER_H)
17 # include <sys/byteorder.h>
18 #elif defined(__APPLE__)
19 # include <machine/endian.h>
20 #else
21 # error "No byte order header file detected"
22 #endif
23 
24 #if defined(__BYTE_ORDER)
25 # if __BYTE_ORDER == __LITTLE_ENDIAN
26 # define GU_LITTLE_ENDIAN
27 # endif
28 #elif defined(_BYTE_ORDER) /* FreeBSD */
29 # if _BYTE_ORDER == _LITTLE_ENDIAN
30 # define GU_LITTLE_ENDIAN
31 # endif
32 #elif defined(__APPLE__) && defined(__DARWIN_BYTE_ORDER)
33 # if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
34 # define GU_LITTLE_ENDIAN
35 # endif
36 #elif defined(__sun__)
37 # if !defined(_BIG_ENDIAN)
38 # define GU_LITTLE_ENDIAN
39 # endif
40 #else
41 # error "Byte order not defined"
42 #endif
43 
44 #if defined(__sun__)
45 # define GU_WORDSIZE 64 /* Solaris 11 is only 64-bit ATM */
46 #elif defined(__APPLE__) || defined(__FreeBSD__)
47 # include <stdint.h>
48 # define GU_WORDSIZE __WORDSIZE
49 #else
50 # include <bits/wordsize.h>
51 # define GU_WORDSIZE __WORDSIZE
52 #endif
53 
54 #if (GU_WORDSIZE != 32) && (GU_WORDSIZE != 64)
55 # error "Unsupported wordsize"
56 #endif
57 
58 /* I'm not aware of the platforms that don't, but still */
59 #define GU_ALLOW_UNALIGNED_READS 1
60 
61 #endif /* _gu_arch_h_ */