@@ -58,6 +58,8 @@ macro_rules! f32_f32 {
58
58
59
59
let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
60
60
write!( f, "
61
+ #![deny(warnings)]
62
+
61
63
extern crate libm;
62
64
63
65
#[test]
@@ -118,6 +120,8 @@ macro_rules! f32f32_f32 {
118
120
119
121
let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
120
122
write!( f, "
123
+ #![deny(warnings)]
124
+
121
125
extern crate libm;
122
126
123
127
#[test]
@@ -153,6 +157,74 @@ macro_rules! f32f32_f32 {
153
157
} ;
154
158
}
155
159
160
+ // fn(f32, f32, f32) -> f32
161
+ macro_rules! f32f32f32_f32 {
162
+ ( $( $intr: ident, ) * ) => {
163
+ fn f32f32f32_f32( rng: & mut XorShiftRng ) -> Result <( ) , Box <Error >> {
164
+ extern "C" {
165
+ $( fn $intr( _: f32 , _: f32 , _: f32 ) -> f32 ; ) *
166
+ }
167
+
168
+ $(
169
+ let mut cases = String :: new( ) ;
170
+ for _ in 0 ..NTESTS {
171
+ let i1 = f32 ( rng) ;
172
+ let i2 = f32 ( rng) ;
173
+ let i3 = f32 ( rng) ;
174
+ let out = unsafe { $intr( i1, i2, i3) } ;
175
+
176
+ let i1 = i1. to_bits( ) ;
177
+ let i2 = i2. to_bits( ) ;
178
+ let i3 = i3. to_bits( ) ;
179
+ let out = out. to_bits( ) ;
180
+
181
+ write!( cases, "(({}, {}, {}), {})" , i1, i2, i3, out) . unwrap( ) ;
182
+ cases. push( ',' ) ;
183
+ }
184
+
185
+ let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
186
+ write!( f, "
187
+ #![deny(warnings)]
188
+
189
+ extern crate libm;
190
+
191
+ #[test]
192
+ fn {0}() {{
193
+ const CASES: &[((u32, u32, u32), u32)] = &[
194
+ {1}
195
+ ];
196
+
197
+ for case in CASES {{
198
+ let ((i1, i2, i3), expected) = *case;
199
+
200
+ let outf = libm::{0}(
201
+ f32::from_bits(i1),
202
+ f32::from_bits(i2),
203
+ f32::from_bits(i3),
204
+ );
205
+ let outi = outf.to_bits();
206
+
207
+ if !((outf.is_nan() && f32::from_bits(expected).is_nan()) ||
208
+ libm::_eqf(outi, expected)) {{
209
+ panic!(
210
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
211
+ (i1, i2, i3),
212
+ outi,
213
+ expected,
214
+ );
215
+ }}
216
+ }}
217
+ }}
218
+ " ,
219
+ stringify!( $intr) ,
220
+ cases) ?;
221
+ ) *
222
+
223
+ Ok ( ( ) )
224
+ }
225
+ } ;
226
+ }
227
+
156
228
// fn(f32, i32) -> f32
157
229
macro_rules! f32i32_f32 {
158
230
( $( $intr: ident, ) * ) => {
@@ -177,6 +249,8 @@ macro_rules! f32i32_f32 {
177
249
178
250
let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
179
251
write!( f, "
252
+ #![deny(warnings)]
253
+
180
254
extern crate libm;
181
255
182
256
#[test]
@@ -236,6 +310,8 @@ macro_rules! f64_f64 {
236
310
237
311
let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
238
312
write!( f, "
313
+ #![deny(warnings)]
314
+
239
315
extern crate libm;
240
316
241
317
#[test]
@@ -296,6 +372,8 @@ macro_rules! f64f64_f64 {
296
372
297
373
let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
298
374
write!( f, "
375
+ #![deny(warnings)]
376
+
299
377
extern crate libm;
300
378
301
379
#[test]
@@ -331,6 +409,74 @@ macro_rules! f64f64_f64 {
331
409
} ;
332
410
}
333
411
412
+ // fn(f64, f64, f64) -> f64
413
+ macro_rules! f64f64f64_f64 {
414
+ ( $( $intr: ident, ) * ) => {
415
+ fn f64f64f64_f64( rng: & mut XorShiftRng ) -> Result <( ) , Box <Error >> {
416
+ extern "C" {
417
+ $( fn $intr( _: f64 , _: f64 , _: f64 ) -> f64 ; ) *
418
+ }
419
+
420
+ $(
421
+ let mut cases = String :: new( ) ;
422
+ for _ in 0 ..NTESTS {
423
+ let i1 = f64 ( rng) ;
424
+ let i2 = f64 ( rng) ;
425
+ let i3 = f64 ( rng) ;
426
+ let out = unsafe { $intr( i1, i2, i3) } ;
427
+
428
+ let i1 = i1. to_bits( ) ;
429
+ let i2 = i2. to_bits( ) ;
430
+ let i3 = i3. to_bits( ) ;
431
+ let out = out. to_bits( ) ;
432
+
433
+ write!( cases, "(({}, {}, {}), {})" , i1, i2, i3, out) . unwrap( ) ;
434
+ cases. push( ',' ) ;
435
+ }
436
+
437
+ let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
438
+ write!( f, "
439
+ #![deny(warnings)]
440
+
441
+ extern crate libm;
442
+
443
+ #[test]
444
+ fn {0}() {{
445
+ const CASES: &[((u64, u64, u64), u64)] = &[
446
+ {1}
447
+ ];
448
+
449
+ for case in CASES {{
450
+ let ((i1, i2, i3), expected) = *case;
451
+
452
+ let outf = libm::{0}(
453
+ f64::from_bits(i1),
454
+ f64::from_bits(i2),
455
+ f64::from_bits(i3),
456
+ );
457
+ let outi = outf.to_bits();
458
+
459
+ if !((outf.is_nan() && f64::from_bits(expected).is_nan()) ||
460
+ libm::_eq(outi, expected)) {{
461
+ panic!(
462
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
463
+ (i1, i2, i3),
464
+ outi,
465
+ expected,
466
+ );
467
+ }}
468
+ }}
469
+ }}
470
+ " ,
471
+ stringify!( $intr) ,
472
+ cases) ?;
473
+ ) *
474
+
475
+ Ok ( ( ) )
476
+ }
477
+ } ;
478
+ }
479
+
334
480
// fn(f64, i32) -> f64
335
481
macro_rules! f64i32_f64 {
336
482
( $( $intr: ident, ) * ) => {
@@ -355,6 +501,8 @@ macro_rules! f64i32_f64 {
355
501
356
502
let mut f = File :: create( concat!( "tests/" , stringify!( $intr) , ".rs" ) ) ?;
357
503
write!( f, "
504
+ #![deny(warnings)]
505
+
358
506
extern crate libm;
359
507
360
508
#[test]
@@ -398,9 +546,11 @@ fn main() -> Result<(), Box<Error>> {
398
546
399
547
f32_f32 ( & mut rng) ?;
400
548
f32f32_f32 ( & mut rng) ?;
549
+ f32f32f32_f32 ( & mut rng) ?;
401
550
f32i32_f32 ( & mut rng) ?;
402
551
f64_f64 ( & mut rng) ?;
403
552
f64f64_f64 ( & mut rng) ?;
553
+ f64f64f64_f64 ( & mut rng) ?;
404
554
f64i32_f64 ( & mut rng) ?;
405
555
406
556
Ok ( ( ) )
@@ -410,6 +560,13 @@ fn main() -> Result<(), Box<Error>> {
410
560
411
561
// With signature `fn(f32) -> f32`
412
562
f32_f32 ! {
563
+ // cosf,
564
+ // exp2f,
565
+ // expf,
566
+ // log10f,
567
+ // log2f,
568
+ // roundf,
569
+ // sinf,
413
570
fabsf,
414
571
sqrtf,
415
572
}
@@ -420,19 +577,50 @@ f32f32_f32! {
420
577
powf,
421
578
}
422
579
580
+ // With signature `fn(f32, f32, f32) -> f32`
581
+ f32f32f32_f32 ! {
582
+ // fmaf,
583
+ }
584
+
423
585
// With signature `fn(f32, i32) -> f32`
424
586
f32i32_f32 ! {
425
587
scalbnf,
426
588
}
427
589
428
590
// With signature `fn(f64) -> f64`
429
591
f64_f64 ! {
592
+ // acos,
593
+ // asin,
594
+ // atan,
595
+ // cbrt,
596
+ // cos,
597
+ // cosh,
598
+ // exp,
599
+ // exp2,
600
+ // expm1,
601
+ // log,
602
+ // log10,
603
+ // log1p,
604
+ // log2,
605
+ // round,
606
+ // sin,
607
+ // sinh,
608
+ // tan,
609
+ // tanh,
430
610
fabs,
431
611
}
432
612
433
613
// With signature `fn(f64, f64) -> f64`
434
614
f64f64_f64 ! {
615
+ // atan2,
435
616
// fmod,
617
+ // hypot,
618
+ // pow,
619
+ }
620
+
621
+ // With signature `fn(f64, f64, f64) -> f64`
622
+ f64f64f64_f64 ! {
623
+ // fma,
436
624
}
437
625
438
626
// With signature `fn(f64, i32) -> f64`
0 commit comments