~ubuntu-branches/debian/squeeze/ffcall/squeeze

« back to all changes in this revision

Viewing changes to vacall/tests.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2010-06-26 15:29:30 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100626152930-c09y01gk3szcnykn
Tags: 1.10+cvs20100619-2
Ship to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Some random tests for vacall. */
 
2
 
 
3
/*
 
4
 * Copyright 1993 Bill Triggs, <Bill.Triggs@inrialpes.fr>
 
5
 * Copyright 1995-1999, 2001-2002, 2005 Bruno Haible, <bruno@clisp.org>
 
6
 *
 
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,
 
10
 * on this software.
 
11
 */
 
12
 
 
13
#include "config.h"
 
14
#include <stdio.h>
 
15
#include <stdlib.h>
 
16
#include <string.h>
 
17
#include "vacall.h"
 
18
FILE* out;
 
19
 
 
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. */
 
23
#define SKIP_T
 
24
#endif
 
25
#endif
 
26
#if defined(__m68k__) && defined(sun) && !defined(__GNUC__)
 
27
/* A SunOS 4.0.3 cc bug is triggered by the va_arg_struct macro. */
 
28
#define SKIP_STRUCTS
 
29
#endif
 
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.
 
35
 */
 
36
#define SKIP_T
 
37
#endif
 
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.
 
47
 */
 
48
#define SKIP_X
 
49
#endif
 
50
#endif
 
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
 
55
 * value.
 
56
 */
 
57
#define SKIP_X
 
58
#endif
 
59
#if defined(__mipsn32__) && !defined(__GNUC__)
 
60
/* The X test crashes for an unknown reason. */
 
61
#define SKIP_X
 
62
#endif
 
63
 
 
64
#define uchar unsigned char
 
65
#define ushort unsigned short
 
66
#define uint unsigned int
 
67
#define ulong unsigned long
 
68
 
 
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;
 
80
 
 
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;
 
88
#endif
 
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;
 
93
 
 
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;
 
98
 
 
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};
 
105
 
 
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'};
 
111
 
 
112
/* void tests */
 
113
void v_v (void)
 
114
{
 
115
  fprintf(out,"void f(void):\n");
 
116
  fflush(out);
 
117
}
 
118
 
 
119
/* int tests */
 
120
int i_v (void)
 
121
{
 
122
  int r=99;
 
123
  fprintf(out,"int f(void):");
 
124
  fflush(out);
 
125
  return r;
 
126
}
 
127
int i_i (int a)
 
128
{
 
129
  int r=a+1;
 
130
  fprintf(out,"int f(int):(%d)",a);
 
131
  fflush(out);
 
132
  return r;
 
133
}
 
134
int i_i2 (int a, int b)
 
135
{
 
136
  int r=a+b;
 
137
  fprintf(out,"int f(2*int):(%d,%d)",a,b);
 
138
  fflush(out);
 
139
  return r;
 
140
}
 
141
int i_i4 (int a, int b, int c, int d)
 
142
{
 
143
  int r=a+b+c+d;
 
144
  fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d);
 
145
  fflush(out);
 
146
  return r;
 
147
}
 
148
int i_i8 (int a, int b, int c, int d, int e, int f, int g, int h)
 
149
{
 
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);
 
152
  fflush(out);
 
153
  return r;
 
154
}
 
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)
 
157
{
 
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);
 
161
  fflush(out);
 
162
  return r;
 
163
}
 
164
 
 
165
/* float tests */
 
166
float f_f (float a)
 
167
{
 
168
  float r=a+1.0;
 
169
  fprintf(out,"float f(float):(%g)",a);
 
170
  fflush(out);
 
171
  return r;
 
172
}
 
173
float f_f2 (float a, float b)
 
174
{
 
175
  float r=a+b;
 
176
  fprintf(out,"float f(2*float):(%g,%g)",a,b);
 
177
  fflush(out);
 
178
  return r;
 
179
}
 
