Check for SYS/GL during library init. Reason is that
[AROS.git] / test / exec / exceptiontest.c
blob67c942f305668efad7fda03bf04da82f4d03c79b
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <aros/libcall.h>
8 #include <clib/exec_protos.h>
9 #include <exec/execbase.h>
10 #include <exec/tasks.h>
11 #include <stdio.h>
13 ULONG s;
15 /* Function prototype needed on Linux-M68K*/
16 AROS_LD2(ULONG,handler,
17 AROS_LDA(ULONG,signals,D0),
18 AROS_LDA(APTR,exceptData,A1),
19 struct ExecBase *,SysBase,0,Test);
21 AROS_LH2(ULONG,handler,
22 AROS_LHA(ULONG,signals,D0),
23 AROS_LHA(APTR,exceptData,A1),
24 struct ExecBase *,SysBase,0,Test)
26 AROS_LIBFUNC_INIT
27 exceptData=0;
28 s=SetSignal(0,0);
29 return signals;
30 AROS_LIBFUNC_EXIT
33 int main(void)
35 int s1,s2;
36 APTR oldexc;
38 s1=AllocSignal(-1);
39 if(s1>=0)
41 printf("sig1: %d\n",s1);
42 s2=AllocSignal(-1);
43 if(s2>=0)
45 struct Task *task = FindTask(NULL);
46 printf("sig2: %d\n",s2);
47 oldexc=task->tc_ExceptCode;
48 task->tc_ExceptCode=&AROS_SLIB_ENTRY(handler,Test,0);
49 SetExcept(1<<s2,1<<s2);
50 Signal(task,(1<<s2)|(1<<s1));
51 SetExcept(0,1<<s2);
52 task->tc_ExceptCode=oldexc;
53 printf("got: %08lx\n",(unsigned long)s);
54 FreeSignal(s2);
56 FreeSignal(s1);
58 return 0;