Try to work well on multiple platforms.
[oota-llvm.git] / include / Support / DataTypes.h
1 //===-- include/Support/DataTypes.h - Define fixed size types ----*- C++ -*--=//
2 //
3 // This file contains definitions to figure out the size of _HOST_ data types.
4 // This file is important because different host OS's define different macros,
5 // which makes portability tough.  This file exports the following definitions:
6 //
7 //   LITTLE_ENDIAN: is #define'd if the host is little endian
8 //   int64_t      : is a typedef for the signed 64 bit system type
9 //   uint64_t     : is a typedef for the unsigned 64 bit system type
10 //   INT64_MAX    : is a #define specifying the max value for int64_t's
11 //
12 // No library is required when using these functinons.
13 //
14 //===----------------------------------------------------------------------===//
15
16 // TODO: This file sucks.  Not only does it not work, but this stuff should be
17 // autoconfiscated anyways. Major FIXME
18
19 #ifndef LLVM_SUPPORT_DATATYPES_H
20 #define LLVM_SUPPORT_DATATYPES_H
21
22 #define __STDC_LIMIT_MACROS 1
23 #include <inttypes.h>
24
25 #ifdef __linux__
26 #include <endian.h>
27 #endif
28
29 #ifdef __sparc__
30 #include <sys/types.h>
31 #ifdef _LITTLE_ENDIAN
32 #define LITTLE_ENDIAN 1
33 #else
34 #define BIG_ENDIAN 1
35 #endif
36 #endif
37
38 #ifndef LITTLE_ENDIAN
39 #if !defined(BIG_ENDIAN) || !defined(INT64_MAX)
40 #error "include/Support/DataTypes.h could not determine endianness!"
41 #endif
42 #endif
43
44 #endif  /* LLVM_SUPPORT_DATATYPES_H */