180
float f_f4 (float a, float b, float c, float d)
 
181
{
 
182
  float r=a+b+c+d;
 
183
  fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d);
 
184
  fflush(out);
 
185
  return r;
 
186
}
 
187
float f_f8 (float a, float b, float c, float d, float e, float f,
 
188
            float g, float h)
 
189
{
 
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);
 
192
  fflush(out);
 
193
  return r;
 
194
}
 
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)
 
197
{
 
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);
 
200
  fflush(out);
 
201
  return r;
 
202
}
 
203
 
 
204
/* double tests */
 
205
double d_d (double a)
 
206
{
 
207
  double r=a+1.0;
 
208
  fprintf(out,"double f(double):(%g)",a);
 
209
  fflush(out);
 
210
  return r;
 
211
}
 
212
double d_d2 (double a, double b)
 
213
{
 
214
  double r=a+b;
 
215
  fprintf(out,"double f(2*double):(%g,%g)",a,b);
 
216
  fflush(out);
 
217
  return r;
 
218
}
 
219
double d_d4 (double a, double b, double c, double d)
 
220
{
 
221
  double r=a+b+c+d;
 
222
  fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d);
 
223
  fflush(out);
 
224
  return r;
 
225
}
 
226
double d_d8 (double a, double b, double c, double d, double e, double f,
 
227
             double g, double h)
 
228
{
 
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);
 
231
  fflush(out);
 
232
  return r;
 
233
}
 
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)
 
237
{
 
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);
 
240
  fflush(out);
 
241
  return r;
 
242
}
 
243
 
 
244
/* pointer tests */
 
245
void* vp_vpdpcpsp (void* a, double* b, char* c, Int* d)
 
246
{
 
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);
 
249
  fflush(out);
 
250
  return ret;
 
251
}
 
252
 
 
253
/* mixed number tests */
 
254
uchar uc_ucsil (uchar a, ushort b, uint c, ulong d)
 
255
{
 
256
  uchar r = (uchar)-1;
 
257
  fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d);
 
258
  fflush(out);
 
259
  return r;
 
260
}
 
261
double d_iidd (int a, int b, double c, double d)
 
262
{
 
263
  double r = a+b+c+d;
 
264
  fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d);
 
265
  fflush(out);
 
266
  return r;
 
267
}
 
268
double d_idid (int a, double b, int c, double d)
 
269
{
 
270
  double r = a+b+c+d;
 
271
  fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d);
 
272
  fflush(out);
 
273
  return r;
 
274
}
 
275
ushort us_cdcd (char a, double b, char c, double d)
 
276
{
 
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);
 
279
  fflush(out);
 
280
  return r;
 
281
}
 
282
 
 
283
#ifdef HAVE_LONG_LONG_INT
 
284
long long ll_flli (float a, long long b, int c)
 
285
{
 
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);
 
288
  fflush(out);
 
289
  return r;
 
290
}
 
291
#endif
 
292
 
 
293
/* structure tests */
 
294
Int I_III (Int a, Int b, Int c)
 
295
{
 
296
  Int r;
 
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);
 
299
  fflush(out);
 
300
  return r;
 
301
}
 
302
Char C_CdC (Char a, double b, Char c)
 
303
{
 
304
  Char r;
 
305
  r.x = (a.x + c.x)/2;
 
306
  fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x);
 
307
  fflush(out);
 
308
  return r;
 
309
}
 
310
Float F_Ffd (Float a, float b, double c)
 
311
{
 
312
  Float r;
 
313
  r.x = a.x + b + c;
 
314
  fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c);
 
315
  fflush(out);
 
316
  return r;
 
317
}
 
318
Double D_fDd (float a, Double b, double c)
 
319
{
 
320
  Double r;
 
321
  r.x = a + b.x + c;
 
322
  fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c);
 
323
  fflush(out);
 
