1 | #include <lib.h>
|
---|
2 | #define sigfillset _sigfillset
|
---|
3 | #define sigjmp _sigjmp
|
---|
4 | #define sigprocmask _sigprocmask
|
---|
5 | #define sigreturn _sigreturn
|
---|
6 | #include <sys/sigcontext.h>
|
---|
7 | #include <setjmp.h>
|
---|
8 | #include <signal.h>
|
---|
9 |
|
---|
10 | _PROTOTYPE( int sigjmp, (jmp_buf jb, int retval));
|
---|
11 |
|
---|
12 | #if (_SETJMP_SAVES_REGS == 0)
|
---|
13 | /* 'sigreturn' using a short format jmp_buf (no registers saved). */
|
---|
14 | PUBLIC int sigjmp(jb, retval)
|
---|
15 | jmp_buf jb;
|
---|
16 | int retval;
|
---|
17 | {
|
---|
18 | struct sigcontext sc;
|
---|
19 |
|
---|
20 | sc.sc_flags = jb[0].__flags;
|
---|
21 | sc.sc_mask = jb[0].__mask;
|
---|
22 |
|
---|
23 | #if (CHIP == INTEL)
|
---|
24 | sc.sc_pc = (int) jb[0].__pc;
|
---|
25 | sc.sc_sp = (int) jb[0].__sp;
|
---|
26 | sc.sc_fp = (int) jb[0].__lb;
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | #if (CHIP == M68000)
|
---|
30 | sc.sc_pc = (long) jb[0].__pc;
|
---|
31 | sc.sc_sp = (long) jb[0].__sp;
|
---|
32 | sc.sc_fp = (long) jb[0].__lb;
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | sc.sc_retreg = retval;
|
---|
36 | return sigreturn(&sc);
|
---|
37 | }
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | PUBLIC int sigreturn(scp)
|
---|
41 | register struct sigcontext *scp;
|
---|
42 | {
|
---|
43 | sigset_t set;
|
---|
44 |
|
---|
45 | /* The message can't be on the stack, because the stack will vanish out
|
---|
46 | * from under us. The send part of sendrec will succeed, but when
|
---|
47 | * a message is sent to restart the current process, who knows what will
|
---|
48 | * be in the place formerly occupied by the message?
|
---|
49 | */
|
---|
50 | static message m;
|
---|
51 |
|
---|
52 | /* Protect against race conditions by blocking all interrupts. */
|
---|
53 | sigfillset(&set); /* splhi */
|
---|
54 | sigprocmask(SIG_SETMASK, &set, (sigset_t *) NULL);
|
---|
55 |
|
---|
56 | m.m2_l1 = scp->sc_mask;
|
---|
57 | m.m2_i2 = scp->sc_flags;
|
---|
58 | m.m2_p1 = (char *) scp;
|
---|
59 | return(_syscall(MM, SIGRETURN, &m)); /* normally this doesn't return */
|
---|
60 | }
|
---|