File: testit.c

package info (click to toggle)
glibc 2.24-11+deb9u4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 225,852 kB
  • sloc: ansic: 996,505; asm: 261,827; sh: 10,484; makefile: 9,856; cpp: 4,169; python: 3,971; perl: 2,254; awk: 1,753; pascal: 1,521; yacc: 291; sed: 80
file content (788 lines) | stat: -rw-r--r-- 17,508 bytes parent folder | download | duplicates (26)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "soft-fp.h"
#include "single.h"
#include "double.h"

#include <fpu_control.h>

/*======================================================================*/
/* declarations for the functions we are testing */

double __adddf3(double, double);
double __subdf3(double, double);
double __muldf3(double, double);
double __divdf3(double, double);
double __negdf2(double);
double __sqrtdf2(double);
double __negdf3(double a, double dummy) { return __negdf2(a); }
double __sqrtdf3(double a, double dummy) { return __sqrtdf2(a); }

float __addsf3(float, float);
float __subsf3(float, float);
float __mulsf3(float, float);
float __divsf3(float, float);
float __negsf2(float);
float __sqrtsf2(float);
float __negsf3(float a, float dummy) { return __negsf2(a); }
float __sqrtsf3(float a, float dummy) { return __sqrtsf2(a); }

int __fixdfsi(double);
int __fixsfsi(float);
double __floatsidf(int);
float __floatsisf(int);
double __extendsfdf2(float);
float __truncdfsf2(double);

int __eqdf2(double, double);
int __nedf2(double, double);
int __gtdf2(double, double);
int __gedf2(double, double);
int __ltdf2(double, double);
int __ledf2(double, double);

int __eqsf2(float, float);
int __nesf2(float, float);
int __gtsf2(float, float);
int __gesf2(float, float);
int __ltsf2(float, float);
int __lesf2(float, float);

/*======================================================================*/
/* definitions for functions we are checking against */

double r_adddf3(double a, double b) { return a + b; }
double r_subdf3(double a, double b) { return a - b; }
double r_muldf3(double a, double b) { return a * b; }
double r_divdf3(double a, double b) { return a / b; }
double r_negdf3(double a, double b) { return -a; }
double sqrt(double x);
double r_sqrtdf3(double a, double b) { return sqrt(a); }

float r_addsf3(float a, float b) { return a + b; }
float r_subsf3(float a, float b) { return a - b; }
float r_mulsf3(float a, float b) { return a * b; }
float r_divsf3(float a, float b) { return a / b; }
float r_negsf3(float a, float b) { return -a; }
float sqrtf(float x);
float r_sqrtsf3(float a, float b) { return sqrtf(a); }

int r_fixdfsi(double a) { return (int)a; }
int r_fixsfsi(float a) { return (int)a; }
double r_floatsidf(int a) { return (double)a; }
float r_floatsisf(int a) { return (float)a; }
double r_extendsfdf2(float a) { return (double)a; }
float r_truncdfsf2(double a) { return (float)a; }

int r_eqdf2(double a, double b) { return !(a == b); }
int r_nedf2(double a, double b) { return a != b; }
int r_gtdf2(double a, double b) { return a > b; }
int r_gedf2(double a, double b) { return (a >= b) - 1; }
int r_ltdf2(double a, double b) { return -(a < b); }
int r_ledf2(double a, double b) { return 1 - (a <= b); }

int r_eqsf2(float a, float b) { return !(a == b); }
int r_nesf2(float a, float b) { return a != b; }
int r_gtsf2(float a, float b) { return a > b; }
int r_gesf2(float a, float b) { return (a >= b) - 1; }
int r_ltsf2(float a, float b) { return -(a < b); }
int r_lesf2(float a, float b) { return 1 - (a <= b); }

/*======================================================================*/

void print_float(float x)
{
    union _FP_UNION_S ux;
    ux.flt = x;
    printf("%-20.8e %X %02X %06lX",
	   x, ux.bits.sign, ux.bits.exp, (unsigned long)ux.bits.frac);
}

void print_double(double x)
{
    union _FP_UNION_D ux;
    ux.flt = x;
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
    printf("%-30.18e %X %04X %06lX%08lX",
	   x, ux.bits.sign, ux.bits.exp,
	   (unsigned long)ux.bits.frac1, (unsigned long)ux.bits.frac0);
#else
    printf("%-30.18e %X %04X %014lX",
	   x, ux.bits.sign, ux.bits.exp,
	   (unsigned long)ux.bits.frac);
#endif
}

