1 /* include/llvm/Support/DataTypes.h. Generated from DataTypes.h.in by configure. */ 2 /*===-- include/Support/DataTypes.h - Define fixed size types -----*- C -*-===*\ 3 |* *| 4 |* The LLVM Compiler Infrastructure *| 5 |* *| 6 |* This file is distributed under the University of Illinois Open Source *| 7 |* License. See LICENSE.TXT for details. *| 8 |* *| 9 |*===----------------------------------------------------------------------===*| 10 |* *| 11 |* This file contains definitions to figure out the size of _HOST_ data types.*| 12 |* This file is important because different host OS's define different macros,*| 13 |* which makes portability tough. This file exports the following *| 14 |* definitions: *| 15 |* *| 16 |* [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types*| 17 |* [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. *| 18 |* *| 19 |* No library is required when using these functions. *| 20 |* *| 21 |*===----------------------------------------------------------------------===*/ 22 23 /* Please leave this file C-compatible. */ 24 25 /* Please keep this file in sync with DataTypes.h.cmake */ 26 27 #ifndef SUPPORT_DATATYPES_H 28 #define SUPPORT_DATATYPES_H 29 30 #define HAVE_INTTYPES_H 1 31 #define HAVE_STDINT_H 1 32 #define HAVE_UINT64_T 1 33 /* #undef HAVE_U_INT64_T */ 34 35 #ifdef __cplusplus 36 #include <cmath> 37 #else 38 #include <math.h> 39 #endif 40 41 #ifndef _MSC_VER 42 43 /* Note that this header's correct operation depends on __STDC_LIMIT_MACROS 44 being defined. We would define it here, but in order to prevent Bad Things 45 happening when system headers or C++ STL headers include stdint.h before we 46 define it here, we define it on the g++ command line (in Makefile.rules). */ 47 #if !defined(__STDC_LIMIT_MACROS) 48 # error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" 49 #endif 50 51 #if !defined(__STDC_CONSTANT_MACROS) 52 # error "Must #define __STDC_CONSTANT_MACROS before " \ 53 "#including Support/DataTypes.h" 54 #endif 55 56 /* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */ 57 #include <sys/types.h> 58 59 #ifdef HAVE_INTTYPES_H 60 #include <inttypes.h> 61 #endif 62 63 #ifdef HAVE_STDINT_H 64 #include <stdint.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 #else /* _MSC_VER */ 81 /* Visual C++ doesn't provide standard integer headers, but it does provide 82 built-in data types. */ 83 #include <stdlib.h> 84 #include <stddef.h> 85 #include <sys/types.h> 86 #ifdef __cplusplus 87 #include <cmath> 88 #else 89 #include <math.h> 90 #endif 91 typedef __int64 int64_t; 92 typedef unsigned __int64 uint64_t; 93 typedef signed int int32_t; 94 typedef unsigned int uint32_t; 95 typedef short int16_t; 96 typedef unsigned short uint16_t; 97 typedef signed char int8_t; 98 typedef unsigned char uint8_t; 99 #if defined(_WIN64) 100 typedef signed __int64 ssize_t; 101 #else 102 typedef signed int ssize_t; 103 #endif 104 105 #ifndef INT8_MAX 106 # define INT8_MAX 127 107 #endif 108 #ifndef INT8_MIN 109 # define INT8_MIN -128 110 #endif 111 #ifndef UINT8_MAX 112 # define UINT8_MAX 255 113 #endif 114 #ifndef INT16_MAX 115 # define INT16_MAX 32767 116 #endif 117 #ifndef INT16_MIN 118 # define INT16_MIN -32768 119 #endif 120 #ifndef UINT16_MAX 121 # define UINT16_MAX 65535 122 #endif 123 #ifndef INT32_MAX 124 # define INT32_MAX 2147483647 125 #endif 126 #ifndef INT32_MIN 127 /* MSC treats -2147483648 as -(2147483648U). */ 128 # define INT32_MIN (-INT32_MAX - 1) 129 #endif 130 #ifndef UINT32_MAX 131 # define UINT32_MAX 4294967295U 132 #endif 133 /* Certain compatibility updates to VC++ introduce the `cstdint' 134 * header, which defines the INT*_C macros. On default installs they 135 * are absent. */ 136 #ifndef INT8_C 137 # define INT8_C(C) C##i8 138 #endif 139 #ifndef UINT8_C 140 # define UINT8_C(C) C##ui8 141 #endif 142 #ifndef INT16_C 143 # define INT16_C(C) C##i16 144 #endif 145 #ifndef UINT16_C 146 # define UINT16_C(C) C##ui16 147 #endif 148 #ifndef INT32_C 149 # define INT32_C(C) C##i32 150 #endif 151 #ifndef UINT32_C 152 # define UINT32_C(C) C##ui32 153 #endif 154 #ifndef INT64_C 155 # define INT64_C(C) C##i64 156 #endif 157 #ifndef UINT64_C 158 # define UINT64_C(C) C##ui64 159 #endif 160 161 #ifndef PRId64 162 # define PRId64 "I64d" 163 #endif 164 #ifndef PRIi64 165 # define PRIi64 "I64i" 166 #endif 167 #ifndef PRIo64 168 # define PRIo64 "I64o" 169 #endif 170 #ifndef PRIu64 171 # define PRIu64 "I64u" 172 #endif 173 #ifndef PRIx64 174 # define PRIx64 "I64x" 175 #endif 176 #ifndef PRIX64 177 # define PRIX64 "I64X" 178 #endif 179 180 #endif /* _MSC_VER */ 181 182 /* Set defaults for constants which we cannot find. */ 183 #if !defined(INT64_MAX) 184 # define INT64_MAX 9223372036854775807LL 185 #endif 186 #if !defined(INT64_MIN) 187 # define INT64_MIN ((-INT64_MAX)-1) 188 #endif 189 #if !defined(UINT64_MAX) 190 # define UINT64_MAX 0xffffffffffffffffULL 191 #endif 192 193 #if __GNUC__ > 3 194 #define END_WITH_NULL __attribute__((sentinel)) 195 #else 196 #define END_WITH_NULL 197 #endif 198 199 #ifndef HUGE_VALF 200 #define HUGE_VALF (float)HUGE_VAL 201 #endif 202 203 #endif /* SUPPORT_DATATYPES_H */ 204