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