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 !defined(__PCC__)
67#define CRT_HAS_128BIT
68#endif
69
70#ifdef CRT_HAS_128BIT
71typedef int ti_int __attribute__ ((mode (TI)));
72typedef unsigned tu_int __attribute__ ((mode (TI)));
73
74typedef 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
89typedef 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
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
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
120typedef union
121{
122 su_int u;
123 float f;
124} float_bits;
125
126typedef union
127{
128 udwords u;
129 double f;
130} double_bits;
131
132typedef 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
143typedef union
144{
145 uqwords u;
146 long double f;
147} long_double_bits;
148
149#if __STDC_VERSION__ >= 199901L
150typedef float _Complex Fcomplex;
151typedef double _Complex Dcomplex;
152typedef long double _Complex Lcomplex;
153
154#define COMPLEX_REAL(x) __real__(x)
155#define COMPLEX_IMAGINARY(x) __imag__(x)
156#else
157typedef struct { float real, imaginary; } Fcomplex;
158
159typedef struct { double real, imaginary; } Dcomplex;
160
161typedef 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