From 7fbfa4360c72056ceb7e9d8cf516a37430bcafb3 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 28 Sep 1990 17:12:33 +0000 Subject: [PATCH] Added _sigvec and _syscall --- mach/sun3/libsys/LIST | 2 ++ mach/sun3/libsys/_sigvec.c | 36 ++++++++++++++++++++++++++++++++++++ mach/sun3/libsys/_syscall.s | 14 ++++++++++++++ mach/sun3/libsys/signal.c | 4 ++-- 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 mach/sun3/libsys/_sigvec.c create mode 100644 mach/sun3/libsys/_syscall.s diff --git a/mach/sun3/libsys/LIST b/mach/sun3/libsys/LIST index 44d0b04ae..5b98dc0c4 100644 --- a/mach/sun3/libsys/LIST +++ b/mach/sun3/libsys/LIST @@ -142,6 +142,7 @@ _sigsetmask.s sigstack.s sigtramp.s sigvec.c +_sigvec.c socket.s socketpair.s sstk.s @@ -151,6 +152,7 @@ swapon.s symlink.s sync.s syscall.s +_syscall.s time.c times.c _times.c diff --git a/mach/sun3/libsys/_sigvec.c b/mach/sun3/libsys/_sigvec.c new file mode 100644 index 000000000..0a8225afd --- /dev/null +++ b/mach/sun3/libsys/_sigvec.c @@ -0,0 +1,36 @@ +#include "syscall.h" +#include +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; +} diff --git a/mach/sun3/libsys/_syscall.s b/mach/sun3/libsys/_syscall.s new file mode 100644 index 000000000..c69f67b16 --- /dev/null +++ b/mach/sun3/libsys/_syscall.s @@ -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) diff --git a/mach/sun3/libsys/signal.c b/mach/sun3/libsys/signal.c index 5c829ae1c..25688e71d 100644 --- a/mach/sun3/libsys/signal.c +++ b/mach/sun3/libsys/signal.c @@ -13,13 +13,13 @@ signal(sig,handler))() v.sv_handler = handler; v.sv_mask = masks[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) { v.sv_mask = ov.sv_mask; masks[sig] = ov.sv_mask; v.sv_flags = 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; }