1 /*===-- include/Support/DataTypes.h - Define fixed size types -----*- C -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
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 *|
15 |* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*|
16 |* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *|
18 |* No library is required when using these functinons. *|
20 |*===----------------------------------------------------------------------===*/
22 /* Please leave this file C-compatible. */
24 #ifndef SUPPORT_DATATYPES_H
25 #define SUPPORT_DATATYPES_H
27 #cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H}
28 #cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
29 #cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
30 #cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T}
31 #cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T}
41 /* Note that this header's correct operation depends on __STDC_LIMIT_MACROS
42 being defined. We would define it here, but in order to prevent Bad Things
43 happening when system headers or C++ STL headers include stdint.h before we
44 define it here, we define it on the g++ command line (in Makefile.rules). */
45 #if !defined(__STDC_LIMIT_MACROS)
46 # error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
49 #if !defined(__STDC_CONSTANT_MACROS)
50 # error "Must #define __STDC_CONSTANT_MACROS before " \
51 "#including Support/DataTypes.h"
54 /* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */
55 #ifdef HAVE_SYS_TYPES_H
56 #include <sys/types.h>
59 #ifdef HAVE_INTTYPES_H
68 #include "llvm/Support/AIXDataTypesFix.h"
71 /* Handle incorrect definition of uint64_t as u_int64_t */
74 typedef u_int64_t uint64_t;
76 # error "Don't have a definition for uint64_t on this platform"
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
93 /* Visual C++ doesn't provide standard integer headers, but it does provide
94 built-in data types. */
97 #include <sys/types.h>
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;
113 # define INT8_MAX 127
116 # define INT8_MIN -128
119 # define UINT8_MAX 255
122 # define INT16_MAX 32767
125 # define INT16_MIN -32768
128 # define UINT16_MAX 65535
131 # define INT32_MAX 2147483647
134 /* MSC treats -2147483648 as -(2147483648U). */
135 # define INT32_MIN (-INT32_MAX - 1)
138 # define UINT32_MAX 4294967295U
140 /* Certain compatibility updates to VC++ introduce the `cstdint'
141 * header, which defines the INT*_C macros. On default installs they
144 # define INT8_C(C) C##i8
147 # define UINT8_C(C) C##ui8
150 # define INT16_C(C) C##i16
153 # define UINT16_C(C) C##ui16
156 # define INT32_C(C) C##i32
159 # define UINT32_C(C) C##ui32
162 # define INT64_C(C) C##i64
165 # define UINT64_C(C) C##ui64
167 #endif /* _MSC_VER */
169 /* Set defaults for constants which we cannot find. */
170 #if !defined(INT64_MAX)
171 # define INT64_MAX 9223372036854775807LL
173 #if !defined(INT64_MIN)
174 # define INT64_MIN ((-INT64_MAX)-1)
176 #if !defined(UINT64_MAX)
177 # define UINT64_MAX 0xffffffffffffffffULL
181 #define END_WITH_NULL __attribute__((sentinel))
183 #define END_WITH_NULL
187 #define HUGE_VALF (float)HUGE_VAL
190 #endif /* SUPPORT_DATATYPES_H */