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 functions. *|
20 |*===----------------------------------------------------------------------===*/
22 /* Please leave this file C-compatible. */
24 #ifndef SUPPORT_DATATYPES_H
25 #define SUPPORT_DATATYPES_H
27 #cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
28 #cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
29 #cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T}
30 #cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T}
41 #ifdef HAVE_INTTYPES_H
52 #error "Compiler must provide an implementation of stdint.h"
58 #if !defined(UINT32_MAX)
59 # error "The standard header <cstdint> is not C++11 compliant. Must #define "\
60 "__STDC_LIMIT_MACROS before #including Support/DataTypes.h"
63 #if !defined(UINT32_C)
64 # error "The standard header <cstdint> is not C++11 compliant. Must #define "\
65 "__STDC_CONSTANT_MACROS before #including Support/DataTypes.h"
68 /* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */
69 #include <sys/types.h>
72 // GCC is strict about defining large constants: they must have LL modifier.
77 /* Handle incorrect definition of uint64_t as u_int64_t */
80 typedef u_int64_t uint64_t;
82 # error "Don't have a definition for uint64_t on this platform"
94 #include <sys/types.h>
97 typedef signed __int64 ssize_t;
99 typedef signed int ssize_t;
102 #ifndef HAVE_INTTYPES_H
103 #define PRId64 "I64d"
104 #define PRIi64 "I64i"
105 #define PRIo64 "I64o"
106 #define PRIu64 "I64u"
107 #define PRIx64 "I64x"
108 #define PRIX64 "I64X"
116 #endif /* HAVE_INTTYPES_H */
118 #endif /* _MSC_VER */
120 /* Set defaults for constants which we cannot find. */
121 #if !defined(INT64_MAX)
122 # define INT64_MAX 9223372036854775807LL
124 #if !defined(INT64_MIN)
125 # define INT64_MIN ((-INT64_MAX)-1)
127 #if !defined(UINT64_MAX)
128 # define UINT64_MAX 0xffffffffffffffffULL
132 #define HUGE_VALF (float)HUGE_VAL
135 #endif /* SUPPORT_DATATYPES_H */