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 27typedef int si_int; 28typedef unsigned su_int; 29 30typedef long long di_int; 31typedef unsigned long long du_int; 32 33typedef 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 48typedef 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#define CRT_HAS_128BIT 67#endif 68 69#ifdef CRT_HAS_128BIT 70typedef int ti_int __attribute__ ((mode (TI))); 71typedef unsigned tu_int __attribute__ ((mode (TI))); 72 73typedef union 74{ 75 ti_int all; 76 struct 77 { 78#if _YUGA_LITTLE_ENDIAN 79 du_int low; 80 di_int high; 81#else 82 di_int high; 83 du_int low; 84#endif /* _YUGA_LITTLE_ENDIAN */ 85 }s; 86} twords; 87 88typedef union 89{ 90 tu_int all; 91 struct 92 { 93#if _YUGA_LITTLE_ENDIAN 94 du_int low; 95 du_int high; 96#else 97 du_int high; 98 du_int low; 99#endif /* _YUGA_LITTLE_ENDIAN */ 100 }s; 101} utwords; 102 103static __inline ti_int make_ti(di_int h, di_int l) { 104 twords r; 105 r.s.high = h; 106 r.s.low = l; 107 return r.all; 108} 109 110static __inline tu_int make_tu(du_int h, du_int l) { 111 utwords r; 112 r.s.high = h; 113 r.s.low = l; 114 return r.all; 115} 116 117#endif /* CRT_HAS_128BIT */ 118 119typedef union 120{ 121 su_int u; 122 float f; 123} float_bits; 124 125typedef union 126{ 127 udwords u; 128 double f; 129} double_bits; 130 131typedef struct 132{ 133#if _YUGA_LITTLE_ENDIAN 134 udwords low; 135 udwords high; 136#else 137 udwords high; 138 udwords low; 139#endif /* _YUGA_LITTLE_ENDIAN */ 140} uqwords; 141 142typedef union 143{ 144 uqwords u; 145 long double f; 146} long_double_bits; 147 148#if __STDC_VERSION__ >= 199901L 149typedef float _Complex Fcomplex; 150typedef double _Complex Dcomplex; 151typedef long double _Complex Lcomplex; 152 153#define COMPLEX_REAL(x) __real__(x) 154#define COMPLEX_IMAGINARY(x) __imag__(x) 155#else 156typedef struct { float real, imaginary; } Fcomplex; 157 158typedef struct { double real, imaginary; } Dcomplex; 159 160typedef struct { long double real, imaginary; } Lcomplex; 161 162#define COMPLEX_REAL(x) (x).real 163#define COMPLEX_IMAGINARY(x) (x).imaginary 164#endif 165#endif /* INT_TYPES_H */ 166 167