1 /*===-- include/llvm-c/DataTypes.h - Define fixed size types ------*- C -*-===*\
2 |*                                                                            *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
4 |* Exceptions.                                                                *|
5 |* See https://llvm.org/LICENSE.txt for license information.                  *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
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 LLVM_C_DATATYPES_H
25 #define LLVM_C_DATATYPES_H
26 
27 #ifdef __cplusplus
28 #include <cmath>
29 #else
30 #include <math.h>
31 #endif
32 
33 #include <inttypes.h>
34 #include <stdint.h>
35 
36 #ifndef _MSC_VER
37 
38 #if !defined(UINT32_MAX)
39 # error "The standard header <cstdint> is not C++11 compliant. Must #define "\
40         "__STDC_LIMIT_MACROS before #including llvm-c/DataTypes.h"
41 #endif
42 
43 #if !defined(UINT32_C)
44 # error "The standard header <cstdint> is not C++11 compliant. Must #define "\
45         "__STDC_CONSTANT_MACROS before #including llvm-c/DataTypes.h"
46 #endif
47 
48 /* Note that <inttypes.h> includes <stdint.h>, if this is a C99 system. */
49 #include <sys/types.h>
50 
51 #ifdef _AIX
52 // GCC is strict about defining large constants: they must have LL modifier.
53 #undef INT64_MAX
54 #undef INT64_MIN
55 #endif
56 
57 #else /* _MSC_VER */
58 #ifdef __cplusplus
59 #include <cstddef>
60 #include <cstdlib>
61 #else
62 #include <stddef.h>
63 #include <stdlib.h>
64 #endif
65 #include <sys/types.h>
66 
67 #if defined(_WIN64)
68 typedef signed __int64 ssize_t;
69 #else
70 typedef signed int ssize_t;
71 #endif /* _WIN64 */
72 
73 #endif /* _MSC_VER */
74 
75 /* Set defaults for constants which we cannot find. */
76 #if !defined(INT64_MAX)
77 # define INT64_MAX 9223372036854775807LL
78 #endif
79 #if !defined(INT64_MIN)
80 # define INT64_MIN ((-INT64_MAX)-1)
81 #endif
82 #if !defined(UINT64_MAX)
83 # define UINT64_MAX 0xffffffffffffffffULL
84 #endif
85 
86 #ifndef HUGE_VALF
87 #define HUGE_VALF (float)HUGE_VAL
88 #endif
89 
90 #endif /* LLVM_C_DATATYPES_H */
91