Added _sigvec and _syscall

This commit is contained in:
ceriel 1990-09-28 17:12:33 +00:00
parent e91e983728
commit 7fbfa4360c
4 changed files with 54 additions and 2 deletions

View file

@ -142,6 +142,7 @@ _sigsetmask.s
sigstack.s sigstack.s
sigtramp.s sigtramp.s
sigvec.c sigvec.c
_sigvec.c
socket.s socket.s
socketpair.s socketpair.s
sstk.s sstk.s
@ -151,6 +152,7 @@ swapon.s
symlink.s symlink.s
sync.s sync.s
syscall.s syscall.s
_syscall.s
time.c time.c
times.c times.c
_times.c _times.c

View file

@ -0,0 +1,36 @@
#include "syscall.h"
#include <errno.h>
struct sigvec { int (*handler)(); int mask,flags; };
int (*(_sigfunc[32]))();
extern int _sigtramp();
extern int errno;
_sigvec(sig,vec,ovec)
register struct sigvec *vec;
struct sigvec *ovec;
{
struct sigvec tmp;
int (*old)();
if ((unsigned) sig >= 32) {
errno = EINVAL;
return -1;
}
old = _sigfunc[sig];
if (vec) {
tmp = *vec;
vec = &tmp;
if (vec->handler && vec->handler != (int (*)()) 1) {
_sigfunc[sig] = vec->handler;
vec->handler = _sigtramp;
}
}
if (_syscall(SYS_sigvec,sig,vec,ovec) < 0) {
_sigfunc[sig] = old;
return -1;
}
if (ovec && ovec->handler == _sigtramp) {
ovec->handler = old;
}
return 0;
}

View file

@ -0,0 +1,14 @@
.sect .text
.define __syscall
__syscall:
move.l (4,sp),d0
move.l (sp),(4,sp)
move.l d0,(sp)
trap #0
bcs 1f
move.l (sp),a0
jmp (a0)
1:
move.l (sp),a0
move.l a0,-(sp)
jmp (cerror)

View file

@ -13,13 +13,13 @@ signal(sig,handler))()
v.sv_handler = handler; v.sv_handler = handler;
v.sv_mask = masks[sig]; v.sv_mask = masks[sig];
v.sv_flags = flags[sig]; v.sv_flags = flags[sig];
if (sigvec(sig,&v, &ov) < 0) return (int (*)()) -1; if (_sigvec(sig,&v, &ov) < 0) return (int (*)()) -1;
if (v.sv_mask != ov.sv_mask || v.sv_flags != ov.sv_flags) { if (v.sv_mask != ov.sv_mask || v.sv_flags != ov.sv_flags) {
v.sv_mask = ov.sv_mask; v.sv_mask = ov.sv_mask;
masks[sig] = ov.sv_mask; masks[sig] = ov.sv_mask;
v.sv_flags = ov.sv_flags; v.sv_flags = ov.sv_flags;
flags[sig] = ov.sv_flags; flags[sig] = ov.sv_flags;
if (sigvec(sig,&v,(char *) 0) < 0) return (int (*)()) -1; if (_sigvec(sig,&v,(char *) 0) < 0) return (int (*)()) -1;
} }
return ov.sv_handler; return ov.sv_handler;
} }