* AIX on Power defines INT64_MIN and INT64_MAX in ways that annoy GCC, so
[oota-llvm.git] / include / llvm / Support / DataTypes.h.in
1 //===-- include/Support/DataTypes.h - Define fixed size types ---*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains definitions to figure out the size of _HOST_ data types.
11 // This file is important because different host OS's define different macros,
12 // which makes portability tough.  This file exports the following definitions:
13 //
14 //   [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types
15 //   [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values.
16 //
17 // No library is required when using these functinons.
18 //
19 //===----------------------------------------------------------------------===//
20
21 #ifndef SUPPORT_DATATYPES_H
22 #define SUPPORT_DATATYPES_H
23
24 #include "llvm/Config/config.h"
25
26 // Note that this header's correct operation depends on __STDC_LIMIT_MACROS
27 // being defined.  We would define it here, but in order to prevent Bad Things
28 // happening when system headers or C++ STL headers include stdint.h before
29 // we define it here, we define it on the g++ command line (in Makefile.rules).
30 #if !defined(__STDC_LIMIT_MACROS)
31 # error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
32 #endif
33
34 #undef HAVE_SYS_TYPES_H
35 #undef HAVE_INTTYPES_H
36 #undef HAVE_STDINT_H
37
38 #ifndef _MSC_VER
39 // Note that <inttypes.h> includes <stdint.h>, if this is a C99 system.
40 #ifdef HAVE_SYS_TYPES_H
41 #include <sys/types.h>
42 #endif
43
44 #ifdef HAVE_INTTYPES_H
45 #include <inttypes.h>
46 #endif
47
48 #ifdef HAVE_STDINT_H
49 #include <stdint.h>
50 #endif
51
52 #if defined(_POWER) && defined(_AIX)
53 // GCC is strict about defining large constants: they must have LL modifier.
54 // We will catch INT64_MAX in the default case below.
55 #undef INT64_MAX
56 // AIX #defines INT64_MIN as (-INT64_MAX-1), or -9223372036854775808 which GCC
57 // complains about as `integer constant is so large that it is unsigned', so
58 // set INT64_MIN to be one above that:
59 #undef INT64_MIN
60 #define INT64_MIN -9223372036854775807LL
61 #endif
62
63 // Handle incorrect definition of uint64_t as u_int64_t
64 #ifndef HAVE_UINT64_T
65 #ifdef HAVE_U_INT64_T
66 typedef u_int64_t uint64_t;
67 #else
68 # error "Don't have a definition for uint64_t on this platform"
69 #endif
70 #endif
71
72 #else /* _MSC_VER */
73 // Visual C++ doesn't provide standard integer headers, but it does provide
74 // built-in data types.
75 typedef __int64 int64_t;
76 typedef unsigned __int64 uint64_t;
77 typedef signed   int int32_t;
78 typedef unsigned int uint32_t;
79 typedef signed   int ssize_t;
80 #define INT8_MAX 127
81 #define INT8_MIN -128
82 #define UINT8_MAX 255
83 #define INT16_MAX 32767
84 #define INT16_MIN -32768
85 #define UINT16_MAX 65535
86 #define INT32_MAX 2147483647
87 #define INT32_MIN -2147483648
88 #define UINT32_MAX 4294967295U
89 #endif /* _MSC_VER */
90
91 /* Set defaults for constants which we cannot find. */
92 #if !defined(INT64_MAX)
93 # define INT64_MAX 9223372036854775807LL
94 #endif
95 #if !defined(UINT64_MAX)
96 # define UINT64_MAX 0xffffffffffffffffULL
97 #endif
98
99 #endif  /* SUPPORT_DATATYPES_H */