summaryrefslogtreecommitdiff
path: root/test/Unit/endianness.h
blob: 9e192c102104f8969caf1e2d1c842f7ac835da4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* ===-- endianness.h - configuration header for libgcc replacement --------===
 *
 *		       The LLVM Compiler Infrastructure
 *
 * This file is distributed under the University of Illinois Open Source
 * License. See LICENSE.TXT for details.
 *
 * ===----------------------------------------------------------------------===
 *
 * This file is a configuration header for libgcc replacement.
 * This file is not part of the interface of this library.
 *
 * ===----------------------------------------------------------------------===
 */

#ifndef ENDIANNESS_H
#define ENDIANNESS_H

/* TODO: Improve this to minimal pre-processor hackish'ness. */
/* config.h build via CMake. */
/* #include <config.h> */
/* Solaris header for endian and byte swap */
/* #if defined HAVE_SYS_BYTEORDER_H */

#if defined (__SVR4) && defined (__sun)
#include <sys/byteorder.h>
#if _BYTE_ORDER == _BIG_ENDIAN
#define __BIG_ENDIAN__ 1
#define __LITTLE_ENDIAN__ 0
#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
#define __BIG_ENDIAN__ 0
#define __LITTLE_ENDIAN__ 1
#endif /* _BYTE_ORDER */
#endif /* Solaris and AuroraUX. */

#if defined (__FreeBSD__)
#include <sys/endian.h>
#if _BYTE_ORDER == _BIG_ENDIAN
#define __BIG_ENDIAN__ 1
#define __LITTLE_ENDIAN__ 0
#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
#define __BIG_ENDIAN__ 0
#define __LITTLE_ENDIAN__ 1
#endif /* _BYTE_ORDER */
#endif /* FreeBSD */

#ifdef __LITTLE_ENDIAN__
#if __LITTLE_ENDIAN__
#define _YUGA_LITTLE_ENDIAN 1
#define _YUGA_BIG_ENDIAN    0
#endif
#endif

#ifdef __BIG_ENDIAN__
#if __BIG_ENDIAN__
#define _YUGA_LITTLE_ENDIAN 0
#define _YUGA_BIG_ENDIAN    1
#endif
#endif

#if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN)
#error unable to determine endian
#endif

#endif /* ENDIANNESS_H */