1
/* Some random tests for vacall. */
4
* Copyright 1993 Bill Triggs, <Bill.Triggs@inrialpes.fr>
5
* Copyright 1995-1999, 2001-2002, 2005 Bruno Haible, <bruno@clisp.org>
7
* This is free software distributed under the GNU General Public Licence
8
* described in the file COPYING. Contact the author if you don't have this
9
* or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
20
#if defined(__hppa__) && defined(__GNUC__)
21
#if (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
22
/* gcc-2.5.2 bugs prevent the T test from working. */
26
#if defined(__m68k__) && defined(sun) && !defined(__GNUC__)
27
/* A SunOS 4.0.3 cc bug is triggered by the va_arg_struct macro. */
30
#if defined(__m68k__) && defined(__GNUC__)
31
/* "gcc-2.6.3 -freg-struct-return" returns T = struct { char c[3]; } (which
32
* has size 4 !) in memory, in contrast to struct { char a,b,c; } and
33
* struct { char c[4]; } and struct { char a,b,c,d; } which have the same
34
* size and the same alignment but are returned in registers. I don't know why.
38
#if defined(__i386__) && defined(__GNUC__)
39
#if (__GNUC__ == 2) && (__GNUC_MINOR__ == 7)
40
/* Problem with gcc-2.7.x on Linux/ELF: The X test fails.
41
* The calling convention for C functions returning structures of size > 8 bytes
42
* apparently has changed between gcc-2.6.3 and gcc-2.7 (all i386 platforms),
43
* and vacall supports only the old one. Since gcc-2.8 will switch back to
44
* gcc-2.6.3's calling convention, I won't change ffcall/vacall for this.
45
* Just hide the problem by not running the test. The impact isn't big for
46
* CLISP: Callbacks returning structures > 8 bytes won't work.
51
#if defined(__sparc__) && defined(sun) && defined(__SUNPRO_C) /* SUNWspro cc */
52
/* SunPRO cc miscompiles the simulator function for X_BcdB: d.i[1] is
53
* temporarily stored in %l2 and put onto the stack from %l2, but in between
54
* the copy of X has used %l2 as a counter without saving and restoring its
59
#if defined(__mipsn32__) && !defined(__GNUC__)
60
/* The X test crashes for an unknown reason. */
64
#define uchar unsigned char
65
#define ushort unsigned short
66
#define uint unsigned int
67
#define ulong unsigned long
69
typedef struct { char x; } Char;
70
typedef struct { short x; } Short;
71
typedef struct { int x; } Int;
72
typedef struct { long x; } Long;
73
typedef struct { float x; } Float;
74
typedef struct { double x; } Double;
75
typedef struct { char c; float f; } A;
76
typedef struct { double d; int i[3]; } B;
77
typedef struct { long l1; long l2; } J;
78
typedef struct { char c[3]; } T;
79
typedef struct { char c[33],c1; } X;
81
char c1='a', c2=127, c3=(char)128, c4=(char)255, c5=-1;
82
short s1=32767, s2=(short)32768, s3=3, s4=4, s5=5, s6=6, s7=7, s8=8, s9=9;
83
int i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9,
84
i10=11, i11=12, i12=13, i13=14, i14=15, i15=16, i16=17;
85
long l1=1, l2=2, l3=3, l4=4, l5=5, l6=6, l7=7, l8=8, l9=9;
86
#ifdef HAVE_LONG_LONG_INT
87
long long ll1 = 3875056143130689530LL;
89
float f1=0.1, f2=0.2, f3=0.3, f4=0.4, f5=0.5, f6=0.6, f7=0.7, f8=0.8, f9=0.9,
90
f10=1.1, f11=1.2, f12=1.3, f13=1.4, f14=1.5, f15=1.6, f16=1.7;
91
double d1=0.1, d2=0.2, d3=0.3, d4=0.4, d5=0.5, d6=0.6, d7=0.7, d8=0.8, d9=0.9,
92
d10=1.1, d11=1.2, d12=1.3, d13=1.4, d14=1.5, d15=1.6, d16=1.7;
94
uchar uc1='a', uc2=127, uc3=128, uc4=255, uc5=(uchar)-1;
95
ushort us1=1, us2=2, us3=3, us4=4, us5=5, us6=6, us7=7, us8=8, us9=9;
96
uint ui1=1, ui2=2, ui3=3, ui4=4, ui5=5, ui6=6, ui7=7, ui8=8, ui9=9;
97
ulong ul1=1, ul2=2, ul3=3, ul4=4, ul5=5, ul6=6, ul7=7, ul8=8, ul9=9;
99
char *str1="hello",str2[]="goodbye",*str3="still here?";
100
Char C1={'A'}, C2={'B'}, C3={'C'}, C4={'\377'}, C5={-1};
101
Short S1={1}, S2={2}, S3={3}, S4={4}, S5={5}, S6={6}, S7={7}, S8={8}, S9={9};
102
Int I1={1}, I2={2}, I3={3}, I4={4}, I5={5}, I6={6}, I7={7}, I8={8}, I9={9};
103
Float F1={0.1}, F2={0.2}, F3={0.3}, F4={0.4}, F5={0.5}, F6={0.6}, F7={0.7}, F8={0.8}, F9={0.9};
104
Double D1={0.1}, D2={0.2}, D3={0.3}, D4={0.4}, D5={0.5}, D6={0.6}, D7={0.7}, D8={0.8}, D9={0.9};
106
A A1={'a',0.1},A2={'b',0.2},A3={'\377',0.3};
107
B B1={0.1,{1,2,3}},B2={0.2,{5,4,3}};
108
J J1={47,11},J2={73,55};
109
T T1={'t','h','e'},T2={'f','o','x'};
110
X X1={"abcdefghijklmnopqrstuvwxyzABCDEF",'G'}, X2={"123",'9'}, X3={"return-return-return",'R'};
115
fprintf(out,"void f(void):\n");
123
fprintf(out,"int f(void):");
130
fprintf(out,"int f(int):(%d)",a);
134
int i_i2 (int a, int b)
137
fprintf(out,"int f(2*int):(%d,%d)",a,b);
141
int i_i4 (int a, int b, int c, int d)
144
fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d);
148
int i_i8 (int a, int b, int c, int d, int e, int f, int g, int h)
150
int r=a+b+c+d+e+f+g+h;
151
fprintf(out,"int f(8*int):(%d,%d,%d,%d,%d,%d,%d,%d)",a,b,c,d,e,f,g,h);
155
int i_i16 (int a, int b, int c, int d, int e, int f, int g, int h,
156
int i, int j, int k, int l, int m, int n, int o, int p)
158
int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
159
fprintf(out,"int f(16*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
160
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
169
fprintf(out,"float f(float):(%g)",a);
173
float f_f2 (float a, float b)
176
fprintf(out,"float f(2*float):(%g,%g)",a,b);
180
float f_f4 (float a, float b, float c, float d)
183
fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d);
187
float f_f8 (float a, float b, float c, float d, float e, float f,
190
float r=a+b+c+d+e+f+g+h;
191
fprintf(out,"float f(8*float):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
195
float f_f16 (float a, float b, float c, float d, float e, float f, float g, float h,
196
float i, float j, float k, float l, float m, float n, float o, float p)
198
float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
199
fprintf(out,"float f(16*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
205
double d_d (double a)
208
fprintf(out,"double f(double):(%g)",a);
212
double d_d2 (double a, double b)
215
fprintf(out,"double f(2*double):(%g,%g)",a,b);
219
double d_d4 (double a, double b, double c, double d)
222
fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d);
226
double d_d8 (double a, double b, double c, double d, double e, double f,
229
double r=a+b+c+d+e+f+g+h;
230
fprintf(out,"double f(8*double):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
234
double d_d16 (double a, double b, double c, double d, double e, double f,
235
double g, double h, double i, double j, double k, double l,
236
double m, double n, double o, double p)
238
double r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
239
fprintf(out,"double f(16*double):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
245
void* vp_vpdpcpsp (void* a, double* b, char* c, Int* d)
247
void* ret = (char*)b + 1;
248
fprintf(out,"void* f(void*,double*,char*,Int*):(0x%lx,0x%lx,0x%lx,0x%lx)",(long)a,(long)b,(long)c,(long)d);
253
/* mixed number tests */
254
uchar uc_ucsil (uchar a, ushort b, uint c, ulong d)
257
fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d);
261
double d_iidd (int a, int b, double c, double d)
264
fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d);
268
double d_idid (int a, double b, int c, double d)
271
fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d);
275
ushort us_cdcd (char a, double b, char c, double d)
277
ushort r = (ushort)(a + b + c + d);
278
fprintf(out,"ushort f(char,double,char,double):('%c',%g,'%c',%g)",a,b,c,d);
283
#ifdef HAVE_LONG_LONG_INT
284
long long ll_flli (float a, long long b, int c)
286
long long r = (long long)(int)a + b + (long long)c;
287
fprintf(out,"long long f(float,long long,int):(%g,0x%lx%08lx,0x%lx)",a,(long)(b>>32),(long)(b&0xffffffff),(long)c);
293
/* structure tests */
294
Int I_III (Int a, Int b, Int c)
297
r.x = a.x + b.x + c.x;
298
fprintf(out,"Int f(Int,Int,Int):({%d},{%d},{%d})",a.x,b.x,c.x);
302
Char C_CdC (Char a, double b, Char c)
306
fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x);
310
Float F_Ffd (Float a, float b, double c)
314
fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c);
318
Double D_fDd (float a, Double b, double c)
322
fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c);
326
J J_JiJ (J a, int b, J c)
329
r.l1 = a.l1+c.l1; r.l2 = a.l2+b+c.l2;
330
fprintf(out,"J f(J,int,J):({%ld,%ld},%d,{%ld,%ld})",a.l1,a.l2,b,c.l1,c.l2);
334
T T_TcT (T a, char b, T c)
337
r.c[0]='b'; r.c[1]=c.c[1]; r.c[2]=c.c[2];
338
fprintf(out,"T f(T,char,T):({\"%c%c%c\"},'%c',{\"%c%c%c\"})",a.c[0],a.c[1],a.c[2],b,c.c[0],c.c[1],c.c[2]);
342
X X_BcdB (B a, char b, double c, B d)
344
static X xr={"return val",'R'};
348
fprintf(out,"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})",
349
a.d,a.i[0],a.i[1],a.i[2],b,c,d.d,d.i[0],d.i[1],d.i[2]);
355
void* current_function;
357
/* This function simulates the behaviour of current_function. */
358
void simulator (va_alist alist)
361
if (current_function == (void*)&v_v)
363
va_start_void(alist);
364
fprintf(out,"void f(void):\n");
366
va_return_void(alist);
370
else if (current_function == (void*)&i_v)
374
fprintf(out,"int f(void):");
376
va_return_int(alist, r);
378
else if (current_function == (void*)&i_i)
381
{int a = va_arg_int(alist);
383
fprintf(out,"int f(int):(%d)",a);
385
va_return_int(alist, r);
387
else if (current_function == (void*)&i_i2)
390
{int a = va_arg_int(alist);
391
int b = va_arg_int(alist);
393
fprintf(out,"int f(2*int):(%d,%d)",a,b);
395
va_return_int(alist, r);
397
else if (current_function == (void*)&i_i4)
400
{int a = va_arg_int(alist);
401
int b = va_arg_int(alist);
402
int c = va_arg_int(alist);
403
int d = va_arg_int(alist);
405
fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d);
407
va_return_int(alist, r);
409
else if (current_function == (void*)&i_i8)
412
{int a = va_arg_int(alist);
413
int b = va_arg_int(alist);
414
int c = va_arg_int(alist);
415
int d = va_arg_int(alist);
416
int e = va_arg_int(alist);
417
int f = va_arg_int(alist);
418
int g = va_arg_int(alist);
419
int h = va_arg_int(alist);
420
int r=a+b+c+d+e+f+g+h;
421
fprintf(out,"int f(8*int):(%d,%d,%d,%d,%d,%d,%d,%d)",a,b,c,d,e,f,g,h);
423
va_return_int(alist, r);
425
else if (current_function == (void*)&i_i16)
428
{int a = va_arg_int(alist);
429
int b = va_arg_int(alist);
430
int c = va_arg_int(alist);
431
int d = va_arg_int(alist);
432
int e = va_arg_int(alist);
433
int f = va_arg_int(alist);
434
int g = va_arg_int(alist);
435
int h = va_arg_int(alist);
436
int i = va_arg_int(alist);
437
int j = va_arg_int(alist);
438
int k = va_arg_int(alist);
439
int l = va_arg_int(alist);
440
int m = va_arg_int(alist);
441
int n = va_arg_int(alist);
442
int o = va_arg_int(alist);
443
int p = va_arg_int(alist);
444
int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
445
fprintf(out,"int f(16*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
446
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
448
va_return_int(alist, r);
452
else if (current_function == (void*)&f_f)
454
va_start_float(alist);
455
{float a = va_arg_float(alist);
457
fprintf(out,"float f(float):(%g)",a);
459
va_return_float(alist, r);
461
else if (current_function == (void*)&f_f2)
463
va_start_float(alist);
464
{float a = va_arg_float(alist);
465
float b = va_arg_float(alist);
467
fprintf(out,"float f(2*float):(%g,%g)",a,b);
469
va_return_float(alist, r);
471
else if (current_function == (void*)&f_f4)
473
va_start_float(alist);
474
{float a = va_arg_float(alist);
475
float b = va_arg_float(alist);
476
float c = va_arg_float(alist);
477
float d = va_arg_float(alist);
479
fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d);
481
va_return_float(alist, r);
483
else if (current_function == (void*)&f_f8)
485
va_start_float(alist);
486
{float a = va_arg_float(alist);
487
float b = va_arg_float(alist);
488
float c = va_arg_float(alist);
489
float d = va_arg_float(alist);
490
float e = va_arg_float(alist);
491
float f = va_arg_float(alist);
492
float g = va_arg_float(alist);
493
float h = va_arg_float(alist);
494
float r=a+b+c+d+e+f+g+h;
495
fprintf(out,"float f(8*float):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
497
va_return_float(alist, r);
499
else if (current_function == (void*)&f_f16)
501
va_start_float(alist);
502
{float a = va_arg_float(alist);
503
float b = va_arg_float(alist);
504
float c = va_arg_float(alist);
505
float d = va_arg_float(alist);
506
float e = va_arg_float(alist);
507
float f = va_arg_float(alist);
508
float g = va_arg_float(alist);
509
float h = va_arg_float(alist);
510
float i = va_arg_float(alist);
511
float j = va_arg_float(alist);
512
float k = va_arg_float(alist);
513
float l = va_arg_float(alist);
514
float m = va_arg_float(alist);
515
float n = va_arg_float(alist);
516
float o = va_arg_float(alist);
517
float p = va_arg_float(alist);
518
float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
519
fprintf(out,"float f(16*float):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
521
va_return_float(alist, r);
525
else if (current_function == (void*)&d_d)
527
va_start_double(alist);
528
{double a = va_arg_double(alist);
530
fprintf(out,"double f(double):(%g)",a);
532
va_return_double(alist, r);
534
else if (current_function == (void*)&d_d2)
536
va_start_double(alist);
537
{double a = va_arg_double(alist);
538
double b = va_arg_double(alist);
540
fprintf(out,"double f(2*double):(%g,%g)",a,b);
542
va_return_double(alist, r);
544
else if (current_function == (void*)&d_d4)
546
va_start_double(alist);
547
{double a = va_arg_double(alist);
548
double b = va_arg_double(alist);
549
double c = va_arg_double(alist);
550
double d = va_arg_double(alist);
552
fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d);
554
va_return_double(alist, r);
556
else if (current_function == (void*)&d_d8)
558
va_start_double(alist);
559
{double a = va_arg_double(alist);
560
double b = va_arg_double(alist);
561
double c = va_arg_double(alist);
562
double d = va_arg_double(alist);
563
double e = va_arg_double(alist);
564
double f = va_arg_double(alist);
565
double g = va_arg_double(alist);
566
double h = va_arg_double(alist);
567
double r=a+b+c+d+e+f+g+h;
568
fprintf(out,"double f(8*double):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
570
va_return_double(alist, r);
572
else if (current_function == (void*)&d_d16)
574
va_start_double(alist);
575
{double a = va_arg_double(alist);
576
double b = va_arg_double(alist);
577
double c = va_arg_double(alist);
578
double d = va_arg_double(alist);
579
double e = va_arg_double(alist);
580
double f = va_arg_double(alist);
581
double g = va_arg_double(alist);
582
double h = va_arg_double(alist);
583
double i = va_arg_double(alist);
584
double j = va_arg_double(alist);
585
double k = va_arg_double(alist);
586
double l = va_arg_double(alist);
587
double m = va_arg_double(alist);
588
double n = va_arg_double(alist);
589
double o = va_arg_double(alist);
590
double p = va_arg_double(alist);
591
double r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
592
fprintf(out,"double f(16*double):(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
594
va_return_double(alist, r);
598
else if (current_function == (void*)&vp_vpdpcpsp)
600
va_start_ptr(alist, void*);
601
{void* a = va_arg_ptr(alist, void*);
602
double* b = va_arg_ptr(alist, double*);
603
char* c = va_arg_ptr(alist, char*);
604
Int* d = va_arg_ptr(alist, Int*);
605
void* ret = (char*)b + 1;
606
fprintf(out,"void* f(void*,double*,char*,Int*):(0x%lx,0x%lx,0x%lx,0x%lx)",(long)a,(long)b,(long)c,(long)d);
608
va_return_ptr(alist, void*, ret);
611
/* mixed number tests */
612
else if (current_function == (void*)&uc_ucsil)
614
va_start_uchar(alist);
615
{uchar a = va_arg_uchar(alist);
616
ushort b = va_arg_ushort(alist);
617
uint c = va_arg_uint(alist);
618
ulong d = va_arg_ulong(alist);
620
fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d);
622
va_return_uchar(alist, r);
624
else if (current_function == (void*)&d_iidd)
626
va_start_double(alist);
627
{int a = va_arg_int(alist);
628
int b = va_arg_int(alist);
629
double c = va_arg_double(alist);
630
double d = va_arg_double(alist);
632
fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d);
634
va_return_double(alist, r);
636
else if (current_function == (void*)&d_idid)
638
va_start_double(alist);
639
{int a = va_arg_int(alist);
640
double b = va_arg_double(alist);
641
int c = va_arg_int(alist);
642
double d = va_arg_double(alist);
644
fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d);
646
va_return_double(alist, r);
648
else if (current_function == (void*)&us_cdcd)
650
va_start_ushort(alist);
651
{char a = va_arg_char(alist);
652
double b = va_arg_double(alist);
653
char c = va_arg_char(alist);
654
double d = va_arg_double(alist);
655
ushort r = (ushort)(a + b + c + d);
656
fprintf(out,"ushort f(char,double,char,double):('%c',%g,'%c',%g)",a,b,c,d);
658
va_return_ushort(alist, r);
660
#ifdef HAVE_LONG_LONG_INT
661
else if (current_function == (void*)&ll_flli)
663
va_start_longlong(alist);
664
{float a = va_arg_float(alist);
665
long long b = va_arg_longlong(alist);
666
int c = va_arg_int(alist);
667
long long r = (long long)(int)a + b + (long long)c;
668
fprintf(out,"long long f(float,long long,int):(%g,0x%lx%08lx,0x%lx)",a,(long)(b>>32),(long)(b&0xffffffff),(long)c);
670
va_return_longlong(alist, r);
675
/* structure tests */
676
else if (current_function == (void*)&I_III)
682
va_start_struct(alist, Int, 1);
683
a = va_arg_struct(alist, Int);
684
b = va_arg_struct(alist, Int);
685
c = va_arg_struct(alist, Int);
686
r.x = a.x + b.x + c.x;
687
fprintf(out,"Int f(Int,Int,Int):({%d},{%d},{%d})",a.x,b.x,c.x);
689
va_return_struct(alist, Int, r);
691
#ifndef SKIP_EXTRA_STRUCTS
692
else if (current_function == (void*)&C_CdC)
698
va_start_struct(alist, Char, 1);
699
a = va_arg_struct(alist, Char);
700
b = va_arg_double(alist);
701
c = va_arg_struct(alist, Char);
703
fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x);
705
va_return_struct(alist, Char, r);
707
else if (current_function == (void*)&F_Ffd)
713
va_start_struct(alist, Float, va_word_splittable_1(float));
714
a = va_arg_struct(alist, Float);
715
b = va_arg_float(alist);
716
c = va_arg_double(alist);
718
fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c);
720
va_return_struct(alist, Float, r);
722
else if (current_function == (void*)&D_fDd)
728
va_start_struct(alist, Double, va_word_splittable_1(double));
729
a = va_arg_float(alist);
730
b = va_arg_struct(alist, Double);
731
c = va_arg_double(alist);
733
fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c);
735
va_return_struct(alist, Double, r);
738
else if (current_function == (void*)&J_JiJ)
744
va_start_struct(alist, J, va_word_splittable_2(long,long));
745
a = va_arg_struct(alist, J);
746
b = va_arg_int(alist);
747
c = va_arg_struct(alist, J);
748
r.l1 = a.l1+c.l1; r.l2 = a.l2+b+c.l2;
749
fprintf(out,"J f(J,int,J):({%ld,%ld},%d,{%ld,%ld})",a.l1,a.l2,b,c.l1,c.l2);
751
va_return_struct(alist, J, r);
753
#ifndef SKIP_EXTRA_STRUCTS
754
else if (current_function == (void*)&T_TcT)
760
va_start_struct(alist, T, 1);
761
a = va_arg_struct(alist, T);
762
b = va_arg_char(alist);
763
c = va_arg_struct(alist, T);
764
r.c[0]='b'; r.c[1]=c.c[1]; r.c[2]=c.c[2];
765
fprintf(out,"T f(T,char,T):({\"%c%c%c\"},'%c',{\"%c%c%c\"})",a.c[0],a.c[1],a.c[2],b,c.c[0],c.c[1],c.c[2]);
767
va_return_struct(alist, T, r);
769
else if (current_function == (void*)&X_BcdB)
775
static X xr={"return val",'R'};
777
va_start_struct(alist, X, 0);
778
a = va_arg_struct(alist, B);
779
b = va_arg_char(alist);
780
c = va_arg_double(alist);
781
d = va_arg_struct(alist, B);
784
fprintf(out,"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})",
785
a.d,a.i[0],a.i[1],a.i[2],b,c,d.d,d.i[0],d.i[1],d.i[2]);
787
va_return_struct(alist, X, r);
794
fprintf(out,"simulate: unknown function\n");
800
* The way we run these tests - first call the function directly, then
801
* through vacall() - there is the danger that arguments or results seem
802
* to be passed correctly, but what we are seeing are in fact the vestiges
803
* (traces) or the previous call. This may seriously fake the test.
804
* Avoid this by clearing the registers between the first and the second call.
806
long clear_traces_i (long a, long b, long c, long d, long e, long f, long g, long h,
807
long i, long j, long k, long l, long m, long n, long o, long p)
809
float clear_traces_f (float a, float b, float c, float d, float e, float f, float g,
810
float h, float i, float j, float k, float l, float m, float n,
813
double clear_traces_d (double a, double b, double c, double d, double e, double f, double g,
814
double h, double i, double j, double k, double l, double m, double n,
817
J clear_traces_J (void)
818
{ J j; j.l1 = j.l2 = 0; return j; }
819
void clear_traces (void)
820
{ clear_traces_i(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
821
clear_traces_f(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
822
clear_traces_d(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0);
830
vacall_function = &simulator;
835
current_function = (void*) &v_v; ((void (*) (void)) vacall) ();
841
fprintf(out,"->%d\n",ir);
843
ir = 0; clear_traces();
844
current_function = (void*) &i_v; ir = ((int (*) (void)) vacall) ();
845
fprintf(out,"->%d\n",ir);
849
fprintf(out,"->%d\n",ir);
851
ir = 0; clear_traces();
852
current_function = (void*) &i_i; ir = ((int (*) (int)) vacall) (i1);
853
fprintf(out,"->%d\n",ir);
857
fprintf(out,"->%d\n",ir);
859
ir = 0; clear_traces();
860
current_function = (void*) &i_i2; ir = ((int (*) (int,int)) vacall) (i1,i2);
861
fprintf(out,"->%d\n",ir);
864
ir = i_i4(i1,i2,i3,i4);
865
fprintf(out,"->%d\n",ir);
867
ir = 0; clear_traces();
868
current_function = (void*) &i_i4; ir = ((int (*) (int,int,int,int)) vacall) (i1,i2,i3,i4);
869
fprintf(out,"->%d\n",ir);
872
ir = i_i8(i1,i2,i3,i4,i5,i6,i7,i8);
873
fprintf(out,"->%d\n",ir);
875
ir = 0; clear_traces();
876
current_function = (void*) &i_i8; ir = ((int (*) (int,int,int,int,int,int,int,int)) vacall) (i1,i2,i3,i4,i5,i6,i7,i8);
877
fprintf(out,"->%d\n",ir);
880
ir = i_i16(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16);
881
fprintf(out,"->%d\n",ir);
883
ir = 0; clear_traces();
884
current_function = (void*) &i_i16; ir = ((int (*) (int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int)) vacall) (i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16);
885
fprintf(out,"->%d\n",ir);
893
fprintf(out,"->%g\n",fr);
895
fr = 0.0; clear_traces();
896
current_function = (void*) &f_f; fr = ((float (*) (float)) vacall) (f1);
897
fprintf(out,"->%g\n",fr);
901
fprintf(out,"->%g\n",fr);
903
fr = 0.0; clear_traces();
904
current_function = (void*) &f_f2; fr = ((float (*) (float,float)) vacall) (f1,f2);
905
fprintf(out,"->%g\n",fr);
908
fr = f_f4(f1,f2,f3,f4);
909
fprintf(out,"->%g\n",fr);
911
fr = 0.0; clear_traces();
912
current_function = (void*) &f_f4; fr = ((float (*) (float,float,float,float)) vacall) (f1,f2,f3,f4);
913
fprintf(out,"->%g\n",fr);
916
fr = f_f8(f1,f2,f3,f4,f5,f6,f7,f8);
917
fprintf(out,"->%g\n",fr);
919
fr = 0.0; clear_traces();
920
current_function = (void*) &f_f8; fr = ((float (*) (float,float,float,float,float,float,float,float)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8);
921
fprintf(out,"->%g\n",fr);
924
fr = f_f16(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16);
925
fprintf(out,"->%g\n",fr);
927
fr = 0.0; clear_traces();
928
current_function = (void*) &f_f16; fr = ((float (*) (float,float,float,float,float,float,float,float,float,float,float,float,float,float,float,float)) vacall) (f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16);
929
fprintf(out,"->%g\n",fr);
937
fprintf(out,"->%g\n",dr);
939
dr = 0.0; clear_traces();
940
current_function = (void*) &d_d; dr = ((double (*) (double)) vacall) (d1);
941
fprintf(out,"->%g\n",dr);
945
fprintf(out,"->%g\n",dr);
947
dr = 0.0; clear_traces();
948
current_function = (void*) &d_d2; dr = ((double (*) (double,double)) vacall) (d1,d2);
949
fprintf(out,"->%g\n",dr);
952
dr = d_d4(d1,d2,d3,d4);
953
fprintf(out,"->%g\n",dr);
955
dr = 0.0; clear_traces();
956
current_function = (void*) &d_d4; dr = ((double (*) (double,double,double,double)) vacall) (d1,d2,d3,d4);
957
fprintf(out,"->%g\n",dr);
960
dr = d_d8(d1,d2,d3,d4,d5,d6,d7,d8);
961
fprintf(out,"->%g\n",dr);
963
dr = 0.0; clear_traces();
964
current_function = (void*) &d_d8; dr = ((double (*) (double,double,double,double,double,double,double,double)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8);
965
fprintf(out,"->%g\n",dr);
968
dr = d_d16(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16);
969
fprintf(out,"->%g\n",dr);
971
dr = 0.0; clear_traces();
972
current_function = (void*) &d_d16; dr = ((double (*) (double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double)) vacall) (d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16);
973
fprintf(out,"->%g\n",dr);
980
vpr = vp_vpdpcpsp(&uc1,&d2,str3,&I4);
981
fprintf(out,"->0x%lx\n",(long)vpr);
983
vpr = 0; clear_traces();
984
current_function = (void*) &vp_vpdpcpsp; vpr = ((void* (*) (void*,double*,char*,Int*)) vacall) (&uc1,&d2,str3,&I4);
985
fprintf(out,"->0x%lx\n",(long)vpr);
989
/* mixed number tests */
993
#ifdef HAVE_LONG_LONG_INT
997
ucr = uc_ucsil(uc1,us2,ui3,ul4);
998
fprintf(out,"->%u\n",ucr);
1000
ucr = 0; clear_traces();
1001
current_function = (void*) &uc_ucsil; ucr = ((uchar (*) (uchar,ushort,uint,ulong)) vacall) (uc1,us2,ui3,ul4);
1002
fprintf(out,"->%u\n",ucr);
1005
dr = d_iidd(i1,i2,d3,d4);
1006
fprintf(out,"->%g\n",dr);
1008
dr = 0.0; clear_traces();
1009
current_function = (void*) &d_iidd; dr = ((double (*) (int,int,double,double)) vacall) (i1,i2,d3,d4);
1010
fprintf(out,"->%g\n",dr);
1013
dr = d_idid(i1,d2,i3,d4);
1014
fprintf(out,"->%g\n",dr);
1016
dr = 0.0; clear_traces();
1017
current_function = (void*) &d_idid; dr = ((double (*) (int,double,int,double)) vacall) (i1,d2,i3,d4);
1018
fprintf(out,"->%g\n",dr);
1021
usr = us_cdcd(c1,d2,c3,d4);
1022
fprintf(out,"->%u\n",usr);
1024
usr = 0; clear_traces();
1025
current_function = (void*) &us_cdcd; usr = ((ushort (*) (char,double,char,double)) vacall) (c1,d2,c3,d4);
1026
fprintf(out,"->%u\n",usr);
1029
#ifdef HAVE_LONG_LONG_INT
1030
llr = ll_flli(f13,ll1,i13);
1031
fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff));
1033
llr = 0; clear_traces();
1034
current_function = (void*) &ll_flli; llr = ((long long (*) (float,long long,int)) vacall) (f13,ll1,i13);
1035
fprintf(out,"->0x%lx%08lx\n",(long)(llr>>32),(long)(llr&0xffffffff));
1040
#ifndef SKIP_STRUCTS
1041
/* structure tests */
1050
Ir = I_III(I1,I2,I3);
1051
fprintf(out,"->{%d}\n",Ir.x);
1053
Ir.x = 0; clear_traces();
1054
current_function = (void*) &I_III; Ir = ((Int (*) (Int,Int,Int)) vacall) (I1,I2,I3);
1055
fprintf(out,"->{%d}\n",Ir.x);
1058
#ifndef SKIP_EXTRA_STRUCTS
1059
Cr = C_CdC(C1,d2,C3);
1060
fprintf(out,"->{'%c'}\n",Cr.x);
1062
Cr.x = '\0'; clear_traces();
1063
current_function = (void*) &C_CdC; Cr = ((Char (*) (Char,double,Char)) vacall) (C1,d2,C3);
1064
fprintf(out,"->{'%c'}\n",Cr.x);
1067
Fr = F_Ffd(F1,f2,d3);
1068
fprintf(out,"->{%g}\n",Fr.x);
1070
Fr.x = 0.0; clear_traces();
1071
current_function = (void*) &F_Ffd; Fr = ((Float (*) (Float,float,double)) vacall) (F1,f2,d3);
1072
fprintf(out,"->{%g}\n",Fr.x);
1075
Dr = D_fDd(f1,D2,d3);
1076
fprintf(out,"->{%g}\n",Dr.x);
1078
Dr.x = 0.0; clear_traces();
1079
current_function = (void*) &D_fDd; Dr = ((Double (*) (float,Double,double)) vacall) (f1,D2,d3);
1080
fprintf(out,"->{%g}\n",Dr.x);
1084
Jr = J_JiJ(J1,i2,J2);
1085
fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2);
1087
Jr.l1 = Jr.l2 = 0; clear_traces();
1088
current_function = (void*) &J_JiJ; Jr = ((J (*) (J,int,J)) vacall) (J1,i2,J2);
1089
fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2);
1092
#ifndef SKIP_EXTRA_STRUCTS
1094
Tr = T_TcT(T1,' ',T2);
1095
fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]);
1097
Tr.c[0] = Tr.c[1] = Tr.c[2] = 0; clear_traces();
1098
current_function = (void*) &T_TcT; Tr = ((T (*) (T,char,T)) vacall) (T1,' ',T2);
1099
fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]);
1104
Xr = X_BcdB(B1,c2,d3,B2);
1105
fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1);
1107
Xr.c[0]=Xr.c1='\0'; clear_traces();
1108
current_function = (void*) &X_BcdB; Xr = ((X (*) (B,char,double,B)) vacall) (B1,c2,d3,B2);
1109
fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1);