324
  return r;
 
325
}
 
326
J J_JiJ (J a, int b, J c)
 
327
{
 
328
  J r;
 
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);
 
331
  fflush(out);
 
332
  return r;
 
333
}
 
334
T T_TcT (T a, char b, T c)
 
335
{
 
336
  T r;
 
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]);
 
339
  fflush(out);
 
340
  return r;
 
341
}
 
342
X X_BcdB (B a, char b, double c, B d)
 
343
{
 
344
  static X xr={"return val",'R'};
 
345
  X r;
 
346
  r = xr;
 
347
  r.c1 = b;
 
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]);
 
350
  fflush(out);
 
351
  return r;
 
352
}
 
353
 
 
354
 
 
355
void* current_function;
 
356
 
 
357
/* This function simulates the behaviour of current_function. */
 
358
void simulator (va_alist alist)
 
359
{
 
360
  /* void tests */
 
361
  if (current_function == (void*)&v_v)
 
362
    {
 
363
      va_start_void(alist);
 
364
      fprintf(out,"void f(void):\n");
 
365
      fflush(out);
 
366
      va_return_void(alist);
 
367
    }
 
368
 
 
369
  /* int tests */
 
370
  else if (current_function == (void*)&i_v)
 
371
    {
 
372
      va_start_int(alist);
 
373
     {int r=99;
 
374
      fprintf(out,"int f(void):");
 
375
      fflush(out);
 
376
      va_return_int(alist, r);
 
377
    }}
 
378
  else if (current_function == (void*)&i_i)
 
379
    {
 
380
      va_start_int(alist);
 
381
     {int a = va_arg_int(alist);
 
382
      int r=a+1;
 
383
      fprintf(out,"int f(int):(%d)",a);
 
384
      fflush(out);
 
385
      va_return_int(alist, r);
 
386
    }}
 
387
  else if (current_function == (void*)&i_i2)
 
388
    {
 
389
      va_start_int(alist);
 
390
     {int a = va_arg_int(alist);
 
391
      int b = va_arg_int(alist);
 
392
      int r=a+b;
 
393
      fprintf(out,"int f(2*int):(%d,%d)",a,b);
 
394
      fflush(out);
 
395
      va_return_int(alist, r);
 
396
    }}
 
397
  else if (current_function == (void*)&i_i4)
 
398
    {
 
399
      va_start_int(alist);
 
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);
 
404
      int r=a+b+c+d;
 
405
      fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d);
 
406
      fflush(out);
 
407
      va_return_int(alist, r);
 
408
    }}
 
409
  else if (current_function == (void*)&i_i8)
 
410
    {
 
411
      va_start_int(alist);
 
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);
 
422
      fflush(out);
 
423
      va_return_int(alist, r);
 
424
    }}
 
425
  else if (current_function == (void*)&i_i16)
 
426
    {
 
427
      va_start_int(alist);
 
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);
 
447
      fflush(out);
 
448
      va_return_int(alist, r);
 
449
    }}
 
450
 
 
451
  /* float tests */
 
452
  else if (current_function == (void*)&f_f)
 
453
    {
 
454
      va_start_float(alist);
 
455
     {float a = va_arg_float(alist);
 
456
      float r=a+1.0;
 
457
      fprintf(out,"float f(float):(%g)",a);
 
458
      fflush(out);
 
459
      va_return_float(alist, r);
 
460
    }}
 
461
  else if (current_function == (void*)&f_f2)
 
462
    {
 
463
      va_start_float(alist);
 
464
     {float a = va_arg_float(alist);
 
465
      float b = va_arg_float(alist);
 
466
      float r=a+b;
 
467
      fprintf(out,"float f(2*float):(%g,%g)",a,b);
 
468
      fflush(out);
 
469
      va_return_float(alist, r);
 
470
    }}
 
471
  else if (current_function == (void*)&f_f4)
 
472
    {
 
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);
 
