home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / test / exceptiontest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-24  |  1.4 KB  |  64 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: exceptiontest.c,v 1.4 1996/10/24 15:51:34 aros Exp $
  4.     $Log: exceptiontest.c,v $
  5.     Revision 1.4  1996/10/24 15:51:34  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.3  1996/10/23 14:06:40  aros
  9.     Use AROS_LHA() instead of AROS_LA()
  10.  
  11.     Use AROS_SLIB_ENTRY() to generate the name of a symbol in AROS_LH*()
  12.  
  13.     Revision 1.2  1996/08/01 17:41:39  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang:
  18. */
  19. #include <aros/libcall.h>
  20. #include <clib/exec_protos.h>
  21. #include <exec/execbase.h>
  22. #include <stdio.h>
  23.  
  24. ULONG s;
  25.  
  26. AROS_LH2(ULONG,handler,
  27.     AROS_LHA(ULONG,signals,D0),
  28.     AROS_LHA(APTR,exceptData,A1),
  29.     struct ExecBase *,SysBase,,)
  30. {
  31.     AROS_LIBFUNC_INIT
  32.     exceptData=0;
  33.     s=SetSignal(0,0);
  34.     return signals;
  35.     AROS_LIBFUNC_EXIT
  36. }
  37.  
  38. int main(void)
  39. {
  40.     int s1,s2;
  41.     APTR oldexc;
  42.  
  43.     s1=AllocSignal(-1);
  44.     if(s1>=0)
  45.     {
  46.     printf("sig1: %d\n",s1);
  47.     s2=AllocSignal(-1);
  48.     if(s2>=0)
  49.     {
  50.         printf("sig2: %d\n",s2);
  51.         oldexc=SysBase->ThisTask->tc_ExceptCode;
  52.         SysBase->ThisTask->tc_ExceptCode=&AROS_SLIB_ENTRY(handler,);
  53.         SetExcept(1<<s2,1<<s2);
  54.         Signal(SysBase->ThisTask,(1<<s2)|(1<<s1));
  55.         SetExcept(0,1<<s2);
  56.         SysBase->ThisTask->tc_ExceptCode=oldexc;
  57.         printf("got: %08lx\n",s);
  58.         FreeSignal(s2);
  59.     }
  60.     FreeSignal(s1);
  61.     }
  62.     return 0;
  63. }
  64.