protozero
Minimalistic protocol buffer decoder and encoder in C++.
include
protozero
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
# ifndef PROTOZERO_DO_NOT_USE_BARE_POINTER
44
# define PROTOZERO_USE_BARE_POINTER_FOR_PACKED_FIXED
45
# endif
46
# endif
47
#endif
48
49
// Check whether __builtin_bswap is available
50
#if defined(__GNUC__) || defined(__clang__)
51
# define PROTOZERO_USE_BUILTIN_BSWAP
52
#endif
53
54
// Wrapper for assert() used for testing
55
#ifndef protozero_assert
56
# define protozero_assert(x) assert(x)
57
#endif
58
59
#endif // PROTOZERO_CONFIG_HPP
Generated on Sat Sep 17 2016 11:17:54 for protozero by
1.8.12