1 //===-- include/Support/DataTypes.h - Define fixed size types ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
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 definitions:
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.
17 // No library is required when using these functinons.
19 //===----------------------------------------------------------------------===//
21 #ifndef SUPPORT_DATATYPES_H
22 #define SUPPORT_DATATYPES_H
24 #undef HAVE_SYS_TYPES_H
25 #undef HAVE_INTTYPES_H
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"
40 // Note that <inttypes.h> includes <stdint.h>, if this is a C99 system.
41 #ifdef HAVE_SYS_TYPES_H
42 #include <sys/types.h>
45 #ifdef HAVE_INTTYPES_H
54 #include "llvm/Support/AIXDataTypesFix.h"
57 // Handle incorrect definition of uint64_t as u_int64_t
60 typedef u_int64_t uint64_t;
62 # error "Don't have a definition for uint64_t on this platform"
70 #define INT16_MAX 32767
71 #define INT16_MIN -32768
72 #define UINT16_MAX 65535
73 #define INT32_MAX 2147483647
74 #define INT32_MIN -2147483648
75 #define UINT32_MAX 4294967295U
79 // Visual C++ doesn't provide standard integer headers, but it does provide
80 // built-in data types.
82 #include <sys/types.h>
83 typedef __int64 int64_t;
84 typedef unsigned __int64 uint64_t;
85 typedef signed int int32_t;
86 typedef unsigned int uint32_t;
87 typedef short int16_t;
88 typedef unsigned short uint16_t;
89 typedef signed char int8_t;
90 typedef unsigned char uint8_t;
91 typedef signed int ssize_t;
95 #define INT16_MAX 32767
96 #define INT16_MIN -32768
97 #define UINT16_MAX 65535
98 #define INT32_MAX 2147483647
99 #define INT32_MIN -2147483648
100 #define UINT32_MAX 4294967295U
101 #endif /* _MSC_VER */
103 /* Set defaults for constants which we cannot find. */
104 #if !defined(INT64_MAX)
105 # define INT64_MAX 9223372036854775807LL
107 #if !defined(INT64_MIN)
108 # define INT64_MIN ((-INT64_MAX)-1)
110 #if !defined(UINT64_MAX)
111 # define UINT64_MAX 0xffffffffffffffffULL
115 #define END_WITH_NULL __attribute__((sentinel))
117 #define END_WITH_NULL
121 #define HUGE_VALF (float)HUGE_VAL
124 #endif /* SUPPORT_DATATYPES_H */