1/*===-- include/Support/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/* Please keep this file in sync with DataTypes.h.in */
25
26#ifndef SUPPORT_DATATYPES_H
27#define SUPPORT_DATATYPES_H
28
29#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
30#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
31#cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T}
32#cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T}
33
34#ifdef __cplusplus
35#include <cmath>
36#else
37#include <math.h>
38#endif
39
40#ifdef HAVE_INTTYPES_H
41#include <inttypes.h>
42#endif
43
44#ifdef HAVE_STDINT_H
45#include <stdint.h>
46#else
47#error "Compiler must provide an implementation of stdint.h"
48#endif
49
50#ifndef _MSC_VER
51
52/* Note that this header's correct operation depends on __STDC_LIMIT_MACROS
53   being defined.  We would define it here, but in order to prevent Bad Things
54   happening when system headers or C++ STL headers include stdint.h before we
55   define it here, we define it on the g++ command line (in Makefile.rules). */
56#if !defined(__STDC_LIMIT_MACROS)
57# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"
58#endif
59
60#if !defined(__STDC_CONSTANT_MACROS)
61# error "Must #define __STDC_CONSTANT_MACROS before " \
62        "#including Support/DataTypes.h"
63#endif
64
65/* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */
66#include <sys/types.h>
67
68#ifdef _AIX
69#include "llvm/Support/AIXDataTypesFix.h"
70#endif
71
72/* Handle incorrect definition of uint64_t as u_int64_t */
73#ifndef HAVE_UINT64_T
74#ifdef HAVE_U_INT64_T
75typedef u_int64_t uint64_t;
76#else
77# error "Don't have a definition for uint64_t on this platform"
78#endif
79#endif
80
81#else /* _MSC_VER */
82#include <stdlib.h>
83#include <stddef.h>
84#include <sys/types.h>
85#ifdef __cplusplus
86#include <cmath>
87#else
88#include <math.h>
89#endif
90
91#if defined(_WIN64)
92typedef signed __int64 ssize_t;
93#else
94typedef signed int ssize_t;
95#endif /* _WIN64 */
96
97#ifndef HAVE_INTTYPES_H
98#define PRId64 "I64d"
99#define PRIi64 "I64i"
100#define PRIo64 "I64o"
101#define PRIu64 "I64u"
102#define PRIx64 "I64x"
103#define PRIX64 "I64X"
104#endif /* HAVE_INTTYPES_H */
105
106#endif /* _MSC_VER */
107
108/* Set defaults for constants which we cannot find. */
109#if !defined(INT64_MAX)
110# define INT64_MAX 9223372036854775807LL
111#endif
112#if !defined(INT64_MIN)
113# define INT64_MIN ((-INT64_MAX)-1)
114#endif
115#if !defined(UINT64_MAX)
116# define UINT64_MAX 0xffffffffffffffffULL
117#endif
118
119#if __GNUC__ > 3
120#define END_WITH_NULL __attribute__((sentinel))
121#else
122#define END_WITH_NULL
123#endif
124
125#ifndef HUGE_VALF
126#define HUGE_VALF (float)HUGE_VAL
127#endif
128
129#endif  /* SUPPORT_DATATYPES_H */
130