tests.c
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:21k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. #ifndef _tests_c /*-*- C -*-*/
  2. #define _tests_c
  3. /**
  4.   Copyright 1993 Bill Triggs, <Bill.Triggs@inrialpes.fr>
  5.   This is free software distributed under the GNU General Public
  6.   Licence described in the file COPYING. Contact the author if
  7.   you don't have this or can't live with it. There is ABSOLUTELY
  8.   NO WARRANTY, explicit or implied, on this software.
  9. **/
  10. /*----------------------------------------------------------------------
  11.   Some test routines for avcall foreign function interface.
  12.   The coverage is entirely random, this just contains some of the things
  13.   that I think are likely to break.
  14.   We really need to add some more pointer (void* / char* / func*) tests
  15.   and some varargs ones, and also try to test structure alignment more
  16.   throughly.
  17.  ----------------------------------------------------------------------*/
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "avcall.h"
  21. FILE* out;
  22. /* NB since K&R C always passes chars and shorts as ints and floats as doubles,
  23.  * unprototyped ANSI-C functions must do the same, eg:
  24.  * - foo(x) float x; { ... } passes x as a double & converts it to a float internally.
  25.  * - foo(float x) { ... } passes x as a float.
  26.  */
  27. #if defined(__STDC__) || defined(__GNUC__) || defined(__cplusplus)
  28. #define _ ,
  29. #define _P(ARGS,TYPES) (TYPES)
  30. #else
  31. #define _ ;
  32. #define _P(ARGS,TYPES) ARGS TYPES;
  33. #endif
  34. #if defined(__hppa__) && defined(__GNUC__)
  35. #if (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
  36. /* gcc-2.5.2 bugs prevent the T test from working. */
  37. #define SKIP_T
  38. #endif
  39. #endif
  40. #if defined(__m68k__) && defined(__GNUC__)
  41. /* "gcc-2.6.3 -freg-struct-return" returns  T = struct { char c[3]; }  (which
  42.  * has size 4 !) in memory, in contrast to  struct { char a,b,c; }  and
  43.  * struct { char c[4]; }  and  struct { char a,b,c,d; }  which have the same
  44.  * size and the same alignment but are returned in registers. I don't know why.
  45.  */
  46. #define SKIP_T
  47. #endif
  48. #if defined(AMIGA)
  49. /* We don't test passing arguments in registers yet.
  50.  * -1 means passing an argument in the stack instead of a register.
  51.  */
  52. #define AV_ARG_REGNUM -1
  53. #endif
  54. #define uchar unsigned char
  55. #define ushort unsigned short
  56. #define uint unsigned int
  57. #define ulong unsigned long
  58. typedef struct { char x; } Char;
  59. typedef struct { short x; } Short;
  60. typedef struct { int x; } Int;
  61. typedef struct { long x; } Long;
  62. typedef struct { float x; } Float;
  63. typedef struct { double x; } Double;
  64. typedef struct { char c; float f; } A;
  65. typedef struct { double d; int i[3]; } B;
  66. typedef struct { long l1; long l2; } J;
  67. typedef struct { char c[3]; } T;
  68. typedef struct { char c[33],c1; } X;
  69. char c1='a', c2=127, c3=(char)128, c4=(char)255, c5=-1;
  70. short s1=32767, s2=(short)32768, s3=3, s4=4, s5=5, s6=6, s7=7, s8=8, s9=9;
  71. int i1=1, i2=2, i3=3, i4=4, i5=5, i6=6, i7=7, i8=8, i9=9,
  72.     i10=11, i11=12, i12=13, i13=14, i14=15, i15=16, i16=17;
  73. long l1=1, l2=2, l3=3, l4=4, l5=5, l6=6, l7=7, l8=8, l9=9;
  74. #ifdef HAVE_LONGLONG
  75. long long ll1 = 3875056143130689530LL;
  76. #endif
  77. 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,
  78.       f10=1.1, f11=1.2, f12=1.3, f13=1.4, f14=1.5, f15=1.6, f16=1.7;
  79. 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,
  80.        d10=1.1, d11=1.2, d12=1.3, d13=1.4, d14=1.5, d15=1.6, d16=1.7;
  81. uchar uc1='a', uc2=127, uc3=128, uc4=255, uc5=-1;
  82. ushort us1=1, us2=2, us3=3, us4=4, us5=5, us6=6, us7=7, us8=8, us9=9;
  83. uint ui1=1, ui2=2, ui3=3, ui4=4, ui5=5, ui6=6, ui7=7, ui8=8, ui9=9;
  84. ulong ul1=1, ul2=2, ul3=3, ul4=4, ul5=5, ul6=6, ul7=7, ul8=8, ul9=9;
  85. char *str1="hello",str2[]="goodbye",*str3="still here?";
  86. Char C1={'A'}, C2={'B'}, C3={'C'}, C4={'377'}, C5={-1};
  87. Short S1={1}, S2={2}, S3={3}, S4={4}, S5={5}, S6={6}, S7={7}, S8={8}, S9={9};
  88. Int I1={1}, I2={2}, I3={3}, I4={4}, I5={5}, I6={6}, I7={7}, I8={8}, I9={9};
  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. 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};
  91. A A1={'a',0.1},A2={'b',0.2},A3={'377',0.3};
  92. B B1={0.1,{1,2,3}},B2={0.2,{5,4,3}};
  93. J J1={47,11},J2={73,55};
  94. T T1={"the"},T2={"fox"};
  95. X X1={"abcdefghijklmnopqrstuvwxyzABCDEF",'G'}, X2={"123",'9'}, X3={"return-return-return",'R'};
  96. void v_v()
  97. {
  98.   fprintf(out,"void f(void):n");
  99.   fflush(out);
  100. }
  101. int i_v()
  102. {
  103.   int r=99;
  104.   fprintf(out,"int f(void):");
  105.   fflush(out);
  106.   return r;
  107. }
  108. int i_i _P((a), int a)
  109. {
  110.   int r=a+1;
  111.   fprintf(out,"int f(int):(%d)",a);
  112.   fflush(out);
  113.   return r;
  114. }
  115. int i_i2 _P((a,b), int a _ int b)
  116. {
  117.   int r=a+b;
  118.   fprintf(out,"int f(2*int):(%d,%d)",a,b);
  119.   fflush(out);
  120.   return r;
  121. }
  122. int i_i4 _P((a,b,c,d), int a _ int b _ int c _ int d)
  123. {
  124.   int r=a+b+c+d;
  125.   fprintf(out,"int f(4*int):(%d,%d,%d,%d)",a,b,c,d);
  126.   fflush(out);
  127.   return r;
  128. }
  129. int i_i8 _P((a,b,c,d,e,f,g,h),
  130.     int a _ int b _ int c _ int d _ int e _ int f _ int g _ int h)
  131. {
  132.   int r=a+b+c+d+e+f+g+h;
  133.   fprintf(out,"int f(8*int):(%d,%d,%d,%d,%d,%d,%d,%d)",a,b,c,d,e,f,g,h);
  134.   fflush(out);
  135.   return r;
  136. }
  137. int i_i16 _P((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p),
  138.      int a _ int b _ int c _ int d _ int e _ int f _ int g _ int h
  139.      _ int i _ int j _ int k _ int l _ int m _ int n _ int o _ int p)
  140. {
  141.   int r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
  142.   fprintf(out,"int f(16*int):(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)",
  143.   a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p);
  144.   fflush(out);
  145.   return r;
  146. }
  147. float f_f _P((a), float a)
  148. {
  149.   float r=a+1.0;
  150.   fprintf(out,"float f(float):(%g)",a);
  151.   fflush(out);
  152.   return r;
  153. }
  154. float f_f2 _P((a,b), float a _ float b)
  155. {
  156.   float r=a+b;
  157.   fprintf(out,"float f(2*float):(%g,%g)",a,b);
  158.   fflush(out);
  159.   return r;
  160. }
  161. float f_f4 _P((a,b,c,d), float a _ float b _ float c _ float d)
  162. {
  163.   float r=a+b+c+d;
  164.   fprintf(out,"float f(4*float):(%g,%g,%g,%g)",a,b,c,d);
  165.   fflush(out);
  166.   return r;
  167. }
  168. float f_f8 _P((a,b,c,d,e,f,g,h), float a _ float b _ float c _ float d _ float e _ float f
  169.       _ float g _ float h)
  170. {
  171.   float r=a+b+c+d+e+f+g+h;
  172.   fprintf(out,"float f(8*float):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
  173.   fflush(out);
  174.   return r;
  175. }
  176. float f_f16 _P((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p),
  177.        float a _ float b _ float c _ float d _ float e _ float f _ float g _ float h
  178.        _ float i _ float j _ float k _ float l _ float m _ float n _ float o _ float p)
  179. {
  180.   float r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
  181.   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);
  182.   fflush(out);
  183.   return r;
  184. }
  185. double d_d _P((a), double a)
  186. {
  187.   double r=a+1.0;
  188.   fprintf(out,"double f(double):(%g)",a);
  189.   fflush(out);
  190.   return r;
  191. }
  192. double d_d2 _P((a,b), double a _ double b)
  193. {
  194.   double r=a+b;
  195.   fprintf(out,"double f(2*double):(%g,%g)",a,b);
  196.   fflush(out);
  197.   return r;
  198. }
  199. double d_d4 _P((a,b,c,d), double a _ double b _ double c _ double d)
  200. {
  201.   double r=a+b+c+d;
  202.   fprintf(out,"double f(4*double):(%g,%g,%g,%g)",a,b,c,d);
  203.   fflush(out);
  204.   return r;
  205. }
  206. double d_d8 _P((a,b,c,d,e,f,g,h),
  207.        double a _ double b _ double c _ double d _ double e _ double f
  208.        _ double g _ double h)
  209. {
  210.   double r=a+b+c+d+e+f+g+h;
  211.   fprintf(out,"double f(8*double):(%g,%g,%g,%g,%g,%g,%g,%g)",a,b,c,d,e,f,g,h);
  212.   fflush(out);
  213.   return r;
  214. }
  215. double d_d16 _P((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p),
  216. double a _ double b _ double c _ double d _ double e _ double f
  217. _ double g _ double h _ double i _ double j _ double k _ double l
  218. _ double m _ double n _ double o _ double p)
  219. {
  220.   double r=a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p;
  221.   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);
  222.   fflush(out);
  223.   return r;
  224. }
  225. void* vp_vpdpcpsp _P((a,b,c,d), void* a _ double* b _ char* c _ Int* d)
  226. {
  227.   void* ret = (char*)b + 1;
  228.   fprintf(out,"void* f(void*,double*,char*,Int*):(0x%lx,0x%lx,0x%lx,0x%lx)",(long)a,(long)b,(long)c,(long)d);
  229.   fflush(out);
  230.   return ret;
  231. }
  232. uchar uc_ucsil _P((a,b,c,d), uchar a _ ushort b _ uint c _ ulong d)
  233. {
  234.   uchar r = -1;
  235.   fprintf(out,"uchar f(uchar,ushort,uint,ulong):(%u,%u,%u,%u)",a,b,c,d);
  236.   fflush(out);
  237.   return r;
  238. }
  239. double d_iidd _P((a,b,c,d), int a _ int b _ double c _ double d)
  240. {
  241.   double r = a+b+c+d;
  242.   fprintf(out,"double f(int,int,double,double):(%d,%d,%g,%g)",a,b,c,d);
  243.   fflush(out);
  244.   return r;
  245. }
  246. double d_idid _P((a,b,c,d), int a _ double b _ int c _ double d)
  247. {
  248.   double r = a+b+c+d;
  249.   fprintf(out,"double f(int,double,int,double):(%d,%g,%d,%g)",a,b,c,d);
  250.   fflush(out);
  251.   return r;
  252. }
  253. ushort us_cdcd _P((a,b,c,d), char a _ double b _ char c _ double d)
  254. {
  255.   ushort r = (ushort)(a + b + c + d);
  256.   fprintf(out,"ushort f(char,double,char,double):('%c',%g,'%c',%g)",a,b,c,d);
  257.   fflush(out);
  258.   return r;
  259. }
  260. #ifdef HAVE_LONGLONG
  261. long long ll_flli _P((a,b,c), float a _ long long b _ int c)
  262. {
  263.   long long r = (long long)(int)a + b + (long long)c;
  264.   fprintf(out,"long long f(float,long long,int):(%g,0x%lx%08lx,0x%lx)",a,(long)(b>>32),(long)(b&0xffffffff),(long)c);
  265.   fflush(out);
  266.   return r;
  267. }
  268. #endif
  269. Int I_III _P((a,b,c), Int a _ Int b _ Int c)
  270. {
  271.   Int r;
  272.   r.x = a.x + b.x + c.x;
  273.   fprintf(out,"Int f(Int,Int,Int):({%d},{%d},{%d})",a.x,b.x,c.x);
  274.   fflush(out);
  275.   return r;
  276. }
  277. #ifndef SKIP_EXTRA_STRUCTS
  278. Char C_CdC _P((a,b,c), Char a _ double b _ Char c)
  279. {
  280.   Char r;
  281.   r.x = (a.x + c.x)/2;
  282.   fprintf(out,"Char f(Char,double,Char):({'%c'},%g,{'%c'})",a.x,b,c.x);
  283.   fflush(out);
  284.   return r;
  285. }
  286. Float F_Ffd _P((a,b,c), Float a _ float b _ double c)
  287. {
  288.   Float r;
  289.   r.x = a.x + b + c;
  290.   fprintf(out,"Float f(Float,float,double):({%g},%g,%g)",a.x,b,c);
  291.   fflush(out);
  292.   return r;
  293. }
  294. Double D_fDd _P((a,b,c), float a _ Double b _ double c)
  295. {
  296.   Double r;
  297.   r.x = a + b.x + c;
  298.   fprintf(out,"Double f(float,Double,double):(%g,{%g},%g)",a,b.x,c);
  299.   fflush(out);
  300.   return r;
  301. }
  302. #endif
  303. J J_JiJ _P((a,b,c), J a _ int b _ J c)
  304. {
  305.   J r;
  306.   r.l1 = a.l1+c.l1; r.l2 = a.l2+b+c.l2;
  307.   fprintf(out,"J f(J,int,J):({%d,%d},%d,{%d,%d})",a.l1,a.l2,b,c.l1,c.l2);
  308.   fflush(out);
  309.   return r;
  310. }
  311. #ifndef SKIP_EXTRA_STRUCTS
  312. T T_TcT _P((a,b,c), T a _ char b _ T c)
  313. {
  314.   T r;
  315.   r.c[0]='b'; r.c[1]=c.c[1]; r.c[2]=c.c[2];
  316.   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]);
  317.   fflush(out);
  318.   return r;
  319. }
  320. X X_BcdB _P((a,b,c,d), B a _ char b _ double c _ B d)
  321. {
  322.   static X xr={"return val",'R'};
  323.   X r;
  324.   r = xr;
  325.   r.c1 = b;
  326.   fprintf(out,"X f(B,char,double,B):({%g,{%d,%d,%d}},'%c',%g,{%g,{%d,%d,%d}})",
  327.   a.d,a.i[0],a.i[1],a.i[2],b,c,d.d,d.i[0],d.i[1],d.i[2]);
  328.   fflush(out);
  329.   return r;
  330. }
  331. #endif
  332. /*
  333.  * The way we run these tests - first call the function directly, then
  334.  * through av_call() - there is the danger that arguments or results seem
  335.  * to be passed correctly, but what we are seeing are in fact the vestiges
  336.  * (traces) or the previous call. This may seriously fake the test.
  337.  * Avoid this by clearing the registers between the first and the second call.
  338.  */
  339. long clear_traces_i _P((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p),
  340.   long a _ long b _ long c _ long d _ long e _ long f _ long g _ long h _
  341.   long i _ long j _ long k _ long l _ long m _ long n _ long o _ long p)
  342. { return 0; }
  343. float clear_traces_f _P((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p),
  344.   float a _ float b _ float c _ float d _ float e _ float f _ float g _
  345.   float h _ float i _ float j _ float k _ float l _ float m _ float n _
  346.   float o _ float p)
  347. { return 0.0; }
  348. double clear_traces_d _P((a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p),
  349.   double a _ double b _ double c _ double d _ double e _ double f _ double g _
  350.   double h _ double i _ double j _ double k _ double l _ double m _ double n _
  351.   double o _ double p)
  352. { return 0.0; }
  353. J clear_traces_J ()
  354. { J j; j.l1 = j.l2 = 0; return j; }
  355. void clear_traces()
  356. { clear_traces_i(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  357.   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);
  358.   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);
  359.   clear_traces_J();
  360. }
  361. void
  362.   void_tests()
  363. {
  364.   av_alist a;
  365.   v_v();
  366.   clear_traces();
  367.   av_start_void(a,v_v);
  368.   av_call(a);
  369.   return;
  370. }
  371. void
  372.   int_tests()
  373. {
  374.   av_alist a;
  375.   int ir;
  376.   ir = i_v();
  377.   fprintf(out,"->%dn",ir);
  378.   fflush(out);
  379.   ir = 0; clear_traces();
  380.   av_start_int(a,i_v,&ir);
  381.   av_call(a);
  382.   fprintf(out,"->%dn",ir);
  383.   fflush(out);
  384.   ir = i_i(i1);
  385.   fprintf(out,"->%dn",ir);
  386.   fflush(out);
  387.   ir = 0; clear_traces();
  388.   av_start_int(a,i_i,&ir);
  389.   av_int(a,i1);
  390.   av_call(a);
  391.   fprintf(out,"->%dn",ir);
  392.   fflush(out);
  393.   ir = i_i2(i1,i2);
  394.   fprintf(out,"->%dn",ir);
  395.   fflush(out);
  396.   ir = 0; clear_traces();
  397.   av_start_int(a,i_i2,&ir);
  398.   av_int(a,i1);
  399.   av_int(a,i2);
  400.   av_call(a);
  401.   fprintf(out,"->%dn",ir);
  402.   fflush(out);
  403.   ir = i_i4(i1,i2,i3,i4);
  404.   fprintf(out,"->%dn",ir);
  405.   fflush(out);
  406.   ir = 0; clear_traces();
  407.   av_start_int(a,i_i4,&ir);
  408.   av_int(a,i1);
  409.   av_int(a,i2);
  410.   av_int(a,i3);
  411.   av_int(a,i4);
  412.   av_call(a);
  413.   fprintf(out,"->%dn",ir);
  414.   fflush(out);
  415.   ir = i_i8(i1,i2,i3,i4,i5,i6,i7,i8);
  416.   fprintf(out,"->%dn",ir);
  417.   fflush(out);
  418.   ir = 0; clear_traces();
  419.   av_start_int(a,i_i8,&ir);
  420.   av_int(a,i1);
  421.   av_int(a,i2);
  422.   av_int(a,i3);
  423.   av_int(a,i4);
  424.   av_int(a,i5);
  425.   av_int(a,i6);
  426.   av_int(a,i7);
  427.   av_int(a,i8);
  428.   av_call(a);
  429.   fprintf(out,"->%dn",ir);
  430.   fflush(out);
  431.   ir = i_i16(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14,i15,i16);
  432.   fprintf(out,"->%dn",ir);
  433.   fflush(out);
  434.   ir = 0; clear_traces();
  435.   av_start_int(a,i_i16,&ir);
  436.   av_int(a,i1);
  437.   av_int(a,i2);
  438.   av_int(a,i3);
  439.   av_int(a,i4);
  440.   av_int(a,i5);
  441.   av_int(a,i6);
  442.   av_int(a,i7);
  443.   av_int(a,i8);
  444.   av_int(a,i9);
  445.   av_int(a,i10);
  446.   av_int(a,i11);
  447.   av_int(a,i12);
  448.   av_int(a,i13);
  449.   av_int(a,i14);
  450.   av_int(a,i15);
  451.   av_int(a,i16);
  452.   av_call(a);
  453.   fprintf(out,"->%dn",ir);
  454.   fflush(out);
  455.   return;
  456. }
  457. void
  458.   float_tests()
  459. {
  460.   av_alist a;
  461.   float fr;
  462.   fr = f_f(f1);
  463.   fprintf(out,"->%gn",fr);
  464.   fflush(out);
  465.   fr = 0.0; clear_traces();
  466.   av_start_float(a,f_f,&fr);
  467.   av_float(a,f1);
  468.   av_call(a);
  469.   fprintf(out,"->%gn",fr);
  470.   fflush(out);
  471.   fr = f_f2(f1,f2);
  472.   fprintf(out,"->%gn",fr);
  473.   fflush(out);
  474.   fr = 0.0; clear_traces();
  475.   av_start_float(a,f_f2,&fr);
  476.   av_float(a,f1);
  477.   av_float(a,f2);
  478.   av_call(a);
  479.   fprintf(out,"->%gn",fr);
  480.   fflush(out);
  481.   fr = f_f4(f1,f2,f3,f4);
  482.   fprintf(out,"->%gn",fr);
  483.   fflush(out);
  484.   fr = 0.0; clear_traces();
  485.   av_start_float(a,f_f4,&fr);
  486.   av_float(a,f1);
  487.   av_float(a,f2);
  488.   av_float(a,f3);
  489.   av_float(a,f4);
  490.   av_call(a);
  491.   fprintf(out,"->%gn",fr);
  492.   fflush(out);
  493.   fr = f_f8(f1,f2,f3,f4,f5,f6,f7,f8);
  494.   fprintf(out,"->%gn",fr);
  495.   fflush(out);
  496.   fr = 0.0; clear_traces();
  497.   av_start_float(a,f_f8,&fr);
  498.   av_float(a,f1);
  499.   av_float(a,f2);
  500.   av_float(a,f3);
  501.   av_float(a,f4);
  502.   av_float(a,f5);
  503.   av_float(a,f6);
  504.   av_float(a,f7);
  505.   av_float(a,f8);
  506.   av_call(a);
  507.   fprintf(out,"->%gn",fr);
  508.   fflush(out);
  509.   fr = f_f16(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14,f15,f16);
  510.   fprintf(out,"->%gn",fr);
  511.   fflush(out);
  512.   fr = 0.0; clear_traces();
  513.   av_start_float(a,f_f16,&fr);
  514.   av_float(a,f1);
  515.   av_float(a,f2);
  516.   av_float(a,f3);
  517.   av_float(a,f4);
  518.   av_float(a,f5);
  519.   av_float(a,f6);
  520.   av_float(a,f7);
  521.   av_float(a,f8);
  522.   av_float(a,f9);
  523.   av_float(a,f10);
  524.   av_float(a,f11);
  525.   av_float(a,f12);
  526.   av_float(a,f13);
  527.   av_float(a,f14);
  528.   av_float(a,f15);
  529.   av_float(a,f16);
  530.   av_call(a);
  531.   fprintf(out,"->%gn",fr);
  532.   fflush(out);
  533. }
  534. void
  535.   double_tests()
  536. {
  537.   av_alist a;
  538.   double dr;
  539.   dr = d_d(d1);
  540.   fprintf(out,"->%gn",dr);
  541.   fflush(out);
  542.   dr = 0.0; clear_traces();
  543.   av_start_double(a,d_d,&dr);
  544.   av_double(a,d1);
  545.   av_call(a);
  546.   fprintf(out,"->%gn",dr);
  547.   fflush(out);
  548.   dr = d_d2(d1,d2);
  549.   fprintf(out,"->%gn",dr);
  550.   fflush(out);
  551.   dr = 0.0; clear_traces();
  552.   av_start_double(a,d_d2,&dr);
  553.   av_double(a,d1);
  554.   av_double(a,d2);
  555.   av_call(a);
  556.   fprintf(out,"->%gn",dr);
  557.   fflush(out);
  558.   dr = d_d4(d1,d2,d3,d4);
  559.   fprintf(out,"->%gn",dr);
  560.   fflush(out);
  561.   dr = 0.0; clear_traces();
  562.   av_start_double(a,d_d4,&dr);
  563.   av_double(a,d1);
  564.   av_double(a,d2);
  565.   av_double(a,d3);
  566.   av_double(a,d4);
  567.   av_call(a);
  568.   fprintf(out,"->%gn",dr);
  569.   fflush(out);
  570.   dr = d_d8(d1,d2,d3,d4,d5,d6,d7,d8);
  571.   fprintf(out,"->%gn",dr);
  572.   fflush(out);
  573.   dr = 0.0; clear_traces();
  574.   av_start_double(a,d_d8,&dr);
  575.   av_double(a,d1);
  576.   av_double(a,d2);
  577.   av_double(a,d3);
  578.   av_double(a,d4);
  579.   av_double(a,d5);
  580.   av_double(a,d6);
  581.   av_double(a,d7);
  582.   av_double(a,d8);
  583.   av_call(a);
  584.   fprintf(out,"->%gn",dr);
  585.   fflush(out);
  586.   dr = d_d16(d1,d2,d3,d4,d5,d6,d7,d8,d9,d10,d11,d12,d13,d14,d15,d16);
  587.   fprintf(out,"->%gn",dr);
  588.   fflush(out);
  589.   dr = 0.0; clear_traces();
  590.   av_start_double(a,d_d16,&dr);
  591.   av_double(a,d1);
  592.   av_double(a,d2);
  593.   av_double(a,d3);
  594.   av_double(a,d4);
  595.   av_double(a,d5);
  596.   av_double(a,d6);
  597.   av_double(a,d7);
  598.   av_double(a,d8);
  599.   av_double(a,d9);
  600.   av_double(a,d10);
  601.   av_double(a,d11);
  602.   av_double(a,d12);
  603.   av_double(a,d13);
  604.   av_double(a,d14);
  605.   av_double(a,d15);
  606.   av_double(a,d16);
  607.   av_call(a);
  608.   fprintf(out,"->%gn",dr);
  609.   fflush(out);
  610.   return;
  611. }
  612. void
  613.   mixed_number_tests()
  614. {
  615.   av_alist a;
  616.   uchar ucr;
  617.   ushort usr;
  618.   double dr;
  619. #ifdef HAVE_LONGLONG
  620.   long long llr;
  621. #endif
  622.   /* Unsigned types.
  623.    */
  624.   ucr = uc_ucsil(uc1,us2,ui3,ul4);
  625.   fprintf(out,"->%un",ucr);
  626.   fflush(out);
  627.   ucr = 0; clear_traces();
  628.   av_start_uchar(a,uc_ucsil,&ucr);
  629.   av_uchar(a,uc1);
  630.   av_ushort(a,us2);
  631.   av_uint(a,ui3);
  632.   av_ulong(a,ul4);
  633.   av_call(a);
  634.   fprintf(out,"->%un",ucr);
  635.   fflush(out);
  636.   /* Mixed int & float types.
  637.    */
  638.   dr = d_iidd(i1,i2,d3,d4);
  639.   fprintf(out,"->%gn",dr);
  640.   fflush(out);
  641.   dr = 0.0; clear_traces();
  642.   av_start_double(a,d_iidd,&dr);
  643.   av_int(a,i1);
  644.   av_int(a,i2);
  645.   av_double(a,d3);
  646.   av_double(a,d4);
  647.   av_call(a);
  648.   fprintf(out,"->%gn",dr);
  649.   fflush(out);
  650.   dr = d_idid(i1,d2,i3,d4);
  651.   fprintf(out,"->%gn",dr);
  652.   fflush(out);
  653.   dr = 0.0; clear_traces();
  654.   av_start_double(a,d_idid,&dr);
  655.   av_int(a,i1);
  656.   av_double(a,d2);
  657.   av_int(a,i3);
  658.   av_double(a,d4);
  659.   av_call(a);
  660.   fprintf(out,"->%gn",dr);
  661.   fflush(out);
  662.   usr = us_cdcd(c1,d2,c3,d4);
  663.   fprintf(out,"->%un",usr);
  664.   fflush(out);
  665.   usr = 0; clear_traces();
  666.   av_start_ushort(a,us_cdcd,&usr);
  667.   av_char(a,c1);
  668.   av_double(a,d2);
  669.   av_char(a,c3);
  670.   av_double(a,d4);
  671.   av_call(a);
  672.   fprintf(out,"->%un",usr);
  673.   fflush(out);
  674. #ifdef HAVE_LONGLONG
  675.   /* Long long types.
  676.    */
  677.   llr = ll_flli(f13,ll1,i13);
  678.   fprintf(out,"->0x%lx%08lxn",(long)(llr>>32),(long)(llr&0xffffffff));
  679.   fflush(out);
  680.   llr = 0; clear_traces();
  681.   av_start_longlong(a,ll_flli,&llr);
  682.   av_float(a,f13);
  683.   av_longlong(a,ll1);
  684.   av_int(a,i13);
  685.   av_call(a);
  686.   fprintf(out,"->0x%lx%08lxn",(long)(llr>>32),(long)(llr&0xffffffff));
  687.   fflush(out);
  688. #endif
  689.   return;
  690. }
  691. void
  692.   pointer_tests()
  693. {
  694.   av_alist a;
  695.   void* vpr;
  696.   vpr = vp_vpdpcpsp(&uc1,&d2,str3,&I4);
  697.   fprintf(out,"->0x%lxn",(long)vpr);
  698.   fflush(out);
  699.   vpr = 0; clear_traces();
  700.   av_start_ptr(a,vp_vpdpcpsp,void*,&vpr);
  701.   av_ptr(a,void*,&uc1);
  702.   av_ptr(a,double*,&d2);
  703.   av_ptr(a,char*,str3);
  704.   av_ptr(a,Int*,&I4);
  705.   av_call(a);
  706.   fprintf(out,"->0x%lxn",(long)vpr);
  707.   fflush(out);
  708.   return;
  709. }
  710. void
  711.   structure_tests()
  712. {
  713.   av_alist a;
  714.   Int Ir;
  715.   Char Cr;
  716.   Float Fr;
  717.   Double Dr;
  718.   J Jr;
  719.   T Tr;
  720.   X Xr;
  721.   Ir = I_III(I1,I2,I3);
  722.   fprintf(out,"->{%d}n",Ir.x);
  723.   fflush(out);
  724.   Ir.x = 0; clear_traces();
  725.   av_start_struct(a,I_III,Int,1,&Ir);
  726.   av_struct(a,Int,I1);
  727.   av_struct(a,Int,I2);
  728.   av_struct(a,Int,I3);
  729.   av_call(a);
  730.   fprintf(out,"->{%d}n",Ir.x);
  731.   fflush(out);
  732. #ifndef SKIP_EXTRA_STRUCTS
  733.   Cr = C_CdC(C1,d2,C3);
  734.   fprintf(out,"->{'%c'}n",Cr.x);
  735.   fflush(out);
  736.   Cr.x = ''; clear_traces();
  737.   av_start_struct(a,C_CdC,Char,1,&Cr);
  738.   av_struct(a,Char,C1);
  739.   av_double(a,d2);
  740.   av_struct(a,Char,C3);
  741.   av_call(a);
  742.   fprintf(out,"->{'%c'}n",Cr.x);
  743.   fflush(out);
  744. #if 0
  745.   Fr = F_Ffd(F1,f2,d3);
  746.   fprintf(out,"->{%g}n",Fr.x);
  747.   fflush(out);
  748.   Fr.x = 0.0; clear_traces();
  749.   av_start_struct(a,F_Ffd,Float,av_word_splittable_1(float),&Fr);
  750.   av_struct(a,Float,F1);
  751.   av_float(a,f2);
  752.   av_double(a,d3);
  753.   av_call(a);
  754.   fprintf(out,"->{%g}n",Fr.x);
  755.   fflush(out);
  756. #endif
  757.   
  758.   Dr = D_fDd(f1,D2,d3);
  759.   fprintf(out,"->{%g}n",Dr.x);
  760.   fflush(out);
  761.   Dr.x = 0.0; clear_traces();
  762.   av_start_struct(a,D_fDd,Double,av_word_splittable_1(double),&Dr);
  763.   av_float(a,f1);
  764.   av_struct(a,Double,D2);
  765.   av_double(a,d3);
  766.   av_call(a);
  767.   fprintf(out,"->{%g}n",Dr.x);
  768.   fflush(out);
  769. #endif
  770.   Jr = J_JiJ(J1,i2,J2);
  771.   fprintf(out,"->{%d,%d}n",Jr.l1,Jr.l2);
  772.   fflush(out);
  773.   Jr.l1 = Jr.l2 = 0; clear_traces();
  774.   av_start_struct(a,J_JiJ,J,av_word_splittable_2(long,long),&Jr);
  775.   av_struct(a,J,J1);
  776.   av_int(a,i2);
  777.   av_struct(a,J,J2);
  778.   av_call(a);
  779.   fprintf(out,"->{%d,%d}n",Jr.l1,Jr.l2);
  780.   fflush(out);
  781. #ifndef SKIP_EXTRA_STRUCTS
  782. #ifndef SKIP_T
  783.   Tr = T_TcT(T1,' ',T2);
  784.   fprintf(out,"->{"%c%c%c"}n",Tr.c[0],Tr.c[1],Tr.c[2]);
  785.   fflush(out);
  786.   Tr.c[0] = Tr.c[1] = Tr.c[2] = 0; clear_traces();
  787.   av_start_struct(a,T_TcT,T,1,&Tr);
  788.   av_struct(a,T,T1);
  789.   av_char(a,' ');
  790.   av_struct(a,T,T2);
  791.   av_call(a);
  792.   fprintf(out,"->{"%c%c%c"}n",Tr.c[0],Tr.c[1],Tr.c[2]);
  793.   fflush(out);
  794. #endif
  795.   Xr = X_BcdB(B1,c2,d3,B2);
  796.   fprintf(out,"->{"%s",'%c'}n",Xr.c,Xr.c1);
  797.   fflush(out);
  798.   Xr.c[0]=Xr.c1=''; clear_traces();
  799.   av_start_struct(a,X_BcdB,X,0,&Xr);
  800.   av_struct(a,B,B1);
  801.   av_char(a,c2);
  802.   av_double(a,d3);
  803.   av_struct(a,B,B2);
  804.   av_call(a);
  805.   fprintf(out,"->{"%s",'%c'}n",Xr.c,Xr.c1);
  806.   fflush(out);
  807. #endif
  808.   return;
  809. }
  810. int
  811.   main()
  812. {
  813.   out = stdout;
  814.   void_tests();
  815.   int_tests();
  816.   float_tests();
  817.   double_tests();
  818.   mixed_number_tests();
  819.   pointer_tests();
  820.   structure_tests();
  821.   exit(0);
  822. }
  823. #endif /*_tests_c */