Jamoma API  0.6.0.a19
OscHostEndianness.h
1 /*
2  oscpack -- Open Sound Control (OSC) packet manipulation library
3  http://www.rossbencina.com/code/oscpack
4 
5  Copyright (c) 2004-2013 Ross Bencina <rossb@audiomulch.com>
6 
7  Permission is hereby granted, free of charge, to any person obtaining
8  a copy of this software and associated documentation files
9  (the "Software"), to deal in the Software without restriction,
10  including without limitation the rights to use, copy, modify, merge,
11  publish, distribute, sublicense, and/or sell copies of the Software,
12  and to permit persons to whom the Software is furnished to do so,
13  subject to the following conditions:
14 
15  The above copyright notice and this permission notice shall be
16  included in all copies or substantial portions of the Software.
17 
18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22  ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26 
27 /*
28  The text above constitutes the entire oscpack license; however,
29  the oscpack developer(s) also make the following non-binding requests:
30 
31  Any person wishing to distribute modifications to the Software is
32  requested to send the modifications to the original developer so that
33  they can be incorporated into the canonical version. It is also
34  requested that these non-binding requests be included whenever the
35  above license is reproduced.
36 */
37 #ifndef INCLUDED_OSCPACK_OSCHOSTENDIANNESS_H
38 #define INCLUDED_OSCPACK_OSCHOSTENDIANNESS_H
39 
40 /*
41  Make sure either OSC_HOST_LITTLE_ENDIAN or OSC_HOST_BIG_ENDIAN is defined
42 
43  We try to use preprocessor symbols to deduce the host endianness.
44 
45  Alternatively you can define one of the above symbols from the command line.
46  Usually you do this with the -D flag to the compiler. e.g.:
47 
48  $ g++ -DOSC_HOST_LITTLE_ENDIAN ...
49 */
50 
51 #if defined(OSC_HOST_LITTLE_ENDIAN) || defined(OSC_HOST_BIG_ENDIAN)
52 
53 // endianness defined on the command line. nothing to do here.
54 
55 #elif defined(__WIN32__) || defined(WIN32) || defined(WINCE)
56 
57 // assume that __WIN32__ is only defined on little endian systems
58 
59 #define OSC_HOST_LITTLE_ENDIAN 1
60 #undef OSC_HOST_BIG_ENDIAN
61 
62 #elif defined(__APPLE__)
63 
64 #if defined(__LITTLE_ENDIAN__)
65 
66 #define OSC_HOST_LITTLE_ENDIAN 1
67 #undef OSC_HOST_BIG_ENDIAN
68 
69 #elif defined(__BIG_ENDIAN__)
70 
71 #define OSC_HOST_BIG_ENDIAN 1
72 #undef OSC_HOST_LITTLE_ENDIAN
73 
74 #endif
75 
76 #elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__)
77 
78 // should cover gcc and clang
79 
80 #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
81 
82 #define OSC_HOST_LITTLE_ENDIAN 1
83 #undef OSC_HOST_BIG_ENDIAN
84 
85 #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
86 
87 #define OSC_HOST_BIG_ENDIAN 1
88 #undef OSC_HOST_LITTLE_ENDIAN
89 
90 #endif
91 
92 #else
93 
94 // gcc defines __LITTLE_ENDIAN__ and __BIG_ENDIAN__
95 // for others used here see http://sourceforge.net/p/predef/wiki/Endianness/
96 #if (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) \
97  || (defined(__ARMEL__) && !defined(__ARMEB__)) \
98  || (defined(__AARCH64EL__) && !defined(__AARCH64EB__)) \
99  || (defined(_MIPSEL) && !defined(_MIPSEB)) \
100  || (defined(__MIPSEL) && !defined(__MIPSEB)) \
101  || (defined(__MIPSEL__) && !defined(__MIPSEB__))
102 
103 #define OSC_HOST_LITTLE_ENDIAN 1
104 #undef OSC_HOST_BIG_ENDIAN
105 
106 #elif (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) \
107  || (defined(__ARMEB__) && !defined(__ARMEL__)) \
108  || (defined(__AARCH64EB__) && !defined(__AARCH64EL__)) \
109  || (defined(_MIPSEB) && !defined(_MIPSEL)) \
110  || (defined(__MIPSEB) && !defined(__MIPSEL)) \
111  || (defined(__MIPSEB__) && !defined(__MIPSEL__))
112 
113 #define OSC_HOST_BIG_ENDIAN 1
114 #undef OSC_HOST_LITTLE_ENDIAN
115 
116 #endif
117 
118 #endif
119 
120 #if !defined(OSC_HOST_LITTLE_ENDIAN) && !defined(OSC_HOST_BIG_ENDIAN)
121 
122 #error please edit OSCHostEndianness.h or define one of {OSC_HOST_LITTLE_ENDIAN, OSC_HOST_BIG_ENDIAN} to configure endianness
123 
124 #endif
125 
126 #endif /* INCLUDED_OSCPACK_OSCHOSTENDIANNESS_H */
127