Changes to make the Windows build work...
[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 is distributed under the University of Illinois Open Source
6 // 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 #undef HAVE_SYS_TYPES_H
25 #undef HAVE_INTTYPES_H
26 #undef HAVE_STDINT_H
27 #undef HAVE_UINT64_T
28 #undef HAVE_U_INT64_T
29
30 #ifndef _MSC_VER
31
32 // Note that this header's correct operation depends on __STDC_LIMIT_MACROS
33 // being defined.  We would define it here, but in order to prevent Bad Things
34 // happening when system headers or C++ STL headers include stdint.h before
35 // we define it here, we define it on the g++ command line (in Makefile.rules).
36 #if !defined(__STDC_LIMIT_MACROS)
37 # error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
38 #endif
39
40 #if !defined(__STDC_CONSTANT_MACROS)
41 # error "Must #define __STDC_CONSTANT_MACROS before " \
42         "#including Support/DataTypes.h"
43 #endif
44
45 // Note that <inttypes.h> includes <stdint.h>, if this is a C99 system.
46 #ifdef HAVE_SYS_TYPES_H
47 #include <sys/types.h>
48 #endif
49
50 #ifdef HAVE_INTTYPES_H
51 #include <inttypes.h>
52 #endif
53
54 #ifdef HAVE_STDINT_H
55 #include <stdint.h>
56 #endif
57
58 #ifdef __cplusplus
59 #include <cmath>
60 #else
61 #include <math.h>
62 #endif
63
64 #ifdef _AIX
65 #include "llvm/Support/AIXDataTypesFix.h"
66 #endif
67
68 // Handle incorrect definition of uint64_t as u_int64_t
69 #ifndef HAVE_UINT64_T
70 #ifdef HAVE_U_INT64_T
71 typedef u_int64_t uint64_t;
72 #else
73 # error "Don't have a definition for uint64_t on this platform"
74 #endif
75 #endif
76
77 #ifdef _OpenBSD_
78 #define INT8_MAX 127
79 #define INT8_MIN -128
80 #define UINT8_MAX 255
81 #define INT16_MAX 32767
82 #define INT16_MIN -32768
83 #define UINT16_MAX 65535
84 #define INT32_MAX 2147483647
85 #define INT32_MIN -2147483648
86 #define UINT32_MAX 4294967295U
87 #endif
88
89 #else /* _MSC_VER */
90 // Visual C++ doesn't provide standard integer headers, but it does provide
91 // built-in data types.
92 #include <stdlib.h>
93 #include <stddef.h>
94 #include <sys/types.h>
95 typedef __int64 int64_t;
96 typedef unsigned __int64 uint64_t;
97 typedef signed int int32_t;
98 typedef unsigned int uint32_t;
99 typedef short int16_t;
100 typedef unsigned short uint16_t;
101 typedef signed char int8_t;
102 typedef unsigned char uint8_t;
103 typedef signed int ssize_t;
104 #define INT8_MAX 127
105 #define INT8_MIN -128
106 #define UINT8_MAX 255
107 #define INT16_MAX 32767
108 #define INT16_MIN -32768
109 #define UINT16_MAX 65535
110 #define INT32_MAX 2147483647
111 #define INT32_MIN -2147483648
112 #define UINT32_MAX 4294967295U
113 #define INT8_C(C)   C
114 #define UINT8_C(C)  C
115 #define INT16_C(C)  C
116 #define UINT16_C(C) C
117 #define INT32_C(C)  C
118 #define UINT32_C(C) C ## U
119 #define INT64_C(C)  ((int64_t) C ## LL)
120 #define UINT64_C(C) ((uint64_t) C ## ULL)
121 #endif /* _MSC_VER */
122
123 /* Set defaults for constants which we cannot find. */
124 #if !defined(INT64_MAX)
125 # define INT64_MAX 9223372036854775807LL
126 #endif
127 #if !defined(INT64_MIN)
128 # define INT64_MIN ((-INT64_MAX)-1)
129 #endif
130 #if !defined(UINT64_MAX)
131 # define UINT64_MAX 0xffffffffffffffffULL
132 #endif
133
134 #if __GNUC__ > 3
135 #define END_WITH_NULL __attribute__((sentinel))
136 #else
137 #define END_WITH_NULL
138 #endif
139
140 #ifndef HUGE_VALF
141 #define HUGE_VALF (float)HUGE_VAL
142 #endif
143
144 #endif  /* SUPPORT_DATATYPES_H */