I swear I did a make clean and make before committing all this...
[oota-llvm.git] / include / llvm / Support / DataTypes.h.in
1 /*===-- include/System/DataTypes.h - Define fixed size types -----*- C -*-===*\
2 |*                                                                            *|
3 |*                     The LLVM Compiler Infrastructure                       *|
4 |*                                                                            *|
5 |* This file is distributed under the University of Illinois Open Source      *|
6 |* 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            *|
13 |* definitions:                                                               *|
14 |*                                                                            *|
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.     *|
17 |*                                                                            *|
18 |* No library is required when using these functions.                         *|
19 |*                                                                            *|
20 |*===----------------------------------------------------------------------===*/
21
22 /* Please leave this file C-compatible. */
23
24 #ifndef SUPPORT_DATATYPES_H
25 #define SUPPORT_DATATYPES_H
26
27 #undef HAVE_SYS_TYPES_H
28 #undef HAVE_INTTYPES_H
29 #undef HAVE_STDINT_H
30 #undef HAVE_UINT64_T
31 #undef HAVE_U_INT64_T
32
33 #ifdef __cplusplus
34 #include <cmath>
35 #else
36 #include <math.h>
37 #endif
38
39 /* Note that this header's correct operation depends on __STDC_LIMIT_MACROS
40    being defined.  We would define it here, but in order to prevent Bad Things
41    happening when system headers or C++ STL headers include stdint.h before we
42    define it here, we define it on the g++ command line (in Makefile.rules). */
43 #if !defined(__STDC_LIMIT_MACROS)
44 # error "Must #define __STDC_LIMIT_MACROS before #including System/DataTypes.h"
45 #endif
46
47 #if !defined(__STDC_CONSTANT_MACROS)
48 # error "Must #define __STDC_CONSTANT_MACROS before " \
49         "#including System/DataTypes.h"
50 #endif
51
52 /* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */
53 #ifdef HAVE_SYS_TYPES_H
54 #include <sys/types.h>
55 #endif
56
57 #ifdef HAVE_INTTYPES_H
58 #include <inttypes.h>
59 #endif
60
61 #ifdef HAVE_STDINT_H
62 #include <stdint.h>
63 #endif
64
65 #ifdef _AIX
66 #include "llvm/Support/AIXDataTypesFix.h"
67 #endif
68
69 /* Handle incorrect definition of uint64_t as u_int64_t */
70 #ifndef HAVE_UINT64_T
71 #ifdef HAVE_U_INT64_T
72 typedef u_int64_t uint64_t;
73 #else
74 # error "Don't have a definition for uint64_t on this platform"
75 #endif
76 #endif
77
78 #ifdef _OpenBSD_
79 #define INT8_MAX 127
80 #define INT8_MIN -128
81 #define UINT8_MAX 255
82 #define INT16_MAX 32767
83 #define INT16_MIN -32768
84 #define UINT16_MAX 65535
85 #define INT32_MAX 2147483647
86 #define INT32_MIN -2147483648
87 #define UINT32_MAX 4294967295U
88 #endif
89
90 /* Set defaults for constants which we cannot find. */
91 #if !defined(INT64_MAX)
92 # define INT64_MAX 9223372036854775807LL
93 #endif
94 #if !defined(INT64_MIN)
95 # define INT64_MIN ((-INT64_MAX)-1)
96 #endif
97 #if !defined(UINT64_MAX)
98 # define UINT64_MAX 0xffffffffffffffffULL
99 #endif
100
101 #if __GNUC__ > 3
102 #define END_WITH_NULL __attribute__((sentinel))
103 #else
104 #define END_WITH_NULL
105 #endif
106
107 #ifndef HUGE_VALF
108 #define HUGE_VALF (float)HUGE_VAL
109 #endif
110
111 #endif  /* SUPPORT_DATATYPES_H */