Edward O'Callaghan | 1fcb40b | 2009-08-05 19:06:50 +0000 | [diff] [blame^] | 1 | /* ===-- endianness.h - configuration header for libgcc replacement --------=== |
| 2 | * |
| 3 | * The LLVM Compiler Infrastructure |
| 4 | * |
| 5 | * This file is distributed under the University of Illinois Open Source |
| 6 | * License. See LICENSE.TXT for details. |
| 7 | * |
| 8 | * ===----------------------------------------------------------------------=== |
| 9 | * |
| 10 | * This file is a configuration header for libgcc replacement. |
| 11 | * This file is not part of the interface of this library. |
| 12 | * |
| 13 | * ===----------------------------------------------------------------------=== |
| 14 | */ |
| 15 | |
| 16 | #ifndef ENDIANNESS_H |
| 17 | #define ENDIANNESS_H |
| 18 | |
| 19 | /* TODO: Improve this to minimal pre-processor hackish'ness. */ |
| 20 | /* config.h build via CMake. */ |
| 21 | /* #include <config.h> */ |
| 22 | /* Solaris header for endian and byte swap */ |
| 23 | /* #if defined HAVE_SYS_BYTEORDER_H */ |
| 24 | |
| 25 | #if defined (__SVR4) && defined (__sun) |
| 26 | #include <sys/byteorder.h> |
| 27 | #if _BYTE_ORDER == _BIG_ENDIAN |
| 28 | #define __BIG_ENDIAN__ 1 |
| 29 | #define __LITTLE_ENDIAN__ 0 |
| 30 | #else /* _BYTE_ORDER == _LITTLE_ENDIAN */ |
| 31 | #define __BIG_ENDIAN__ 0 |
| 32 | #define __LITTLE_ENDIAN__ 1 |
| 33 | #endif /* _BYTE_ORDER */ |
| 34 | #endif /* Solaris and AuroraUX. */ |
| 35 | |
| 36 | #if defined (__FreeBSD__) |
| 37 | #include <sys/endian.h> |
| 38 | #if _BYTE_ORDER == _BIG_ENDIAN |
| 39 | #define __BIG_ENDIAN__ 1 |
| 40 | #define __LITTLE_ENDIAN__ 0 |
| 41 | #else /* _BYTE_ORDER == _LITTLE_ENDIAN */ |
| 42 | #define __BIG_ENDIAN__ 0 |
| 43 | #define __LITTLE_ENDIAN__ 1 |
| 44 | #endif /* _BYTE_ORDER */ |
| 45 | #endif /* FreeBSD */ |
| 46 | |
| 47 | #ifdef __LITTLE_ENDIAN__ |
| 48 | #if __LITTLE_ENDIAN__ |
| 49 | #define _YUGA_LITTLE_ENDIAN 1 |
| 50 | #define _YUGA_BIG_ENDIAN 0 |
| 51 | #endif |
| 52 | #endif |
| 53 | |
| 54 | #ifdef __BIG_ENDIAN__ |
| 55 | #if __BIG_ENDIAN__ |
| 56 | #define _YUGA_LITTLE_ENDIAN 0 |
| 57 | #define _YUGA_BIG_ENDIAN 1 |
| 58 | #endif |
| 59 | #endif |
| 60 | |
| 61 | #if !defined(_YUGA_LITTLE_ENDIAN) || !defined(_YUGA_BIG_ENDIAN) |
| 62 | #error unable to determine endian |
| 63 | #endif |
| 64 | |
| 65 | #endif /* ENDIANNESS_H */ |