protozero
Minimalistic protocol buffer decoder and encoder in C++.
config.hpp
Go to the documentation of this file.
1 #ifndef PROTOZERO_CONFIG_HPP
2 #define PROTOZERO_CONFIG_HPP
3 
4 /*****************************************************************************
5 
6 protozero - Minimalistic protocol buffer decoder and encoder in C++.
7 
8 This file is from https://github.com/mapbox/protozero where you can find more
9 documentation.
10 
11 *****************************************************************************/
12 
13 #include <cassert>
14 
21 #define PROTOZERO_LITTLE_ENDIAN 1234
22 #define PROTOZERO_BIG_ENDIAN 4321
23 
24 // Find out which byte order the machine has.
25 #if defined(__BYTE_ORDER)
26 # if (__BYTE_ORDER == __LITTLE_ENDIAN)
27 # define PROTOZERO_BYTE_ORDER PROTOZERO_LITTLE_ENDIAN
28 # endif
29 # if (__BYTE_ORDER == __BIG_ENDIAN)
30 # define PROTOZERO_BYTE_ORDER PROTOZERO_BIG_ENDIAN
31 # endif
32 #else
33 // This probably isn't a very good default, but might do until we figure
34 // out something better.
35 # define PROTOZERO_BYTE_ORDER PROTOZERO_LITTLE_ENDIAN
36 #endif
37 
38 // On some ARM machines and depending on compiler settings access to unaligned
39 // floating point values will result in a SIGBUS. Do not use the bare pointers
40 // in this case.
41 #if PROTOZERO_BYTE_ORDER == PROTOZERO_LITTLE_ENDIAN
42 # if !defined(__arm__) && !defined(_M_ARM)
43 # define PROTOZERO_USE_BARE_POINTER_FOR_PACKED_FIXED
44 # endif
45 #endif
46 
47 // Check whether __builtin_bswap is available
48 #if defined(__GNUC__) || defined(__clang__)
49 # define PROTOZERO_USE_BUILTIN_BSWAP
50 #endif
51 
52 // Wrapper for assert() used for testing
53 #ifndef protozero_assert
54 # define protozero_assert(x) assert(x)
55 #endif
56 
57 #endif // PROTOZERO_CONFIG_HPP