float rand_float(void)
{
    union {
	union _FP_UNION_S u;
	int i;
    } u;

    u.i = lrand48() << 1;

    if (u.u.bits.exp == _FP_EXPMAX_S)
	u.u.bits.exp--;
    else if (u.u.bits.exp == 0 && u.u.bits.frac != 0)
	u.u.bits.exp++;

    return u.u.flt;
}


double rand_double(void)
{
    union {
	union _FP_UNION_D u;
	int i[2];
    } u;

    u.i[0] = lrand48() << 1;
    u.i[1] = lrand48() << 1;

    if (u.u.bits.exp == _FP_EXPMAX_D)
	u.u.bits.exp--;
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
    else if (u.u.bits.exp == 0 && !(u.u.bits.frac0 == 0 && u.u.bits.frac1 == 0))
	u.u.bits.exp++;
#else
    else if (u.u.bits.exp == 0 && u.u.bits.frac != 0)
	u.u.bits.exp++;
#endif

    return u.u.flt;
}

#define NSPECIALS  10

float gen_special_float(int i)
{
    FP_DECL_EX;
    FP_DECL_S(X);
    float x;

    switch (i & ~1)
    {
      case 0:
	X_c = FP_CLS_NAN; X_f = 0x1234;
	break;
      case 2:
	X_c = FP_CLS_NAN; X_f = 0x1;
	break;
      case 4:
	X_c = FP_CLS_INF;
	break;
      case 6:
	X_c = FP_CLS_ZERO;
	break;
      case 8:
	X_c = FP_CLS_NORMAL; X_e = 0;
	X_f = 0x4321;
	break;
    }
    X_s = (i & 1);

    FP_PACK_S(x, X);
    return x;
}

double gen_special_double(int i)
{
    FP_DECL_EX;
    FP_DECL_D(X);
    double x;

    switch (i & ~1)
    {
      case 0:
	X_c = FP_CLS_NAN;
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
	__FP_FRAC_SET_2(X, _FP_QNANNEGATEDP ? 0 : _FP_QNANBIT_D, 0x1234);
#else
	_FP_FRAC_SET_1(X, (_FP_QNANNEGATEDP ? 0 : _FP_QNANBIT_D) | 0x1234);
#endif
	break;
      case 2:
	X_c = FP_CLS_NAN;
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
	__FP_FRAC_SET_2(X, _FP_QNANNEGATEDP ? 0 : _FP_QNANBIT_D, 0x1);
#else
	_FP_FRAC_SET_1(X, (_FP_QNANNEGATEDP ? 0 : _FP_QNANBIT_D) | 0x1);
#endif
	break;
      case 4:
	X_c = FP_CLS_INF;
	break;
      case 6:
	X_c = FP_CLS_ZERO;
	break;
      case 8:
	X_c = FP_CLS_NORMAL; X_e = 0;
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
	__FP_FRAC_SET_2(X, 0, 0x87654321);
#else
	_FP_FRAC_SET_1(X, 0x87654321);
#endif
	break;
    }
    X_s = (i & 1);

    FP_PACK_D(x, X);
    return x;
}

float build_float(const char *s, const char *e, const char *f)
{
    union _FP_UNION_S u;

    u.bits.sign = strtoul(s, 0, 16);
    u.bits.exp = strtoul(e, 0, 16);
    u.bits.frac = strtoul(f, 0, 16);

    return u.flt;
}

double build_double(const char *s, const char *e, const char *f)
{
    union _FP_UNION_D u;

    u.bits.sign = strtoul(s, 0, 16);
    u.bits.exp = strtoul(e, 0, 16);
#if _FP_W_TYPE_SIZE < _FP_FRACBITS_D
    {
	size_t len = strlen(f)+1;
	char *dup = memcpy(alloca(len), f, len);
	char *low = dup + len - _FP_W_TYPE_SIZE/4 - 1;

	u.bits.frac0 = strtoul(low, 0, 16);
	*low = 0;
	u.bits.frac1 = strtoul(dup, 0, 16);
    }
#else
    u.bits.frac = strtoul(f, 0, 16);
#endif

    return u.flt;
}

/*======================================================================*/

fpu_control_t fcw0, fcw1;

void test_float_arith(float (*tf)(float, float),
		      float (*rf)(float, float),
		      float x, float y)
{
    float tr, rr;
    rr = (*rf)(x, y);
    tr = (*tf)(x, y);
    if (memcmp(&tr, &rr, sizeof(float)) != 0)
    {
	fputs("error:\n\tx     = ", stdout); print_float(x);
	fputs("\n\ty     = ", stdout); print_float(y);
	fputs("\n\ttrue  = ", stdout); print_float(rr);
	fputs("\n\tfalse = ", stdout); print_float(tr);
	putchar('\n');
    }
}

