1 //===-- int_lib.h - configuration header for compiler-rt -----------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is not part of the interface of this library.
11 // This file defines various standard types, most importantly a number of unions
12 // used to access parts of larger types.
14 //===----------------------------------------------------------------------===//
19 #include "int_endianness.h"
21 // si_int is defined in Linux sysroot's asm-generic/siginfo.h
26 typedef unsigned su_int;
28 typedef long long di_int;
29 typedef unsigned long long du_int;
34 #if _YUGA_LITTLE_ENDIAN
40 #endif // _YUGA_LITTLE_ENDIAN
47 #if _YUGA_LITTLE_ENDIAN
53 #endif // _YUGA_LITTLE_ENDIAN
57 #if defined(__LP64__) || defined(__wasm__) || defined(__mips64) || \
58 defined(__riscv) || defined(_WIN64)
59 #define CRT_HAS_128BIT
62 // MSVC doesn't have a working 128bit integer type. Users should really compile
63 // compiler-rt with clang, but if they happen to be doing a standalone build for
64 // asan or something else, disable the 128 bit parts so things sort of work.
65 #if defined(_MSC_VER) && !defined(__clang__)
70 typedef int ti_int __attribute__((mode(TI)));
71 typedef unsigned tu_int __attribute__((mode(TI)));
76 #if _YUGA_LITTLE_ENDIAN
82 #endif // _YUGA_LITTLE_ENDIAN
89 #if _YUGA_LITTLE_ENDIAN
95 #endif // _YUGA_LITTLE_ENDIAN
99 static __inline ti_int make_ti(di_int h, di_int l) {
106 static __inline tu_int make_tu(du_int h, du_int l) {
113 #endif // CRT_HAS_128BIT
128 #if _YUGA_LITTLE_ENDIAN
134 #endif // _YUGA_LITTLE_ENDIAN
137 // Check if the target supports 80 bit extended precision long doubles.
138 // Notably, on x86 Windows, MSVC only provides a 64-bit long double, but GCC
139 // still makes it 80 bits. Clang will match whatever compiler it is trying to
140 // be compatible with.
141 #if ((defined(__i386__) || defined(__x86_64__)) && !defined(_MSC_VER)) || \
142 defined(__m68k__) || defined(__ia64__)
143 #define HAS_80_BIT_LONG_DOUBLE 1
145 #define HAS_80_BIT_LONG_DOUBLE 0
154 #if __STDC_VERSION__ >= 199901L
155 typedef float _Complex Fcomplex;
156 typedef double _Complex Dcomplex;
157 typedef long double _Complex Lcomplex;
159 #define COMPLEX_REAL(x) __real__(x)
160 #define COMPLEX_IMAGINARY(x) __imag__(x)
163 float real, imaginary;
167 double real, imaginary;
171 long double real, imaginary;
174 #define COMPLEX_REAL(x) (x).real
175 #define COMPLEX_IMAGINARY(x) (x).imaginary
178 #endif // INT_TYPES_H