home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-2.LHA / CLISP960530-ki.lha / ffcall / trampoline / test2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-15  |  1.1 KB  |  42 lines

  1. /* Trampoline accessor test */
  2.  
  3. /*
  4.  * Copyright 1995 Bruno Haible, <haible@ma2s2.mathematik.uni-karlsruhe.de>
  5.  *
  6.  * This is free software distributed under the GNU General Public Licence
  7.  * described in the file COPYING. Contact the author if you don't have this
  8.  * or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
  9.  * on this software.
  10.  */
  11.  
  12. #include <stdio.h>
  13.  
  14. #include "trampoline.h"
  15.  
  16. typedef int (*function)();
  17.  
  18. int f (x)
  19.   int x;
  20. { return x; }
  21.  
  22. void* variable;
  23.  
  24. static int data;
  25.  
  26. int main ()
  27. {
  28.   function cf = alloc_trampoline(&f, &variable, &data);
  29.   if (is_trampoline(&main))
  30.     { printf("is_trampoline(&main) returns true!\n"); exit(1); }
  31.   if (!is_trampoline(cf))
  32.     { printf("is_trampoline() returns false!\n"); exit(1); }
  33.   if (trampoline_address(cf) != &f)
  34.     { printf("trampoline_address() doesn't work!\n"); exit(1); }
  35.   if (trampoline_variable(cf) != &variable)
  36.     { printf("trampoline_variable() doesn't work!\n"); exit(1); }
  37.   if (trampoline_data(cf) != &data)
  38.     { printf("trampoline_data() doesn't work!\n"); exit(1); }
  39.   printf("test2 passed.\n");
  40.   exit(0);
  41. }
  42.