added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / .unmaintained / all-netbsd / exec / sigcore.h
blobb7bc7b218c74a670e8f946a3eaecae14e390601a
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef _SIGCORE_H
7 #define _SIGCORE_H
9 #include <signal.h>
10 #include <errno.h>
11 #include "etask.h"
13 /* Put a value of type SP_TYPE on the stack or get it off the stack. */
14 #define _PUSH(sp,val) (*--sp = (SP_TYPE)(val))
15 #define _POP(sp) (*sp++)
17 typedef struct sigcontext sigcontext_t;
18 #define SIGHANDLER bsd_sighandler
19 #define SIGHANDLER_T void *
20 //__sighandler_t *
22 #define SP_TYPE long
23 #define CPU_NUMREGS 0
25 #define SC_DISABLE(sc) (sc->sc_mask = sig_int_mask)
26 #define SC_ENABLE(sc) (sigemptyset(&sc->sc_mask))
28 #define SP(sc) (sc->sc_esp)
29 #define FP(sc) (sc->sc_ebp)
30 #define PC(sc) (sc->sc_eip)
32 #define R0(sc) (sc->sc_eax)
33 #define R1(sc) (sc->sc_ebx)
34 #define R2(sc) (sc->sc_ecx)
35 #define R3(sc) (sc->sc_edx)
36 #define R4(sc) (sc->sc_edi)
37 #define R5(sc) (sc->sc_esi)
38 #define R6(sc) (sc->sc_eflags)
39 //isp)
41 struct AROS_cpu_context
43 ULONG regs[7]; /* eax, ebx, ecx, edx, edi, esi, isp */
44 ULONG pc,fp; /* store these on the stack to avoid sighandlers */
45 int errno_backup;
48 #define SIZEOF_ALL_REGISTERS (sizeof(struct AROS_cpu_context))
49 #define GetCpuContext(task) ((struct AROS_cpu_context *)\
50 (GetIntETask(task)->iet_Context))
51 #define GetSP(task) ((SP_TYPE*)(task->tc_SPReg))
53 #define GLOBAL_SIGNAL_INIT \
54 static void sighandler (int sig, sigcontext_t * sc); \
56 static void SIGHANDLER (int sig, int code, struct sigcontext *sc) \
57 { \
58 sighandler( sig, (sigcontext_t*)sc); \
61 #define SAVE_CPU(task, sc) \
62 (GetCpuContext(task)->regs[0] = R0(sc)), \
63 (GetCpuContext(task)->regs[1] = R1(sc)), \
64 (GetCpuContext(task)->regs[2] = R2(sc)), \
65 (GetCpuContext(task)->regs[3] = R3(sc)), \
66 (GetCpuContext(task)->regs[4] = R4(sc)), \
67 (GetCpuContext(task)->regs[5] = R5(sc)), \
68 (GetCpuContext(task)->regs[6] = R6(sc))
70 #define RESTORE_CPU(task,sc) \
71 ((R0(sc) = GetCpuContext(task)->regs[0]), \
72 (R1(sc) = GetCpuContext(task)->regs[1]), \
73 (R2(sc) = GetCpuContext(task)->regs[2]), \
74 (R3(sc) = GetCpuContext(task)->regs[3]), \
75 (R4(sc) = GetCpuContext(task)->regs[4]), \
76 (R5(sc) = GetCpuContext(task)->regs[5]), \
77 (R6(sc) = GetCpuContext(task)->regs[6]))
79 #define SAVE_ERRNO(task) \
80 (GetCpuContext(task)->errno_backup = errno)
82 #define RESTORE_ERRNO(task) \
83 (errno = GetCpuContext(task)->errno_backup)
85 #define HAS_FPU 0
86 #define SAVE_FPU(task,sc) /* nop */
87 #define RESTORE_FPU(task,sc) /* nop */
89 #define PREPARE_INITIAL_FRAME(sp,pc) /* nop */
91 #define PREPARE_INITIAL_CONTEXT(task,startpc) \
92 ( GetCpuContext(task)->pc = (ULONG)startpc, \
93 GetCpuContext(task)->fp = 0 )
95 #define SAVEREGS(task,sc) \
96 ((GetSP(task) = (long *)SP(sc)), \
97 (GetCpuContext(task)->pc = PC(sc)), \
98 (GetCpuContext(task)->fp = FP(sc)), \
99 /* SAVE_FPU(task, sc), */ \
100 SAVE_CPU(task, sc), \
101 SAVE_ERRNO(task))
103 #define RESTOREREGS(task,sc) \
104 (RESTORE_ERRNO(task), \
105 RESTORE_CPU(task,sc), \
106 /* RESTORE_FPU(task, sc), */ \
107 (FP(sc) = GetCpuContext(task)->fp), \
108 (PC(sc) = GetCpuContext(task)->pc)), \
109 (SP(sc) = (long)GetSP(task))
111 #define PRINT_SC(sc) \
112 printf (" SP=%08lx FP=%08lx PC=%08lx FPU=%s\n" \
113 " R0=%08lx R1=%08lx R2=%08lx R3=%08lx\n" \
114 " R4=%08lx R5=%08lx R6=%08lx\n" \
115 , SP(sc), FP(sc), PC(sc) \
116 , HAS_FPU(sc) ? "yes" : "no" \
117 , R0(sc), R1(sc), R2(sc), R3(sc) \
118 , R4(sc), R5(sc), R6(sc) \
121 #define PRINT_CPUCONTEXT(task) \
122 printf (" SP=%08lx FP=%08lx PC=%08lx\n" \
123 " R0=%08lx R1=%08lx R2=%08lx R3=%08lx\n" \
124 " R4=%08lx R5=%08lx R6=%08lx\n" \
125 , (ULONG)(GetSP(task)) \
126 , GetCpuContext(task)->fp, GetCpuContext(task)->pc, \
127 , GetCpuContext(task)->regs[0] \
128 , GetCpuContext(task)->regs[1] \
129 , GetCpuContext(task)->regs[2] \
130 , GetCpuContext(task)->regs[3] \
131 , GetCpuContext(task)->regs[4] \
132 , GetCpuContext(task)->regs[5] \
133 , GetCpuContext(task)->regs[6] \
136 #endif /* _SIGCORE_H */