478
      float r=a+b+c+d;
 
479
      fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d);
 
480
      fflush(out);
 
481
      va_return_float(alist, r);
 
482
    }}
 
483
  else if (current_function == (void*)&f_f8)
 
484
    {
 
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);
 
496
      fflush(out);
 
497
      va_return_float(alist, r);
 
498
    }}
 
499
  else if (current_function == (void*)&f_f16)
 
500
    {
 
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);
 
520
      fflush(out);
 
521
      va_return_float(alist, r);
 
522
    }}
 
523
 
 
524
  /* double tests */
 
525
  else if (current_function == (void*)&d_d)
 
526
    {
 
527
      va_start_double(alist);
 
528
     {double a = va_arg_double(alist);
 
529
      double r=a+1.0;
 
530
      fprintf(out,"double f(double):(%g)",a);
 
531
      fflush(out);
 
532
      va_return_double(alist, r);
 
533
    }}
 
534
  else if (current_function == (void*)&d_d2)
 
535
    {
 
536
      va_start_double(alist);
 
537
     {double a = va_arg_double(alist);
 
538
      double b = va_arg_double(alist);
 
539
      double r=a+b;
 
540
      fprintf(out,"double f(2*double):(%g,%g)",a,b);
 
541
      fflush(out);
 
542
      va_return_double(alist, r);
 
543
    }}
 
544
  else if (current_function == (void*)&d_d4)
 
545
    {
 
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);
 
551
      double r=a+b+c+d;
 
552
      fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d);
 
553
      fflush(out);
 
554
      va_return_double(alist, r);
 
555
    }}
 
556
  else if (current_function == (void*)&d_d8)
 
557
    {
 
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);
 
569
      fflush(out);
 
570
      va_return_double(alist, r);
 
571
    }}
 
572
  else if (current_function == (void*)&d_d16)
 
573
    {
 
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);
 
593
      fflush(out);
 
594
      va_return_double(alist, r);
 
595
    }}
 
596
 
 
597
  /* pointer tests */
 
598
  else if (current_function == (void*)&vp_vpdpcpsp)
 
599
    {
 
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);
 
607
      fflush(out);
 
608
      va_return_ptr(alist, void*, ret);
 
609
    }}
 
610
 
 
611
  /* mixed number tests */
 
612
  else if (current_function == (void*)&uc_ucsil)
 
613
    {
 
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);
 
619
      uchar r = (uchar)-1;
 
620
      fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%lu)",a,b,c,d);
 
621
      fflush(out);
 
622
      va_return_uchar(alist, r);
 
623
    }}
 
624
  else if (current_function == (void*)&d_iidd)
 
625
    {
 
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);
 
631
      double r=a+b+c+d;
 
632
      fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d);
 
633
      fflush(out);
 
634
      va_return_double(alist, r);
 
635
    }}
 
636
  else if (current_function == (void*)&d_idid)
 
637
    {
 
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);
 
643
      double r=a+b+c+d;
 
644
      fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d);
 
645
      fflush(out);
 
646
      va_return_double(alist, r);
 
647
    }}
 
648
  else if (current_function == (void*)&us_cdcd)
 
649
    {
 
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);
 
657
      fflush(out);
 
658
      va_return_ushort(alist, r);
 
659
    }}
 
660
#ifdef HAVE_LONG_LONG_INT
 
661
  else if (current_function == (void*)&ll_flli)
 
662
    {
 
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);
 
669
      fflush(out);
 
670
      va_return_longlong(alist, r);
 
671
    }}
 
672
#endif
 
673
 
 
674
#ifndef SKIP_STRUCTS
 
675
  /* structure tests */
 
676
  else if (current_function == (void*)&I_III)
 
677
    {
 
678
      Int a;
 
679
      Int b;
 
680
      Int c;
 
681
      Int r;
 
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);
 
688
      fflush(out);
 
