1 /* ===-- int_lib.h - configuration header for compiler-rt -----------------=== 2 * 3 * The LLVM Compiler Infrastructure 4 * 5 * This file is dual licensed under the MIT and the University of Illinois Open 6 * Source Licenses. See LICENSE.TXT for details. 7 * 8 * ===----------------------------------------------------------------------=== 9 * 10 * This file is not part of the interface of this library. 11 * 12 * This file defines various standard types, most importantly a number of unions 13 * used to access parts of larger types. 14 * 15 * ===----------------------------------------------------------------------=== 16 */ 17 18 #ifndef INT_TYPES_H 19 #define INT_TYPES_H 20 21 #include "int_endianness.h" 22 23 /* si_int is defined in Linux sysroot's asm-generic/siginfo.h */ 24 #ifdef si_int 25 #undef si_int 26 #endif 27 typedef int si_int; 28 typedef unsigned su_int; 29 30 typedef long long di_int; 31 typedef unsigned long long du_int; 32 33 typedef union 34 { 35 di_int all; 36 struct 37 { 38 #if _YUGA_LITTLE_ENDIAN 39 su_int low; 40 si_int high; 41 #else 42 si_int high; 43 su_int low; 44 #endif /* _YUGA_LITTLE_ENDIAN */ 45 }s; 46 } dwords; 47 48 typedef union 49 { 50 du_int all; 51 struct 52 { 53 #if _YUGA_LITTLE_ENDIAN 54 su_int low; 55 su_int high; 56 #else 57 su_int high; 58 su_int low; 59 #endif /* _YUGA_LITTLE_ENDIAN */ 60 }s; 61 } udwords; 62 63 /* MIPS64 issue: PR 20098 */ 64 #if (defined(__LP64__) || defined(__wasm__)) && \ 65 !(defined(__mips__) && defined(__clang__)) && \ 66 !defined(__PCC__) 67 #define CRT_HAS_128BIT 68 #endif 69 70 #ifdef CRT_HAS_128BIT 71 typedef int ti_int __attribute__ ((mode (TI))); 72 typedef unsigned tu_int __attribute__ ((mode (TI))); 73 74 typedef union 75 { 76 ti_int all; 77 struct 78 { 79 #if _YUGA_LITTLE_ENDIAN 80 du_int low; 81 di_int high; 82 #else 83 di_int high; 84 du_int low; 85 #endif /* _YUGA_LITTLE_ENDIAN */ 86 }s; 87 } twords; 88 89 typedef union 90 { 91 tu_int all; 92 struct 93 { 94 #if _YUGA_LITTLE_ENDIAN 95 du_int low; 96 du_int high; 97 #else 98 du_int high; 99 du_int low; 100 #endif /* _YUGA_LITTLE_ENDIAN */ 101 }s; 102 } utwords; 103 make_ti(di_int h,di_int l)104static __inline ti_int make_ti(di_int h, di_int l) { 105 twords r; 106 r.s.high = h; 107 r.s.low = l; 108 return r.all; 109 } 110 make_tu(du_int h,du_int l)111static __inline tu_int make_tu(du_int h, du_int l) { 112 utwords r; 113 r.s.high = h; 114 r.s.low = l; 115 return r.all; 116 } 117 118 #endif /* CRT_HAS_128BIT */ 119 120 typedef union 121 { 122 su_int u; 123 float f; 124 } float_bits; 125 126 typedef union 127 { 128 udwords u; 129 double f; 130 } double_bits; 131 132 typedef struct 133 { 134 #if _YUGA_LITTLE_ENDIAN 135 udwords low; 136 udwords high; 137 #else 138 udwords high; 139 udwords low; 140 #endif /* _YUGA_LITTLE_ENDIAN */ 141 } uqwords; 142 143 typedef union 144 { 145 uqwords u; 146 long double f; 147 } long_double_bits; 148 149 #if __STDC_VERSION__ >= 199901L 150 typedef float _Complex Fcomplex; 151 typedef double _Complex Dcomplex; 152 typedef long double _Complex Lcomplex; 153 154 #define COMPLEX_REAL(x) __real__(x) 155 #define COMPLEX_IMAGINARY(x) __imag__(x) 156 #else 157 typedef struct { float real, imaginary; } Fcomplex; 158 159 typedef struct { double real, imaginary; } Dcomplex; 160 161 typedef struct { long double real, imaginary; } Lcomplex; 162 163 #define COMPLEX_REAL(x) (x).real 164 #define COMPLEX_IMAGINARY(x) (x).imaginary 165 #endif 166 #endif /* INT_TYPES_H */ 167 168