]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/int_types.h
Merge ^/vendor/NetBSD/tests/dist@r312294
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / int_types.h
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 #define CRT_HAS_128BIT
67 #endif
68
69 #ifdef CRT_HAS_128BIT
70 typedef int      ti_int __attribute__ ((mode (TI)));
71 typedef unsigned tu_int __attribute__ ((mode (TI)));
72
73 typedef 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
88 typedef 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
103 static __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
110 static __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
119 typedef union
120 {
121     su_int u;
122     float f;
123 } float_bits;
124
125 typedef union
126 {
127     udwords u;
128     double  f;
129 } double_bits;
130
131 typedef 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
142 typedef union
143 {
144     uqwords     u;
145     long double f;
146 } long_double_bits;
147
148 #if __STDC_VERSION__ >= 199901L
149 typedef float _Complex Fcomplex;
150 typedef double _Complex Dcomplex;
151 typedef long double _Complex Lcomplex;
152
153 #define COMPLEX_REAL(x) __real__(x)
154 #define COMPLEX_IMAGINARY(x) __imag__(x)
155 #else
156 typedef struct { float real, imaginary; } Fcomplex;
157
158 typedef struct { double real, imaginary; } Dcomplex;
159
160 typedef 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