689
      va_return_struct(alist, Int, r);
 
690
    }
 
691
#ifndef SKIP_EXTRA_STRUCTS
 
692
  else if (current_function == (void*)&C_CdC)
 
693
    {
 
694
      Char a;
 
695
      double b;
 
696
      Char c;
 
697
      Char r;
 
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);
 
702
      r.x = (a.x + c.x)/2;
 
703
      fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x);
 
704
      fflush(out);
 
705
      va_return_struct(alist, Char, r);
 
706
    }
 
707
  else if (current_function == (void*)&F_Ffd)
 
708
    {
 
709
      Float a;
 
710
      float b;
 
711
      double c;
 
712
      Float r;
 
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);
 
717
      r.x = a.x + b + c;
 
718
      fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c);
 
719
      fflush(out);
 
720
      va_return_struct(alist, Float, r);
 
721
    }
 
722
  else if (current_function == (void*)&D_fDd)
 
723
    {
 
724
      float a;
 
725
      Double b;
 
726
      double c;
 
727
      Double r;
 
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);
 
732
      r.x = a + b.x + c;
 
733
      fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c);
 
734
      fflush(out);
 
735
      va_return_struct(alist, Double, r);
 
736
    }
 
737
#endif
 
738
  else if (current_function == (void*)&J_JiJ)
 
739
    {
 
740
      J a;
 
741
      int b;
 
742
      J c;
 
743
      J r;
 
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);
 
750
      fflush(out);
 
751
      va_return_struct(alist, J, r);
 
752
    }
 
753
#ifndef SKIP_EXTRA_STRUCTS
 
754
  else if (current_function == (void*)&T_TcT)
 
755
    {
 
756
      T a;
 
757
      char b;
 
758
      T c;
 
759
      T r;
 
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]);
 
766
      fflush(out);
 
767
      va_return_struct(alist, T, r);
 
768
    }
 
769
  else if (current_function == (void*)&X_BcdB)
 
770
    {
 
771
      B a;
 
772
      char b;
 
773
      double c;
 
774
      B d;
 
775
      static X xr={"return val",'R'};
 
776
      X 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);
 
782
      r = xr;
 
783
      r.c1 = 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]);
 
786
      fflush(out);
 
787
      va_return_struct(alist, X, r);
 
788
    }
 
789
#endif
 
790
#endif
 
791
 
 
792
  else
 
793
    {
 
794
      fprintf(out,"simulate: unknown function\n");
 
795
      fflush(out);
 
796
    }
 
797
}
 
798
 
 
799
/*
 
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.
 
805
 */
 
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)
 
808
{ return 0; }
 
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,
 
811
                      float o, float p)
 
812
{ return 0.0; }
 
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,
 
815
                       double o, double p)
 
816
{ return 0.0; }
 
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);
 
823
  clear_traces_J();
 
824
}
 
825
 
 
826
int main (void)
 
827
{
 
828
  out = stdout;
 
829
 
 
830
  vacall_function = &simulator;
 
831
 
 
832
  /* void tests */
 
833
  v_v();
 
834
  clear_traces();
 
835
  current_function = (void*) &v_v; ((void (*) (void)) vacall) ();
 
836
 
 
837
  /* int tests */
 
838
  { int ir;
 
839
 
 
840
    ir = i_v();
 
841
    fprintf(out,"->%d\n",ir);
 
842
    fflush(out);
 
843
    ir = 0; clear_traces();
 
844
    current_function = (void*) &i_v; ir = ((int (*) (void)) vacall) ();
 
845
    fprintf(out,"->%d\n",ir);
 
846
    fflush(out);
 
847
 
 
848
    ir = i_i(i1);
 
849
    fprintf(out,"->%d\n",ir);
 
850
    fflush(out);
 
851
    ir = 0; clear_traces();
 
852
    current_function = (void*) &i_i; ir = ((int (*) (int)) vacall) (i1);
 
853
    fprintf(out,"->%d\n",ir);
 
854
    fflush(out);
 
855
 
 
856
    ir = i_i2(i1,i2);
 
857
    fprintf(out,"->%d\n",ir);
 
858
    fflush(out);
 
859
    ir = 0; clear_traces();
 
860
    current_function = (void*) &i_i2; ir = ((int (*) (int,int)) vacall) (i1,i2);
 
861
    fprintf(out,"->%d\n",ir);
 
862
    fflush(out);
 
863
 
 
864
    ir = i_i4(i1,i2,i3,i4);
 
865
    fprintf(out,"->%d\n",ir);
 
866
    fflush(out);
 
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);
 
870
    fflush(out);
 
871
 
 
872
    ir = i_i8(i1,i2,i3,i4,i5,i6,i7,i8);
 
873
    fprintf(out,"->%d\n",ir);
 
874
    fflush(out);
 
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);
 
