home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-2.LHA / CLISP960530-ki.lha / ffcall / avcall / tests.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-12  |  19.3 KB  |  812 lines

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