void test_double_arith(double (*tf)(double, double),
		       double (*rf)(double, double),
		       double x, double y)
{
    double tr, rr;
#ifdef __i386__
    /* Don't worry.  Even this does not make it error free
       on ia32.  If the result is denormal,  it will not
       honour the double precision and generate bad results
       anyway.  On the other side,  who wants to use ia32
       for IEEE math?  I don't.  */
    _FPU_GETCW(fcw0);
    fcw1 = ((fcw0 & ~_FPU_EXTENDED) | _FPU_DOUBLE);
    _FPU_SETCW(fcw1);
#endif
    rr = (*rf)(x, y);
#ifdef __i386__
    _FPU_SETCW(fcw0);
#endif
    tr = (*tf)(x, y);
    if (memcmp(&tr, &rr, sizeof(double)) != 0)
    {
	fputs("error:\n\tx     = ", stdout); print_double(x);
	fputs("\n\ty     = ", stdout); print_double(y);
	fputs("\n\ttrue  = ", stdout); print_double(rr);
	fputs("\n\tfalse = ", stdout); print_double(tr);
	putchar('\n');
    }
}

void test_float_double_conv(float x)
{
    double tr, rr;
    rr = r_extendsfdf2(x);
    tr = __extendsfdf2(x);
    if (memcmp(&tr, &rr, sizeof(double)) != 0)
    {
	fputs("error:\n\tx     = ", stdout); print_float(x);
	fputs("\n\ttrue  = ", stdout); print_double(rr);
	fputs("\n\tfalse = ", stdout); print_double(tr);
	putchar('\n');
    }
}

void test_double_float_conv(double x)
{
    float tr, rr;
    rr = r_truncdfsf2(x);
    tr = __truncdfsf2(x);
    if (memcmp(&tr, &rr, sizeof(float)) != 0)
    {
	fputs("error:\n\tx     = ", stdout); print_double(x);
	fputs("\n\ttrue  = ", stdout); print_float(rr);
	fputs("\n\tfalse = ", stdout); print_float(tr);
	putchar('\n');
    }
}

void test_int_float_conv(int x)
{
    float tr, rr;
    rr = r_floatsisf(x);
    tr = __floatsisf(x);
    if (memcmp(&tr, &rr, sizeof(float)) != 0)
    {
	printf("error\n\tx     = %d", x);
	fputs("\n\ttrue  = ", stdout); print_float(rr);
	fputs("\n\tfalse = ", stdout); print_float(tr);
	putchar('\n');
    }
}

void test_int_double_conv(int x)
{
    double tr, rr;
    rr = r_floatsidf(x);
    tr = __floatsidf(x);
    if (memcmp(&tr, &rr, sizeof(double)) != 0)
    {
	printf("error\n\tx     = %d", x);
	fputs("\n\ttrue  = ", stdout); print_double(rr);
	fputs("\n\tfalse = ", stdout); print_double(tr);
	putchar('\n');
    }
}

void test_float_int_conv(float x)
{
    int tr, rr;
    rr = r_fixsfsi(x);
    tr = __fixsfsi(x);
    if (rr != tr)
    {
	fputs("error:\n\tx     = ", stdout); print_float(x);
	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
    }
}

void test_double_int_conv(double x)
{
    int tr, rr;
    rr = r_fixsfsi(x);
    tr = __fixsfsi(x);
    if (rr != tr)
    {
	fputs("error:\n\tx     = ", stdout); print_double(x);
	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
    }
}

int eq0(int x) { return x == 0; }
int ne0(int x) { return x != 0; }
int le0(int x) { return x <= 0; }
int lt0(int x) { return x < 0; }
int ge0(int x) { return x >= 0; }
int gt0(int x) { return x > 0; }

void test_float_cmp(int (*tf)(float, float),
		    int (*rf)(float, float),
		    int (*cmp0)(int),
		    float x, float y)
{
    int tr, rr;
    rr = (*rf)(x, y);
    tr = (*tf)(x, y);
    if (cmp0(rr) != cmp0(tr))
    {
	fputs("error:\n\tx     = ", stdout); print_float(x);
	fputs("\n\ty     = ", stdout); print_float(y);
	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
    }
}