878
    fflush(out);
 
879
 
 
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);
 
882
    fflush(out);
 
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);
 
886
    fflush(out);
 
887
  }
 
888
 
 
889
  /* float tests */
 
890
  { float fr;
 
891
 
 
892
    fr = f_f(f1);
 
893
    fprintf(out,"->%g\n",fr);
 
894
    fflush(out);
 
895
    fr = 0.0; clear_traces();
 
896
    current_function = (void*) &f_f; fr = ((float (*) (float)) vacall) (f1);
 
897
    fprintf(out,"->%g\n",fr);
 
898
    fflush(out);
 
899
 
 
900
    fr = f_f2(f1,f2);
 
901
    fprintf(out,"->%g\n",fr);
 
902
    fflush(out);
 
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);
 
906
    fflush(out);
 
907
 
 
908
    fr = f_f4(f1,f2,f3,f4);
 
909
    fprintf(out,"->%g\n",fr);
 
910
    fflush(out);
 
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);
 
914
    fflush(out);
 
915
 
 
916
    fr = f_f8(f1,f2,f3,f4,f5,f6,f7,f8);
 
917
    fprintf(out,"->%g\n",fr);
 
918
    fflush(out);
 
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);
 
922
    fflush(out);
 
923
 
 
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);
 
926
    fflush(out);
 
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);
 
930
    fflush(out);
 
931
  }
 
932
 
 
933
  /* double tests */
 
934
  { double dr;
 
935
 
 
936
    dr = d_d(d1);
 
937
    fprintf(out,"->%g\n",dr);
 
938
    fflush(out);
 
939
    dr = 0.0; clear_traces();
 
940
    current_function = (void*) &d_d; dr = ((double (*) (double)) vacall) (d1);
 
941
    fprintf(out,"->%g\n",dr);
 
942
    fflush(out);
 
943
 
 
944
    dr = d_d2(d1,d2);
 
945
    fprintf(out,"->%g\n",dr);
 
946
    fflush(out);
 
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);
 
950
    fflush(out);
 
951
 
 
952
    dr = d_d4(d1,d2,d3,d4);
 
953
    fprintf(out,"->%g\n",dr);
 
954
    fflush(out);
 
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);
 
958
    fflush(out);
 
959
 
 
960
    dr = d_d8(d1,d2,d3,d4,d5,d6,d7,d8);
 
961
    fprintf(out,"->%g\n",dr);
 
962
    fflush(out);
 
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);
 
966
    fflush(out);
 
967
 
 
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);
 
970
    fflush(out);
 
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);
 
974
    fflush(out);
 
975
  }
 
976
 
 
977
  /* pointer tests */
 
978
  { void* vpr;
 
979
 
 
980
    vpr = vp_vpdpcpsp(&uc1,&d2,str3,&I4);
 
981
    fprintf(out,"->0x%lx\n",(long)vpr);
 
982
    fflush(out);
 
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);
 
986
    fflush(out);
 
987
  }
 
