1 /* ===-- int_lib.h - configuration header for compiler-rt -----------------===
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 * ===----------------------------------------------------------------------===
10 * This file is not part of the interface of this library.
12 * This file defines various standard types, most importantly a number of unions
13 * used to access parts of larger types.
15 * ===----------------------------------------------------------------------===
21 #include "int_endianness.h"
23 /* si_int is defined in Linux sysroot's asm-generic/siginfo.h */
28 typedef unsigned su_int;
30 typedef long long di_int;
31 typedef unsigned long long du_int;
38 #if _YUGA_LITTLE_ENDIAN
44 #endif /* _YUGA_LITTLE_ENDIAN */
53 #if _YUGA_LITTLE_ENDIAN
59 #endif /* _YUGA_LITTLE_ENDIAN */
63 #if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \
64 defined(__riscv) || defined(_WIN64)
65 #define CRT_HAS_128BIT
68 /* MSVC doesn't have a working 128bit integer type. Users should really compile
69 * compiler-rt with clang, but if they happen to be doing a standalone build for
70 * asan or something else, disable the 128 bit parts so things sort of work.
72 #if defined(_MSC_VER) && !defined(__clang__)
77 typedef int ti_int __attribute__ ((mode (TI)));
78 typedef unsigned tu_int __attribute__ ((mode (TI)));
85 #if _YUGA_LITTLE_ENDIAN
91 #endif /* _YUGA_LITTLE_ENDIAN */
100 #if _YUGA_LITTLE_ENDIAN
106 #endif /* _YUGA_LITTLE_ENDIAN */
110 static __inline ti_int make_ti(di_int h, di_int l) {
117 static __inline tu_int make_tu(du_int h, du_int l) {
124 #endif /* CRT_HAS_128BIT */
142 #if _YUGA_LITTLE_ENDIAN
148 #endif /* _YUGA_LITTLE_ENDIAN */
151 /* Check if the target supports 80 bit extended precision long doubles.
152 * Notably, on x86 Windows, MSVC only provides a 64-bit long double, but GCC
153 * still makes it 80 bits. Clang will match whatever compiler it is trying to
154 * be compatible with.
156 #if ((defined(__i386__) || defined(__x86_64__)) && !defined(_MSC_VER)) || \
157 defined(__m68k__) || defined(__ia64__)
158 #define HAS_80_BIT_LONG_DOUBLE 1
160 #define HAS_80_BIT_LONG_DOUBLE 0
170 #if __STDC_VERSION__ >= 199901L
171 typedef float _Complex Fcomplex;
172 typedef double _Complex Dcomplex;
173 typedef long double _Complex Lcomplex;
175 #define COMPLEX_REAL(x) __real__(x)
176 #define COMPLEX_IMAGINARY(x) __imag__(x)
178 typedef struct { float real, imaginary; } Fcomplex;
180 typedef struct { double real, imaginary; } Dcomplex;
182 typedef struct { long double real, imaginary; } Lcomplex;
184 #define COMPLEX_REAL(x) (x).real
185 #define COMPLEX_IMAGINARY(x) (x).imaginary
188 #endif /* INT_TYPES_H */