1 /*
2 	oscpack -- Open Sound Control packet manipulation library
3 	http://www.audiomulch.com/~rossb/oscpack
4 
5 	Copyright (c) 2004-2005 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 	Any person wishing to distribute modifications to the Software is
19 	requested to send the modifications to the original developer so that
20 	they can be incorporated into the canonical version.
21 
22 	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 	IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26 	ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 	CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 */
30 #ifndef OSC_HOSTENDIANNESS_H
31 #define OSC_HOSTENDIANNESS_H
32 
33 /*
34     Make sure either OSC_HOST_LITTLE_ENDIAN or OSC_HOST_BIG_ENDIAN is defined
35 
36     If you know a way to enhance the detection below for Linux and/or MacOSX
37     please let me know! I've tried a few things which don't work.
38 */
39 
40 #if defined(OSC_HOST_LITTLE_ENDIAN) || defined(OSC_HOST_BIG_ENDIAN)
41 
42 // you can define one of the above symbols from the command line
43 // then you don't have to edit this file.
44 
45 #elif defined(__WIN32__) || defined(WIN32) || defined(WINCE)
46 
47 // assume that __WIN32__ is only defined on little endian systems
48 
49 #define OSC_HOST_LITTLE_ENDIAN 1
50 #undef OSC_HOST_BIG_ENDIAN
51 
52 #else
53 
54     #if defined(__GLIBC__) || defined(__ANDROID__) || defined(__CYGWIN__)
55         #include <endian.h>
56         #if (__BYTE_ORDER == __LITTLE_ENDIAN)
57             #ifndef __LITTLE_ENDIAN__
58                 #define __LITTLE_ENDIAN__
59             #endif
60         #elif (__BYTE_ORDER == __BIG_ENDIAN)
61             #ifndef __BIG_ENDIAN__
62                 #define __BIG_ENDIAN__
63             #endif
64         #else
65             #error Unknown machine endianness detected.
66         #endif
67     #elif defined(__FreeBSD__)
68         #include <sys/endian.h>
69         #if (_BYTE_ORDER == _LITTLE_ENDIAN)
70             #ifndef __LITTLE_ENDIAN__
71                 #define __LITTLE_ENDIAN__
72             #endif
73         #elif (_BYTE_ORDER == _BIG_ENDIAN)
74             #ifndef __BIG_ENDIAN__
75                 #define __BIG_ENDIAN__
76             #endif
77         #else
78             #error Unknown machine endianness detected.
79         #endif
80     #endif
81 
82     #if   defined(__LITTLE_ENDIAN__)
83 
84         #define OSC_HOST_LITTLE_ENDIAN 1
85         #undef OSC_HOST_BIG_ENDIAN
86 
87     #elif defined(__BIG_ENDIAN__)
88 
89         #define OSC_HOST_BIG_ENDIAN 1
90         #undef OSC_HOST_LITTLE_ENDIAN
91 
92     #else
93 
94         #error please edit OscHostEndianness.h to configure endianness
95 
96     #endif
97 
98 #endif
99 
100 
101 #endif /* OSC_HOSTENDIANNESS_H */
102 
103