988
 
 
989
  /* mixed number tests */
 
990
  { uchar ucr;
 
991
    ushort usr;
 
992
    double dr;
 
993
#ifdef HAVE_LONG_LONG_INT
 
994
    long long llr;
 
995
#endif
 
996
 
 
997
    ucr = uc_ucsil(uc1,us2,ui3,ul4);
 
998
    fprintf(out,"->%u\n",ucr);
 
999
    fflush(out);
 
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);
 
1003
    fflush(out);
 
1004
 
 
1005
    dr = d_iidd(i1,i2,d3,d4);
 
1006
    fprintf(out,"->%g\n",dr);
 
1007
    fflush(out);
 
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);
 
1011
    fflush(out);
 
1012
 
 
1013
    dr = d_idid(i1,d2,i3,d4);
 
1014
    fprintf(out,"->%g\n",dr);
 
1015
    fflush(out);
 
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);
 
1019
    fflush(out);
 
1020
 
 
1021
    usr = us_cdcd(c1,d2,c3,d4);
 
1022
    fprintf(out,"->%u\n",usr);
 
1023
    fflush(out);
 
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);
 
1027
    fflush(out);
 
1028
 
 
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));
 
1032
    fflush(out);
 
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));
 
1036
    fflush(out);
 
1037
#endif
 
1038
  }
 
1039
 
 
1040
#ifndef SKIP_STRUCTS
 
1041
  /* structure tests */
 
1042
  { Int Ir;
 
1043
    Char Cr;
 
1044
    Float Fr;
 
1045
    Double Dr;
 
1046
    J Jr;
 
1047
    T Tr;
 
1048
    X Xr;
 
1049
 
 
1050
    Ir = I_III(I1,I2,I3);
 
1051
    fprintf(out,"->{%d}\n",Ir.x);
 
1052
    fflush(out);
 
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);
 
1056
    fflush(out);
 
1057
 
 
1058
#ifndef SKIP_EXTRA_STRUCTS
 
1059
    Cr = C_CdC(C1,d2,C3);
 
1060
    fprintf(out,"->{'%c'}\n",Cr.x);
 
1061
    fflush(out);
 
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);
 
1065
    fflush(out);
 
1066
 
 
1067
    Fr = F_Ffd(F1,f2,d3);
 
1068
    fprintf(out,"->{%g}\n",Fr.x);
 
1069
    fflush(out);
 
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);
 
1073
    fflush(out);
 
1074
 
 
1075
    Dr = D_fDd(f1,D2,d3);
 
1076
    fprintf(out,"->{%g}\n",Dr.x);
 
1077
    fflush(out);
 
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);
 
1081
    fflush(out);
 
1082
#endif
 
1083
 
 
1084
    Jr = J_JiJ(J1,i2,J2);
 
1085
    fprintf(out,"->{%ld,%ld}\n",Jr.l1,Jr.l2);
 
1086
    fflush(out);
 
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);
 
1090
    fflush(out);
 
1091
 
 
1092
#ifndef SKIP_EXTRA_STRUCTS
 
1093
#ifndef SKIP_T
 
1094
    Tr = T_TcT(T1,' ',T2);
 
1095
    fprintf(out,"->{\"%c%c%c\"}\n",Tr.c[0],Tr.c[1],Tr.c[2]);
 
1096
    fflush(out);
 
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]);
 
1100
    fflush(out);
 
1101
#endif
 
1102
 
 
1103
#ifndef SKIP_X
 
1104
    Xr = X_BcdB(B1,c2,d3,B2);
 
1105
    fprintf(out,"->{\"%s\",'%c'}\n",Xr.c,Xr.c1);
 
1106
    fflush(out);
 
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);
 
1110
    fflush(out);
 
1111
#endif
 
1112
#endif
 
1113
  }
 
1114
#endif
 
1115
 
 
1116
  exit(0);
 
1117
}