]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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 | ||
3157f602 XL |
23 | /* si_int is defined in Linux sysroot's asm-generic/siginfo.h */ |
24 | #ifdef si_int | |
25 | #undef si_int | |
26 | #endif | |
1a4d82fc JJ |
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 | ||
2c00a5a8 | 63 | #if (defined(__LP64__) || defined(__wasm__) || defined(__mips64)) |
1a4d82fc JJ |
64 | #define CRT_HAS_128BIT |
65 | #endif | |
66 | ||
67 | #ifdef CRT_HAS_128BIT | |
68 | typedef int ti_int __attribute__ ((mode (TI))); | |
69 | typedef unsigned tu_int __attribute__ ((mode (TI))); | |
70 | ||
71 | typedef union | |
72 | { | |
73 | ti_int all; | |
74 | struct | |
75 | { | |
76 | #if _YUGA_LITTLE_ENDIAN | |
77 | du_int low; | |
78 | di_int high; | |
79 | #else | |
80 | di_int high; | |
81 | du_int low; | |
82 | #endif /* _YUGA_LITTLE_ENDIAN */ | |
83 | }s; | |
84 | } twords; | |
85 | ||
86 | typedef union | |
87 | { | |
88 | tu_int all; | |
89 | struct | |
90 | { | |
91 | #if _YUGA_LITTLE_ENDIAN | |
92 | du_int low; | |
93 | du_int high; | |
94 | #else | |
95 | du_int high; | |
96 | du_int low; | |
97 | #endif /* _YUGA_LITTLE_ENDIAN */ | |
98 | }s; | |
99 | } utwords; | |
100 | ||
92a42be0 | 101 | static __inline ti_int make_ti(di_int h, di_int l) { |
1a4d82fc JJ |
102 | twords r; |
103 | r.s.high = h; | |
104 | r.s.low = l; | |
105 | return r.all; | |
106 | } | |
107 | ||
92a42be0 | 108 | static __inline tu_int make_tu(du_int h, du_int l) { |
1a4d82fc JJ |
109 | utwords r; |
110 | r.s.high = h; | |
111 | r.s.low = l; | |
112 | return r.all; | |
113 | } | |
114 | ||
115 | #endif /* CRT_HAS_128BIT */ | |
116 | ||
117 | typedef union | |
118 | { | |
119 | su_int u; | |
120 | float f; | |
121 | } float_bits; | |
122 | ||
123 | typedef union | |
124 | { | |
125 | udwords u; | |
126 | double f; | |
127 | } double_bits; | |
128 | ||
129 | typedef struct | |
130 | { | |
131 | #if _YUGA_LITTLE_ENDIAN | |
132 | udwords low; | |
133 | udwords high; | |
134 | #else | |
135 | udwords high; | |
136 | udwords low; | |
137 | #endif /* _YUGA_LITTLE_ENDIAN */ | |
138 | } uqwords; | |
139 | ||
140 | typedef union | |
141 | { | |
142 | uqwords u; | |
143 | long double f; | |
144 | } long_double_bits; | |
145 | ||
92a42be0 SL |
146 | #if __STDC_VERSION__ >= 199901L |
147 | typedef float _Complex Fcomplex; | |
148 | typedef double _Complex Dcomplex; | |
149 | typedef long double _Complex Lcomplex; | |
150 | ||
151 | #define COMPLEX_REAL(x) __real__(x) | |
152 | #define COMPLEX_IMAGINARY(x) __imag__(x) | |
153 | #else | |
154 | typedef struct { float real, imaginary; } Fcomplex; | |
155 | ||
156 | typedef struct { double real, imaginary; } Dcomplex; | |
157 | ||
158 | typedef struct { long double real, imaginary; } Lcomplex; | |
159 | ||
160 | #define COMPLEX_REAL(x) (x).real | |
161 | #define COMPLEX_IMAGINARY(x) (x).imaginary | |
162 | #endif | |
1a4d82fc JJ |
163 | #endif /* INT_TYPES_H */ |
164 |