]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/libm/musl-generator/src/macros.rs
New upstream version 1.32.0+dfsg1
[rustc.git] / src / libcompiler_builtins / libm / musl-generator / src / macros.rs
CommitLineData
a1dfa0c6
XL
1macro_rules! f32 {
2 ($($fun:ident,)+) => {{
3 $(
4 // check type signature
5 let _: fn(f32) -> f32 = libm::$fun;
6 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
7 )+
8
9 for x in shared::F32.iter() {
10 $(
11 let y = unsafe {
12 extern "C" {
13 fn $fun(_: f32) -> f32;
14 }
15
16 $fun(*x)
17 };
18
19 $fun.write_all(&y.to_bits().to_bytes())?;
20 )+
21 }
22 }};
23}
24
25macro_rules! f32f32 {
26 ($($fun:ident,)+) => {{
27 $(
28 // check type signature
29 let _: fn(f32, f32) -> f32 = libm::$fun;
30 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
31 )+
32
33 for (x0, x1) in shared::F32F32.iter() {
34 $(
35 let y = unsafe {
36 extern "C" {
37 fn $fun(_: f32, _: f32) -> f32;
38 }
39
40 $fun(*x0, *x1)
41 };
42
43 $fun.write_all(&y.to_bits().to_bytes())?;
44 )+
45 }
46 }};
47}
48
49macro_rules! f32f32f32 {
50 ($($fun:ident,)+) => {{
51 $(
52 // check type signature
53 let _: fn(f32, f32, f32) -> f32 = libm::$fun;
54 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
55 )+
56
57 for (x0, x1, x2) in shared::F32F32F32.iter() {
58 $(
59 let y = unsafe {
60 extern "C" {
61 fn $fun(_: f32, _: f32, _: f32) -> f32;
62 }
63
64 $fun(*x0, *x1, *x2)
65 };
66
67 $fun.write_all(&y.to_bits().to_bytes())?;
68 )+
69 }
70 }};
71}
72
73macro_rules! f32i32 {
74 ($($fun:ident,)+) => {{
75 $(
76 // check type signature
77 let _: fn(f32, i32) -> f32 = libm::$fun;
78 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
79 )+
80
81 for (x0, x1) in shared::F32I32.iter() {
82 $(
83 let y = unsafe {
84 extern "C" {
85 fn $fun(_: f32, _: i32) -> f32;
86 }
87
88 $fun(*x0, *x1 as i32)
89 };
90
91 $fun.write_all(&y.to_bits().to_bytes())?;
92 )+
93 }
94 }};
95}
96
97macro_rules! f64 {
98 ($($fun:ident,)+) => {{
99 $(
100 // check type signature
101 let _: fn(f64) -> f64 = libm::$fun;
102 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
103 )+
104
105 for x in shared::F64.iter() {
106 $(
107 let y = unsafe {
108 extern "C" {
109 fn $fun(_: f64) -> f64;
110 }
111
112 $fun(*x)
113 };
114
115 $fun.write_all(&y.to_bits().to_bytes())?;
116 )+
117 }
118 }};
119}
120
121macro_rules! f64f64 {
122 ($($fun:ident,)+) => {{
123 $(
124 // check type signature
125 let _: fn(f64, f64) -> f64 = libm::$fun;
126 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
127 )+
128
129 for (x0, x1) in shared::F64F64.iter() {
130 $(
131 let y = unsafe {
132 extern "C" {
133 fn $fun(_: f64, _: f64) -> f64;
134 }
135
136 $fun(*x0, *x1)
137 };
138
139 $fun.write_all(&y.to_bits().to_bytes())?;
140 )+
141 }
142 }};
143}
144
145macro_rules! f64f64f64 {
146 ($($fun:ident,)+) => {{
147 $(
148 // check type signature
149 let _: fn(f64, f64, f64) -> f64 = libm::$fun;
150 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
151 )+
152
153 for (x0, x1, x2) in shared::F64F64F64.iter() {
154 $(
155 let y = unsafe {
156 extern "C" {
157 fn $fun(_: f64, _: f64, _: f64) -> f64;
158 }
159
160 $fun(*x0, *x1, *x2)
161 };
162
163 $fun.write_all(&y.to_bits().to_bytes())?;
164 )+
165 }
166 }};
167}
168
169macro_rules! f64i32 {
170 ($($fun:ident,)+) => {{
171 $(
172 // check type signature
173 let _: fn(f64, i32) -> f64 = libm::$fun;
174 let mut $fun = File::create(concat!("bin/output/musl.", stringify!($fun)))?;
175 )+
176
177 for (x0, x1) in shared::F64I32.iter() {
178 $(
179 let y = unsafe {
180 extern "C" {
181 fn $fun(_: f64, _: i32) -> f64;
182 }
183
184 $fun(*x0, *x1 as i32)
185 };
186
187 $fun.write_all(&y.to_bits().to_bytes())?;
188 )+
189 }
190 }};
191}