void test_double_cmp(int (*tf)(double, double),
		     int (*rf)(double, double),
		     int (*cmp0)(int),
		     double x, double y)
{
    int tr, rr;
    rr = (*rf)(x, y);
    tr = (*tf)(x, y);
    if (cmp0(rr) != cmp0(tr))
    {
	fputs("error:\n\tx     = ", stdout); print_double(x);
	fputs("\n\ty     = ", stdout); print_double(y);
	printf("\n\ttrue  = %d\n\tfalse = %d\n", rr, tr);
    }
}


/*======================================================================*/


int main(int ac, char **av)
{
#ifdef __alpha__
    __ieee_set_fp_control(0);
#endif
    av++, ac--;
    switch (*(*av)++)
    {
	{
	    float (*r)(float, float);
	    float (*t)(float, float);

	    do {
	      case 'a': r = r_addsf3; t = __addsf3; break;
	      case 's': r = r_subsf3; t = __subsf3; break;
	      case 'm': r = r_mulsf3; t = __mulsf3; break;
	      case 'd': r = r_divsf3; t = __divsf3; break;
	      case 'r': r = r_sqrtsf3; t = __sqrtsf3; break;
	      case 'j': r = r_negsf3; t = __negsf3; break;
	    } while (0);

	    switch (*(*av)++)
	    {
	      case 'n':
		{
		    int count = (ac > 1 ? atoi(av[1]) : 100);
		    while (count--)
			test_float_arith(t, r, rand_float(), rand_float());
		}
		break;

	      case 's':
		{
		    int i, j;
		    for (i = 0; i < NSPECIALS; i++)
			for (j = 0; j < NSPECIALS; j++)
			    test_float_arith(t, r, gen_special_float(i),
					      gen_special_float(j));
		}
		break;

	      case 0:
		if (ac < 7) abort();
		test_float_arith(t, r, build_float(av[1], av[2], av[3]),
				 build_float(av[4], av[5], av[6]));
		break;
	    }
	}
	break;

	{
	    double (*r)(double, double);
	    double (*t)(double, double);

	    do {
	      case 'A': r = r_adddf3; t = __adddf3; break;
	      case 'S': r = r_subdf3; t = __subdf3; break;
	      case 'M': r = r_muldf3; t = __muldf3; break;
	      case 'D': r = r_divdf3; t = __divdf3; break;
	      case 'R': r = r_sqrtdf3; t = __sqrtdf3; break;
	      case 'J': r = r_negdf3; t = __negdf3; break;
	    } while (0);

	    switch (*(*av)++)
	    {
	      case 'n':
		{
		    int count = (ac > 1 ? atoi(av[1]) : 100);
		    while (count--)
			test_double_arith(t, r, rand_double(), rand_double());
		}
		break;

	      case 's':
		{
		    int i, j;
		    for (i = 0; i < NSPECIALS; i++)
			for (j = 0; j < NSPECIALS; j++)
			    test_double_arith(t, r, gen_special_double(i),
					      gen_special_double(j));
		}
		break;

	      case 0:
		if (ac < 7) abort();
		test_double_arith(t, r, build_double(av[1], av[2], av[3]),
				  build_double(av[4], av[5], av[6]));
		break;
	    }
	}
	break;

      case 'c':
	switch (*(*av)++)
	{
	  case 'n':
	    {
		int count = (ac > 1 ? atoi(av[1]) : 100);
		while (count--)
		    test_float_double_conv(rand_float());
	    }
	    break;

	  case 's':
	    {
		int i;
		for (i = 0; i < NSPECIALS; i++)
		    test_float_double_conv(gen_special_float(i));
	    }
	    break;

	  case 0:
	    if (ac < 4) abort();
	    test_float_double_conv(build_float(av[1], av[2], av[3]));
	    break;
	}
	break;

      case 'C':
	switch (*(*av)++)
	{
	  case 'n':
	    {
		int count = (ac > 1 ? atoi(av[1]) : 100);
		while (count--)
		    test_double_float_conv(rand_double());
	    }
	    break;

	  case 's':
	    {
		int i;
		for (i = 0; i < NSPECIALS; i++)
		    test_double_float_conv(gen_special_double(i));
	    }
	    break;

	  case 0:
	    if (ac < 4) abort();
	    test_double_float_conv(build_double(av[1], av[2], av[3]));
	    break;
	}
	break;

      case 'i':
	switch (*(*av)++)
	{
	  case 'n':
	    {
		int count = (ac > 1 ? atoi(av[1]) : 100);
		while (count--)
		    test_int_float_conv(lrand48() << 1);
	    }
	    break;

	  case 0:
	    if (ac < 2) abort();
	    test_int_float_conv(strtol(av[1], 0, 0));
	    break;
	}
	break;

      case 'I':
	switch (*(*av)++)
	{
	  case 'n':
	    {
		int count = (ac > 1 ? atoi(av[1]) : 100);
		while (count--)
		    test_int_double_conv(lrand48() << 1);
	    }
	    break;

	  case 0:
	    if (ac < 2) abort();
	    test_int_double_conv(strtol(av[1], 0, 0));
	    break;
	}
	break;

      case 'f':
	switch (*(*av)++)
	{
	  case 'n':
	    {
		int count = (ac > 1 ? atoi(av[1]) : 100);
		while (count--)
		    test_float_int_conv(rand_float());
	    }
	    break;

	  case 's':
	    {
		int i;
		for (i = 0; i < NSPECIALS; i++)
		    test_float_int_conv(gen_special_float(i));
	    }
	    break;

	  case 0:
	    if (ac < 4) abort();
	    test_float_int_conv(build_float(av[1], av[2], av[3]));
	    break;
	}
	break;

      case 'F':
	switch (*(*av)++)
	{
	  case 'n':
	    {
		int count = (ac > 1 ? atoi(av[1]) : 100);
		while (count--)
		    test_double_int_conv(rand_double());
	    }
	    break;

	  case 's':
	    {
		int i;
		for (i = 0; i < NSPECIALS; i++)
		    test_double_int_conv(gen_special_double(i));
	    }
	    break;

	  case 0:
	    if (ac < 4) abort();
	    test_double_int_conv(build_double(av[1], av[2], av[3]));
	    break;
	}
	break;

	{
	    int (*r)(float, float);
	    int (*t)(float, float);
	    int (*c)(int);

	    do {
	      case 'e': r = r_eqsf2; t = __eqsf2; c = eq0; break;
	      case 'n': r = r_nesf2; t = __nesf2; c = ne0; break;
	      case 'l':
		switch (*(*av)++)
		{
		  case 'e': r = r_lesf2; t = __lesf2; c = le0; break;
		  case 't': r = r_ltsf2; t = __ltsf2; c = lt0; break;
		}
		break;
	      case 'g':
		switch (*(*av)++)
		{
		  case 'e': r = r_gesf2; t = __gesf2; c = ge0; break;
		  case 't': r = r_gtsf2; t = __gtsf2; c = gt0; break;
		}
		break;
	    } while (0);

	    switch (*(*av)++)
	    {
	      case 'n':
		{
		    int count = (ac > 1 ? atoi(av[1]) : 100);
		    while (count--)
			test_float_cmp(t, r, c, rand_float(), rand_float());
		}
		break;

	      case 's':
		{
		    int i, j;
		    for (i = 0; i < NSPECIALS; i++)
			for (j = 0; j < NSPECIALS; j++)
			    test_float_cmp(t, r, c, gen_special_float(i),
					   gen_special_float(j));
		}
		break;

	      case 0:
		if (ac < 7) abort();
		test_float_cmp(t, r, c, build_float(av[1], av[2], av[3]),
				build_float(av[4], av[5], av[6]));
		break;
	    }
	}
	break;

	{
	    int (*r)(double, double);
	    int (*t)(double, double);
	    int (*c)(int);

	    do {
	      case 'E': r = r_eqdf2; t = __eqdf2; c = eq0; break;
	      case 'N': r = r_nedf2; t = __nedf2; c = ne0; break;
	      case 'L':
		switch (*(*av)++)
		{
		  case 'E': r = r_ledf2; t = __ledf2; c = le0; break;
		  case 'T': r = r_ltdf2; t = __ltdf2; c = lt0; break;
		}
		break;
	      case 'G':
		switch (*(*av)++)
		{
		  case 'E': r = r_gedf2; t = __gedf2; c = ge0; break;
		  case 'T': r = r_gtdf2; t = __gtdf2; c = gt0; break;
		}
		break;
	    } while (0);

	    switch (*(*av)++)
	    {
	      case 'n':
		{
		    int count = (ac > 1 ? atoi(av[1]) : 100);
		    while (count--)
			test_double_cmp(t, r, c, rand_double(), rand_double());
		}
		break;

	      case 's':
		{
		    int i, j;
		    for (i = 0; i < NSPECIALS; i++)
			for (j = 0; j < NSPECIALS; j++)
			    test_double_cmp(t, r, c, gen_special_double(i),
					    gen_special_double(j));
		}
		break;

	      case 0:
		if (ac < 7) abort();
		test_double_cmp(t, r, c, build_double(av[1], av[2], av[3]),
				build_double(av[4], av[5], av[6]));
		break;
	    }
	}
	break;

      default:
	abort();
    }

    return 0;
}