]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/lib/builtins/int_types.h
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / 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 typedef int si_int;
24 typedef unsigned su_int;
25
26 typedef long long di_int;
27 typedef unsigned long long du_int;
28
29 typedef union
30 {
31 di_int all;
32 struct
33 {
34 #if _YUGA_LITTLE_ENDIAN
35 su_int low;
36 si_int high;
37 #else
38 si_int high;
39 su_int low;
40 #endif /* _YUGA_LITTLE_ENDIAN */
41 }s;
42 } dwords;
43
44 typedef union
45 {
46 du_int all;
47 struct
48 {
49 #if _YUGA_LITTLE_ENDIAN
50 su_int low;
51 su_int high;
52 #else
53 su_int high;
54 su_int low;
55 #endif /* _YUGA_LITTLE_ENDIAN */
56 }s;
57 } udwords;
58
59 /* MIPS64 issue: PR 20098 */
60 #if defined(__LP64__) && !(defined(__mips__) && defined(__clang__))
61 #define CRT_HAS_128BIT
62 #endif
63
64 #ifdef CRT_HAS_128BIT
65 typedef int ti_int __attribute__ ((mode (TI)));
66 typedef unsigned tu_int __attribute__ ((mode (TI)));
67
68 typedef union
69 {
70 ti_int all;
71 struct
72 {
73 #if _YUGA_LITTLE_ENDIAN
74 du_int low;
75 di_int high;
76 #else
77 di_int high;
78 du_int low;
79 #endif /* _YUGA_LITTLE_ENDIAN */
80 }s;
81 } twords;
82
83 typedef union
84 {
85 tu_int all;
86 struct
87 {
88 #if _YUGA_LITTLE_ENDIAN
89 du_int low;
90 du_int high;
91 #else
92 du_int high;
93 du_int low;
94 #endif /* _YUGA_LITTLE_ENDIAN */
95 }s;
96 } utwords;
97
98 static __inline ti_int make_ti(di_int h, di_int l) {
99 twords r;
100 r.s.high = h;
101 r.s.low = l;
102 return r.all;
103 }
104
105 static __inline tu_int make_tu(du_int h, du_int l) {
106 utwords r;
107 r.s.high = h;
108 r.s.low = l;
109 return r.all;
110 }
111
112 #endif /* CRT_HAS_128BIT */
113
114 typedef union
115 {
116 su_int u;
117 float f;
118 } float_bits;
119
120 typedef union
121 {
122 udwords u;
123 double f;
124 } double_bits;
125
126 typedef struct
127 {
128 #if _YUGA_LITTLE_ENDIAN
129 udwords low;
130 udwords high;
131 #else
132 udwords high;
133 udwords low;
134 #endif /* _YUGA_LITTLE_ENDIAN */
135 } uqwords;
136
137 typedef union
138 {
139 uqwords u;
140 long double f;
141 } long_double_bits;
142
143 #if __STDC_VERSION__ >= 199901L
144 typedef float _Complex Fcomplex;
145 typedef double _Complex Dcomplex;
146 typedef long double _Complex Lcomplex;
147
148 #define COMPLEX_REAL(x) __real__(x)
149 #define COMPLEX_IMAGINARY(x) __imag__(x)
150 #else
151 typedef struct { float real, imaginary; } Fcomplex;
152
153 typedef struct { double real, imaginary; } Dcomplex;
154
155 typedef struct { long double real, imaginary; } Lcomplex;
156
157 #define COMPLEX_REAL(x) (x).real
158 #define COMPLEX_IMAGINARY(x) (x).imaginary
159 #endif
160 #endif /* INT_TYPES_H */
161