From: Ben Gras Date: Tue, 22 Oct 2013 15:08:15 +0000 (+0200) Subject: use netbsd and sigset_t X-Git-Tag: v3.3.0~507 X-Git-Url: http://zhaoyanbai.com/repos/%22../static/icons/zlib_tech.html?a=commitdiff_plain;h=8ccb12bb5a0b388273f6a035ed21ca59795f2440;p=minix.git use netbsd and sigset_t . create signals-related struct message type to store sigset_t directly . create notify-specific message types, so the generic NOTIFY_ARG doesn't exist anymore . various related test expansions, improvements, fixes . add a few error-checks to sigismember() calls . rename kernel call specific signals fields to SYS_* Change-Id: I53c18999b5eaf0cfa0cb25f5330bee9e7ad2b478 --- diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index df9ba4747..13ba50de4 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -1598,7 +1598,7 @@ static void w_intr_wait(void) if (r != 0) panic("sys_inb failed: %d", r); w_wn->w_status= w_status; - w_hw_int(m.NOTIFY_ARG); + w_hw_int(m.NOTIFY_INTMASK); break; default: /* diff --git a/drivers/lan8710a/lan8710a.c b/drivers/lan8710a/lan8710a.c index d2b58120d..dd466b3a4 100644 --- a/drivers/lan8710a/lan8710a.c +++ b/drivers/lan8710a/lan8710a.c @@ -226,11 +226,11 @@ message *m; } /* Re-enable Rx interrupt. */ - if(m->NOTIFY_ARG & (1 << RX_INT)) + if(m->NOTIFY_INTMASK & (1 << RX_INT)) lan8710a_enable_interrupt(RX_INT); /* Re-enable Tx interrupt. */ - if(m->NOTIFY_ARG & (1 << TX_INT)) + if(m->NOTIFY_INTMASK & (1 << TX_INT)) lan8710a_enable_interrupt(TX_INT); } diff --git a/drivers/tty/arch/earm/rs232.c b/drivers/tty/arch/earm/rs232.c index 23a2e7fec..ce9c6f22e 100644 --- a/drivers/tty/arch/earm/rs232.c +++ b/drivers/tty/arch/earm/rs232.c @@ -589,7 +589,7 @@ rs_interrupt(message *m) int line; rs232_t *rs; - irq_set = m->NOTIFY_ARG; + irq_set = m->NOTIFY_INTMASK; for (line = 0, rs = rs_lines; line < NR_RS_LINES; line++, rs++) { if (irq_set & (1 << rs->irq_hook_id)) { rs232_handler(rs); diff --git a/drivers/tty/arch/i386/rs232.c b/drivers/tty/arch/i386/rs232.c index 7b339e72d..c5a3a7cf6 100644 --- a/drivers/tty/arch/i386/rs232.c +++ b/drivers/tty/arch/i386/rs232.c @@ -534,7 +534,7 @@ void rs_interrupt(message *m) int i; rs232_t *rs; - irq_set= m->NOTIFY_ARG; + irq_set= m->NOTIFY_INTMASK; for (i= 0, rs = rs_lines; iirq)) diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 41e3fbdbc..43e21997d 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -193,7 +193,7 @@ int main(void) #if NR_RS_LINES > 0 /* serial I/O */ - if (tty_mess.NOTIFY_ARG & rs_irq_set) + if (tty_mess.NOTIFY_INTMASK & rs_irq_set) rs_interrupt(&tty_mess); #endif /* run watchdogs of expired timers */ diff --git a/include/arch/earm/include/stackframe.h b/include/arch/earm/include/stackframe.h index c609a65c0..aec3da201 100644 --- a/include/arch/earm/include/stackframe.h +++ b/include/arch/earm/include/stackframe.h @@ -1,6 +1,8 @@ #ifndef _ARM_STACKFRAME_H #define _ARM_STACKFRAME_H +#include + typedef u32_t reg_t; /* machine register */ struct stackframe_s { diff --git a/include/arch/i386/include/stackframe.h b/include/arch/i386/include/stackframe.h index a1b16e58e..e00dc70a0 100644 --- a/include/arch/i386/include/stackframe.h +++ b/include/arch/i386/include/stackframe.h @@ -1,6 +1,8 @@ #ifndef STACK_FRAME_H #define STACK_FRAME_H +#include + typedef unsigned reg_t; /* machine register */ typedef reg_t segdesc_t; diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 7da48ab56..a2243d3b3 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -121,7 +121,7 @@ * sigsuspend(2) calls. */ #define PM_SIG_HOW m2_i1 /* int */ -#define PM_SIG_SET m2_l1 /* sigset_t */ +#define PM_SIG_SET m2_sigset /* sigset_t */ #define PM_SIG_CTX m2_p1 /* struct sigcontext * */ /* Field names for the srv_fork(2) call. */ diff --git a/include/minix/com.h b/include/minix/com.h index 79c1fac7f..46a292f8f 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -108,8 +108,9 @@ (is_ipc_notify(ipc_status) || IPC_STATUS_CALL(ipc_status) == SENDA) /* Shorthands for message parameters passed with notifications. */ -#define NOTIFY_ARG m2_l1 -#define NOTIFY_TIMESTAMP m2_l2 +#define NOTIFY_TIMESTAMP m_u.m_notify.timestamp +#define NOTIFY_INTMASK m_u.m_notify.interrupts +#define NOTIFY_SIGSET m_u.m_notify.sigset /*===========================================================================* * Messages for BUS controller drivers * @@ -475,11 +476,12 @@ #define SG_SIZE m2_i2 /* no. of entries */ /* Field names for SYS_GETKSIG, _ENDKSIG, _KILL, _SIGSEND, _SIGRETURN. */ -#define SIG_ENDPT m2_i1 /* process number for inform */ -#define SIG_NUMBER m2_i2 /* signal number to send */ -#define SIG_FLAGS m2_i3 /* signal flags field */ -#define SIG_MAP m2_l1 /* used by kernel to pass signal bit map */ -#define SIG_CTXT_PTR m2_p1 /* pointer to info to restore signal context */ +#define SYS_SIG_ENDPT m_u.m_sigcalls.ep /* process number for inform */ +#define SYS_SIG_NUMBER m_u.m_sigcalls.sig /* signal number to send */ +#define SYS_SIG_FLAGS m_u.m_sigcalls.flags /* signal flags field */ +#define SYS_SIG_MAP m_u.m_sigcalls.sigs /* used to pass signal bit map */ +#define SYS_SIG_CTXT_PTR m_u.m_sigcalls.sigctx /* pointer to signal context */ +#define SYS_SIG_HOW m_u.m_sigcalls.how /* used to pass signal bit map */ /* Field names for SYS_FORK, _EXEC, _EXIT, GETMCONTEXT, SETMCONTEXT.*/ #define PR_ENDPT m1_i1 /* indicates a process */ diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 4e5bd54d9..ef0eba5ec 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -4,6 +4,7 @@ #include #include #include +#include /*==========================================================================* * Types relating to messages. * @@ -17,7 +18,9 @@ typedef struct {int m1i1, m1i2, m1i3; char *m1p1, *m1p2, *m1p3, *m1p4;} mess_1; typedef struct {int m2i1, m2i2, m2i3; long m2l1, m2l2; char *m2p1; - short m2s1;} mess_2; + short m2s1; sigset_t sigset; } mess_2; +typedef struct {endpoint_t ep; int sig; u32_t flags; sigset_t sigs; + void *sigctx; int how; } mess_sigcalls; typedef struct {int m3i1, m3i2; char *m3p1; char m3ca1[M3_LONG_STRING];} mess_3; typedef struct {long m4l1, m4l2, m4l3, m4l4, m4l5;} mess_4; typedef struct {short m5s1, m5s2; int m5i1, m5i2; long m5l1, m5l2, m5l3;}mess_5; @@ -43,6 +46,12 @@ typedef struct { u8_t flags; } mess_vmmcp; +typedef struct { + u64_t timestamp; /* valid for every notify msg */ + u64_t interrupts; /* raised interrupts; valid if from HARDWARE */ + sigset_t sigset; /* raised signals; valid if from SYSTEM */ +} mess_notify; + typedef struct { endpoint_t who; u32_t offset; @@ -74,6 +83,8 @@ typedef struct { mess_vmmcp m_vmmcp; mess_vmmcp_reply m_vmmcp_reply; mess_vm_vfs_mmap m_vm_vfs; + mess_notify m_notify; /* notify messages */ + mess_sigcalls m_sigcalls; /* SYS_{GETKSIG,ENDKSIG,KILL,SIGSEND,SIGRETURN} */ u32_t size[14]; /* message payload may have 14 longs at most */ } m_u; } message __aligned(16); @@ -93,6 +104,7 @@ typedef struct { #define m2_l1 m_u.m_m2.m2l1 #define m2_l2 m_u.m_m2.m2l2 #define m2_p1 m_u.m_m2.m2p1 +#define m2_sigset m_u.m_m2.sigset #define m2_s1 m_u.m_m2.m2s1 diff --git a/include/minix/type.h b/include/minix/type.h index 2e415b84b..25b24d2c3 100644 --- a/include/minix/type.h +++ b/include/minix/type.h @@ -7,6 +7,7 @@ #endif #include +#include #include @@ -65,7 +66,7 @@ typedef struct { */ struct sigmsg { int sm_signo; /* signal number being caught */ - unsigned long sm_mask; /* mask to restore when handler returns */ + sigset_t sm_mask; /* mask to restore when handler returns */ vir_bytes sm_sighandler; /* address of handler */ vir_bytes sm_sigreturn; /* address of _sigreturn in C library */ vir_bytes sm_stkptr; /* user stack pointer */ diff --git a/include/signal.h b/include/signal.h index 3d225cb75..e1b435fdc 100644 --- a/include/signal.h +++ b/include/signal.h @@ -62,29 +62,33 @@ int kill(pid_t, int); int __libc_sigaction14(int, const struct sigaction * __restrict, struct sigaction * __restrict); -#ifndef __minix #if (_POSIX_C_SOURCE - 0L) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ defined(_NETBSD_SOURCE) int pthread_sigmask(int, const sigset_t * __restrict, sigset_t * __restrict); +#ifndef __minix int pthread_kill(pthread_t, int); +#endif int __libc_thr_sigsetmask(int, const sigset_t * __restrict, sigset_t * __restrict); #ifndef __LIBPTHREAD_SOURCE__ #define pthread_sigmask __libc_thr_sigsetmask #endif /* __LIBPTHREAD_SOURCE__ */ #endif -#endif /* __minix */ #ifndef __LIBC12_SOURCE__ int sigaction(int, const struct sigaction * __restrict, struct sigaction * __restrict) __RENAME(__sigaction14); #if defined(__minix) && defined(_SYSTEM) -#define sigaddset(set, sig) __sigaddset((set), (sig)) -#define sigdelset(set, sig) __sigdelset((set), (sig)) -#define sigemptyset(set) __sigemptyset((set)) -#define sigfillset(set) __sigfillset((set)) -#define sigismember(set, sig) __sigismember((set), (sig)) +/* In Minix system code, use alternate versions of the signal mask + * manipulation functions that do not check signal numbers vs. _NSIG. + * _NSIG can then represent the user-visible signal set. + */ +#define sigaddset(set, sig) __sigaddset((set), (sig)) +#define sigdelset(set, sig) __sigdelset((set), (sig)) +#define sigemptyset(set) __sigemptyset((set)) +#define sigfillset(set) __sigfillset((set)) +#define sigismember(set, sig) __sigismember((set), (sig)) #else int sigaddset(sigset_t *, int) __RENAME(__sigaddset14); int sigdelset(sigset_t *, int) __RENAME(__sigdelset14); @@ -115,7 +119,7 @@ int *__errno(void); #define ___errno (*__errno()) #endif -#if !defined(__minix) || !defined(_SYSTEM) +#if !(defined(__minix) && defined(_SYSTEM)) __c99inline int sigaddset(sigset_t *set, int signo) { @@ -161,7 +165,7 @@ sigfillset(sigset_t *set) __sigfillset(set); return (0); } -#endif /* !defined(__minix) || !defined(_SYSTEM) */ +#endif #endif /* __c99inline */ #endif /* !__LIBC12_SOURCE__ */ @@ -172,13 +176,11 @@ sigfillset(sigset_t *set) (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) int killpg(pid_t, int); int siginterrupt(int, int); -#ifndef __minix int sigstack(const struct sigstack *, struct sigstack *); #ifndef __LIBC12_SOURCE__ int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __RENAME(__sigaltstack14); #endif -#endif /* !__minix */ int sighold(int); int sigignore(int); int sigpause(int); @@ -192,13 +194,10 @@ void (*sigset (int, void (*)(int)))(int); */ #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ defined(_NETBSD_SOURCE) -#ifndef __minix int sigwait (const sigset_t * __restrict, int * __restrict); int sigwaitinfo(const sigset_t * __restrict, siginfo_t * __restrict); -#endif /* !__minix */ void psiginfo(const siginfo_t *, const char *); -#ifndef __minix #ifndef __LIBC12_SOURCE__ struct timespec; int sigtimedwait(const sigset_t * __restrict, @@ -208,18 +207,15 @@ int __sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict, struct timespec * __restrict) __RENAME(____sigtimedwait50); #endif -#endif /* !__minix */ #endif /* _POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE_EXTENDED || ... */ #if defined(_NETBSD_SOURCE) -#ifndef __minix #ifndef __PSIGNAL_DECLARED #define __PSIGNAL_DECLARED /* also in unistd.h */ void psignal(int, const char *); #endif /* __PSIGNAL_DECLARED */ -#endif /* !__minix */ int sigblock(int); int sigsetmask(int); #endif /* _NETBSD_SOURCE */ diff --git a/kernel/proc.c b/kernel/proc.c index 36703a541..bb81ac911 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "kernel/kernel.h" #include "vm.h" @@ -98,16 +99,19 @@ static void set_idle_name(char * name, int n) #define PICK_HIGHERONLY 2 #define BuildNotifyMessage(m_ptr, src, dst_ptr) \ + memset((m_ptr), 0, sizeof(*(m_ptr))); \ (m_ptr)->m_type = NOTIFY_MESSAGE; \ (m_ptr)->NOTIFY_TIMESTAMP = get_monotonic(); \ switch (src) { \ case HARDWARE: \ - (m_ptr)->NOTIFY_ARG = priv(dst_ptr)->s_int_pending; \ + (m_ptr)->NOTIFY_INTMASK = priv(dst_ptr)->s_int_pending; \ priv(dst_ptr)->s_int_pending = 0; \ break; \ case SYSTEM: \ - (m_ptr)->NOTIFY_ARG = priv(dst_ptr)->s_sig_pending; \ - priv(dst_ptr)->s_sig_pending = 0; \ + memcpy(&(m_ptr)->NOTIFY_SIGSET, \ + &priv(dst_ptr)->s_sig_pending, \ + sizeof(sigset_t)); \ + sigemptyset(&priv(dst_ptr)->s_sig_pending); \ break; \ } diff --git a/kernel/system.c b/kernel/system.c index a76d6af69..2d1aee10d 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -408,6 +408,7 @@ int sig_nr; /* signal to be sent */ register struct proc *rp, *sig_mgr_rp; endpoint_t sig_mgr; int sig_mgr_proc_nr; + int s; /* Lookup signal manager. */ rp = proc_addr(proc_nr); @@ -438,8 +439,10 @@ int sig_nr; /* signal to be sent */ return; } + if((s = sigismember(&rp->p_pending, sig_nr)) < 0) + panic("sigismember failed"); /* Check if the signal is already pending. Process it otherwise. */ - if (! sigismember(&rp->p_pending, sig_nr)) { + if (!s) { sigaddset(&rp->p_pending, sig_nr); increase_proc_signals(rp); if (! (RTS_ISSET(rp, RTS_SIGNALED))) { /* other pending */ diff --git a/kernel/system/do_endksig.c b/kernel/system/do_endksig.c index de1a3505f..414e01179 100644 --- a/kernel/system/do_endksig.c +++ b/kernel/system/do_endksig.c @@ -24,7 +24,7 @@ int do_endksig(struct proc * caller, message * m_ptr) /* Get process pointer and verify that it had signals pending. If the * process is already dead its flags will be reset. */ - if(!isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) + if(!isokendpt(m_ptr->SYS_SIG_ENDPT, &proc_nr)) return EINVAL; rp = proc_addr(proc_nr); diff --git a/kernel/system/do_getksig.c b/kernel/system/do_getksig.c index 0235fcc3b..496066f91 100644 --- a/kernel/system/do_getksig.c +++ b/kernel/system/do_getksig.c @@ -2,8 +2,8 @@ * m_type: SYS_GETKSIG * * The parameters for this kernel call are: - * m2_i1: SIG_ENDPT # process with pending signals - * m2_l1: SIG_MAP # bit map with pending signals + * m2_i1: SYS_SIG_ENDPT # process with pending signals + * m2_l1: SYS_SIG_MAP # bit map with pending signals */ #include "kernel/system.h" @@ -28,8 +28,8 @@ int do_getksig(struct proc * caller, message * m_ptr) if (RTS_ISSET(rp, RTS_SIGNALED)) { if (caller->p_endpoint != priv(rp)->s_sig_mgr) continue; /* store signaled process' endpoint */ - m_ptr->SIG_ENDPT = rp->p_endpoint; - m_ptr->SIG_MAP = rp->p_pending; /* pending signals map */ + m_ptr->SYS_SIG_ENDPT = rp->p_endpoint; + m_ptr->SYS_SIG_MAP = rp->p_pending; /* pending signals map */ (void) sigemptyset(&rp->p_pending); /* clear map in the kernel */ RTS_UNSET(rp, RTS_SIGNALED); /* blocked by SIG_PENDING */ return(OK); @@ -37,7 +37,7 @@ int do_getksig(struct proc * caller, message * m_ptr) } /* No process with pending signals was found. */ - m_ptr->SIG_ENDPT = NONE; + m_ptr->SYS_SIG_ENDPT = NONE; return(OK); } #endif /* USE_GETKSIG */ diff --git a/kernel/system/do_kill.c b/kernel/system/do_kill.c index dc370dc67..7bc4a9568 100644 --- a/kernel/system/do_kill.c +++ b/kernel/system/do_kill.c @@ -2,8 +2,8 @@ * m_type: SYS_KILL * * The parameters for this kernel call are: - * m2_i1: SIG_ENDPT # process to signal/ pending - * m2_i2: SIG_NUMBER # signal number to send to process + * m2_i1: SYS_SIG_ENDPT # process to signal/ pending + * m2_i2: SYS_SIG_NUMBER # signal number to send to process */ #include "kernel/system.h" @@ -23,9 +23,9 @@ int do_kill(struct proc * caller, message * m_ptr) * translated into an IPC message for system services. */ proc_nr_t proc_nr, proc_nr_e; - int sig_nr = m_ptr->SIG_NUMBER; + int sig_nr = m_ptr->SYS_SIG_NUMBER; - proc_nr_e= (proc_nr_t) m_ptr->SIG_ENDPT; + proc_nr_e= (proc_nr_t) m_ptr->SYS_SIG_ENDPT; if (!isokendpt(proc_nr_e, &proc_nr)) return(EINVAL); if (sig_nr >= _NSIG) return(EINVAL); diff --git a/kernel/system/do_sigreturn.c b/kernel/system/do_sigreturn.c index 606314b18..833010733 100644 --- a/kernel/system/do_sigreturn.c +++ b/kernel/system/do_sigreturn.c @@ -25,12 +25,12 @@ int do_sigreturn(struct proc * caller, message * m_ptr) register struct proc *rp; int proc_nr, r; - if (! isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL); + if (! isokendpt(m_ptr->SYS_SIG_ENDPT, &proc_nr)) return(EINVAL); if (iskerneln(proc_nr)) return(EPERM); rp = proc_addr(proc_nr); /* Copy in the sigcontext structure. */ - if((r=data_copy(m_ptr->SIG_ENDPT, (vir_bytes) m_ptr->SIG_CTXT_PTR, + if((r=data_copy(m_ptr->SYS_SIG_ENDPT, (vir_bytes) m_ptr->SYS_SIG_CTXT_PTR, KERNEL, (vir_bytes) &sc, sizeof(struct sigcontext))) != OK) return r; diff --git a/kernel/system/do_sigsend.c b/kernel/system/do_sigsend.c index 6c6e9babe..95f46e3e1 100644 --- a/kernel/system/do_sigsend.c +++ b/kernel/system/do_sigsend.c @@ -2,9 +2,9 @@ * m_type: SYS_SIGSEND * * The parameters for this kernel call are: - * m2_i1: SIG_ENDPT # process to call signal handler - * m2_p1: SIG_CTXT_PTR # pointer to sigcontext structure - * m2_i3: SIG_FLAGS # flags for S_SIGRETURN call + * m2_i1: SYS_SIG_ENDPT # process to call signal handler + * m2_p1: SYS_SIG_CTXT_PTR # pointer to sigcontext structure + * m2_i3: SYS_SIG_FLAGS # flags for S_SIGRETURN call * */ @@ -27,13 +27,13 @@ int do_sigsend(struct proc * caller, message * m_ptr) struct sigframe fr, *frp; int proc_nr, r; - if (!isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL); + if (!isokendpt(m_ptr->SYS_SIG_ENDPT, &proc_nr)) return(EINVAL); if (iskerneln(proc_nr)) return(EPERM); rp = proc_addr(proc_nr); /* Get the sigmsg structure into our address space. */ if((r=data_copy_vmcheck(caller, caller->p_endpoint, - (vir_bytes) m_ptr->SIG_CTXT_PTR, KERNEL, (vir_bytes) &smsg, + (vir_bytes) m_ptr->SYS_SIG_CTXT_PTR, KERNEL, (vir_bytes) &smsg, (phys_bytes) sizeof(struct sigmsg))) != OK) return r; @@ -64,7 +64,7 @@ int do_sigsend(struct proc * caller, message * m_ptr) sc.sc_flags = rp->p_misc_flags & MF_FPU_INITIALIZED; /* Copy the sigcontext structure to the user's stack. */ - if((r=data_copy_vmcheck(caller, KERNEL, (vir_bytes) &sc, m_ptr->SIG_ENDPT, + if((r=data_copy_vmcheck(caller, KERNEL, (vir_bytes) &sc, m_ptr->SYS_SIG_ENDPT, (vir_bytes) scp, (vir_bytes) sizeof(struct sigcontext))) != OK) return r; @@ -97,7 +97,7 @@ int do_sigsend(struct proc * caller, message * m_ptr) /* Copy the sigframe structure to the user's stack. */ if((r=data_copy_vmcheck(caller, KERNEL, (vir_bytes) &fr, - m_ptr->SIG_ENDPT, (vir_bytes) frp, + m_ptr->SYS_SIG_ENDPT, (vir_bytes) frp, (vir_bytes) sizeof(struct sigframe))) != OK) return r; diff --git a/lib/libblockdriver/driver.c b/lib/libblockdriver/driver.c index 6557f68c1..ed251702f 100644 --- a/lib/libblockdriver/driver.c +++ b/lib/libblockdriver/driver.c @@ -391,7 +391,7 @@ void blockdriver_process_on_thread(struct blockdriver *bdp, message *m_ptr, switch (_ENDPOINT_P(m_ptr->m_source)) { case HARDWARE: if (bdp->bdr_intr) - (*bdp->bdr_intr)(m_ptr->NOTIFY_ARG); + (*bdp->bdr_intr)(m_ptr->NOTIFY_INTMASK); break; case CLOCK: diff --git a/lib/libc/arch/arm/gen/setjmp.S b/lib/libc/arch/arm/gen/setjmp.S index 56b8202e0..3f3750c9c 100644 --- a/lib/libc/arch/arm/gen/setjmp.S +++ b/lib/libc/arch/arm/gen/setjmp.S @@ -87,11 +87,7 @@ ENTRY(__longjmp14) stmfd sp!, {r0-r2, r14} mov r2, #0x00000000 add r1, r0, #(_JB_SIGMASK * 4) -#ifdef __minix - mov r0, #2 /* SIG_SETMASK */ -#else mov r0, #3 /* SIG_SETMASK */ -#endif bl PIC_SYM(_C_LABEL(__sigprocmask14), PLT) ldmfd sp!, {r0-r2, r14} diff --git a/lib/libc/arch/i386/gen/setjmp.S b/lib/libc/arch/i386/gen/setjmp.S index 5c271212a..cbb24e8cd 100644 --- a/lib/libc/arch/i386/gen/setjmp.S +++ b/lib/libc/arch/i386/gen/setjmp.S @@ -85,11 +85,7 @@ ENTRY(__longjmp14) PIC_PROLOGUE pushl $0 pushl %edx -#ifdef __minix - pushl $2 /* SIG_SETMASK */ -#else pushl $3 /* SIG_SETMASK */ -#endif #ifdef PIC call PIC_PLT(_C_LABEL(__sigprocmask14)) #else diff --git a/lib/libc/arch/i386/gen/sigsetjmp.S b/lib/libc/arch/i386/gen/sigsetjmp.S index 12769d16c..56743b896 100644 --- a/lib/libc/arch/i386/gen/sigsetjmp.S +++ b/lib/libc/arch/i386/gen/sigsetjmp.S @@ -85,11 +85,7 @@ ENTRY(__siglongjmp14) PIC_PROLOGUE pushl $0 pushl %edx -#ifdef __minix - pushl $2 /* SIG_SETMASK */ -#else pushl $3 /* SIG_SETMASK */ -#endif #ifdef PIC call PIC_PLT(_C_LABEL(__sigprocmask14)) #else diff --git a/lib/libc/sys-minix/sigpending.c b/lib/libc/sys-minix/sigpending.c index e561ce826..e851c9228 100644 --- a/lib/libc/sys-minix/sigpending.c +++ b/lib/libc/sys-minix/sigpending.c @@ -12,7 +12,7 @@ sigset_t *set; memset(&m, 0, sizeof(m)); if (_syscall(PM_PROC_NR, PM_SIGPENDING, &m) < 0) return(-1); - *set = (sigset_t) m.PM_SIG_SET; + *set = m.PM_SIG_SET; return(m.m_type); } diff --git a/lib/libc/sys-minix/sigprocmask.c b/lib/libc/sys-minix/sigprocmask.c index fe6a2c7e2..a84aa8076 100644 --- a/lib/libc/sys-minix/sigprocmask.c +++ b/lib/libc/sys-minix/sigprocmask.c @@ -1,5 +1,8 @@ #include +#include +#include #include +#include #include "namespace.h" #include @@ -15,13 +18,14 @@ sigset_t *oset; memset(&m, 0, sizeof(m)); if (set == (sigset_t *) NULL) { m.PM_SIG_HOW = SIG_INQUIRE; - m.PM_SIG_SET = 0; + sigemptyset(&m.PM_SIG_SET); } else { m.PM_SIG_HOW = how; - m.PM_SIG_SET = (long) *set; + m.PM_SIG_SET = *set; } if (_syscall(PM_PROC_NR, PM_SIGPROCMASK, &m) < 0) return(-1); - if (oset != (sigset_t *) NULL) *oset = (sigset_t) (m.PM_SIG_SET); + if (oset != (sigset_t *) NULL) *oset = m.PM_SIG_SET; + return(m.m_type); } diff --git a/lib/libc/sys-minix/sigreturn.c b/lib/libc/sys-minix/sigreturn.c index 4b441407e..7b907425c 100644 --- a/lib/libc/sys-minix/sigreturn.c +++ b/lib/libc/sys-minix/sigreturn.c @@ -1,17 +1,19 @@ +#include "namespace.h" + #include #include -#include "namespace.h" #include #include +#include #include +#include #ifdef __weak_alias __weak_alias(sigreturn, _sigreturn) #endif -int sigreturn(scp) -register struct sigcontext *scp; +int sigreturn(struct sigcontext *scp) { sigset_t set; diff --git a/lib/libc/sys-minix/sigsuspend.c b/lib/libc/sys-minix/sigsuspend.c index c7c8d7b58..abfdc8ff7 100644 --- a/lib/libc/sys-minix/sigsuspend.c +++ b/lib/libc/sys-minix/sigsuspend.c @@ -11,7 +11,7 @@ const sigset_t *set; message m; memset(&m, 0, sizeof(m)); - m.PM_SIG_SET = (long) *set; + m.PM_SIG_SET = *set; return(_syscall(PM_PROC_NR, PM_SIGSUSPEND, &m)); } diff --git a/lib/libchardriver/chardriver.c b/lib/libchardriver/chardriver.c index 27ab03516..176819dec 100644 --- a/lib/libchardriver/chardriver.c +++ b/lib/libchardriver/chardriver.c @@ -447,7 +447,7 @@ void chardriver_process(struct chardriver *cdp, message *m_ptr, int ipc_status) switch (_ENDPOINT_P(m_ptr->m_source)) { case HARDWARE: if (cdp->cdr_intr) - cdp->cdr_intr(m_ptr->NOTIFY_ARG); + cdp->cdr_intr(m_ptr->NOTIFY_INTMASK); break; case CLOCK: diff --git a/lib/libddekit/src/dde.c b/lib/libddekit/src/dde.c index 8fc7fd473..6c117fcc5 100644 --- a/lib/libddekit/src/dde.c +++ b/lib/libddekit/src/dde.c @@ -64,7 +64,7 @@ static void dispatcher_thread(void *unused) { case HARDWARE: for (i =0 ; i < 32 ; i++) { - if(m.NOTIFY_ARG & (1 << i)) + if(m.NOTIFY_INTMASK & (1 << i)) { _ddekit_interrupt_trigger(i); } diff --git a/lib/libgpio/gpio_omap.c b/lib/libgpio/gpio_omap.c index 05e761d9e..18005df6e 100644 --- a/lib/libgpio/gpio_omap.c +++ b/lib/libgpio/gpio_omap.c @@ -349,8 +349,8 @@ omap_message_hook(message * m) switch (_ENDPOINT_P(m->m_source)) { case HARDWARE: /* Hardware interrupt return a "set" if pending interrupts */ - irq_set = m->NOTIFY_ARG; - log_debug(&log, "HW message 0X%08x\n", m->NOTIFY_ARG); + irq_set = m->NOTIFY_INTMASK; + log_debug(&log, "HW message 0X%08llx\n", m->NOTIFY_INTMASK); bank = &omap_gpio_banks[0]; for (i = 0; omap_gpio_banks[i].name != NULL; i++) { bank = &omap_gpio_banks[i]; diff --git a/lib/libinputdriver/inputdriver.c b/lib/libinputdriver/inputdriver.c index 24e734c41..e4e1c3948 100644 --- a/lib/libinputdriver/inputdriver.c +++ b/lib/libinputdriver/inputdriver.c @@ -146,7 +146,7 @@ inputdriver_process(struct inputdriver *idp, message *m_ptr, int ipc_status) switch (_ENDPOINT_P(m_ptr->m_source)) { case HARDWARE: if (idp->idr_intr) - idp->idr_intr(m_ptr->NOTIFY_ARG); + idp->idr_intr(m_ptr->NOTIFY_INTMASK); break; case CLOCK: diff --git a/lib/libminc/Makefile b/lib/libminc/Makefile index a049890a0..286082498 100644 --- a/lib/libminc/Makefile +++ b/lib/libminc/Makefile @@ -99,7 +99,7 @@ CLEANFILES+= errlist.c isnanf_ieee754.c isnand_ieee754.c \ isfinitef_ieee754.c isfinited_ieee754.c \ signbitf_ieee754.c signbitd_ieee754.c \ - nanf.c + nanf.c sigsetops.c .PATH.c .PATH.S: ${ARCHDIR}/gen ${LIBCDIR}/gen/minix \ ${LIBCDIR}/gen ${LIBCDIR} SRCS+= ${i} diff --git a/lib/libsys/sef_signal.c b/lib/libsys/sef_signal.c index 8136c21d6..dd3bbb3f0 100644 --- a/lib/libsys/sef_signal.c +++ b/lib/libsys/sef_signal.c @@ -43,7 +43,9 @@ static void process_sigmgr_signals(void) /* Process every signal in the signal set. */ r = OK; for (signo = SIGS_FIRST; signo <= SIGS_LAST; signo++) { - if(sigismember(&sigset, signo)) { + int s = sigismember(&sigset, signo); + assert(s >= 0); + if(s) { /* Let the callback code process the signal. */ r = sef_cbs.sef_cb_signal_manager(target, signo); @@ -71,7 +73,9 @@ static void process_sigmgr_self_signals(sigset_t sigset) int signo; for (signo = SIGS_FIRST; signo <= SIGS_LAST; signo++) { - if(sigismember(&sigset, signo)) { + int s = sigismember(&sigset, signo); + assert(s >= 0); + if(s) { /* Let the callback code process the signal. */ sef_cbs.sef_cb_signal_handler(signo); } @@ -89,9 +93,11 @@ int do_sef_signal_request(message *m_ptr) if(m_ptr->m_source == SYSTEM) { /* Handle kernel signals. */ - sigset = m_ptr->NOTIFY_ARG; + sigset = m_ptr->NOTIFY_SIGSET; for (signo = SIGK_FIRST; signo <= SIGK_LAST; signo++) { - if (sigismember(&sigset, signo)) { + int s = sigismember(&sigset, signo); + assert(s >= 0); + if (s) { /* Let the callback code handle the kernel signal. */ sef_cbs.sef_cb_signal_handler(signo); diff --git a/lib/libsys/sys_endsig.c b/lib/libsys/sys_endsig.c index 7226f2bbc..a93fe0c04 100644 --- a/lib/libsys/sys_endsig.c +++ b/lib/libsys/sys_endsig.c @@ -9,7 +9,7 @@ endpoint_t proc_ep; /* process number */ message m; int result; - m.SIG_ENDPT = proc_ep; + m.SYS_SIG_ENDPT = proc_ep; result = _kernel_call(SYS_ENDKSIG, &m); return(result); } diff --git a/lib/libsys/sys_getsig.c b/lib/libsys/sys_getsig.c index dc993c16f..30e335a33 100644 --- a/lib/libsys/sys_getsig.c +++ b/lib/libsys/sys_getsig.c @@ -11,8 +11,8 @@ sigset_t *k_sig_map; /* return signal map here */ int result; result = _kernel_call(SYS_GETKSIG, &m); - *proc_ep = m.SIG_ENDPT; - *k_sig_map = (sigset_t) m.SIG_MAP; + *proc_ep = m.SYS_SIG_ENDPT; + *k_sig_map = m.SYS_SIG_MAP; return(result); } diff --git a/lib/libsys/sys_kill.c b/lib/libsys/sys_kill.c index 71b84505e..7886c47ef 100644 --- a/lib/libsys/sys_kill.c +++ b/lib/libsys/sys_kill.c @@ -7,8 +7,8 @@ int signr; /* signal number: 1 - 16 */ /* A proc_ep has to be signaled via PM. Tell the kernel. */ message m; - m.SIG_ENDPT = proc_ep; - m.SIG_NUMBER = signr; + m.SYS_SIG_ENDPT = proc_ep; + m.SYS_SIG_NUMBER = signr; return(_kernel_call(SYS_KILL, &m)); } diff --git a/lib/libsys/sys_sigreturn.c b/lib/libsys/sys_sigreturn.c index 116ac728c..15ed38a4c 100644 --- a/lib/libsys/sys_sigreturn.c +++ b/lib/libsys/sys_sigreturn.c @@ -10,8 +10,8 @@ struct sigmsg *sig_ctxt; /* POSIX style handling */ message m; int result; - m.SIG_ENDPT = proc_ep; - m.SIG_CTXT_PTR = (char *) sig_ctxt; + m.SYS_SIG_ENDPT = proc_ep; + m.SYS_SIG_CTXT_PTR = (char *) sig_ctxt; result = _kernel_call(SYS_SIGRETURN, &m); return(result); } diff --git a/lib/libsys/sys_sigsend.c b/lib/libsys/sys_sigsend.c index 90683a592..2d0eae933 100644 --- a/lib/libsys/sys_sigsend.c +++ b/lib/libsys/sys_sigsend.c @@ -10,8 +10,8 @@ struct sigmsg *sig_ctxt; /* POSIX style handling */ message m; int result; - m.SIG_ENDPT = proc_ep; - m.SIG_CTXT_PTR = (char *) sig_ctxt; + m.SYS_SIG_ENDPT = proc_ep; + m.SYS_SIG_CTXT_PTR = (char *) sig_ctxt; result = _kernel_call(SYS_SIGSEND, &m); return(result); } diff --git a/servers/is/dmp_pm.c b/servers/is/dmp_pm.c index 151e4c5ac..1cbd8d394 100644 --- a/servers/is/dmp_pm.c +++ b/servers/is/dmp_pm.c @@ -90,9 +90,10 @@ void sigaction_dmp() if (mp->mp_pid == 0 && i != PM_PROC_NR) continue; if (++n > 22) break; printf("%8.8s %3d ", mp->mp_name, i); - printf(" %08lx %08lx %08lx ", - mp->mp_ignore, mp->mp_catch, mp->mp_sigmask); - printf("%08lx ", mp->mp_sigpending); + printf(" %08x %08x %08x ", + mp->mp_ignore.__bits[0], mp->mp_catch.__bits[0], + mp->mp_sigmask.__bits[0]); + printf("%08x ", mp->mp_sigpending.__bits[0]); if (mp->mp_flags & ALARM_ON) printf("%8lu", mp->mp_timer.tmr_exp_time-uptime); else printf(" -"); printf("\n"); diff --git a/servers/pm/signal.c b/servers/pm/signal.c index c498018ed..01623c13d 100644 --- a/servers/pm/signal.c +++ b/servers/pm/signal.c @@ -92,7 +92,7 @@ int do_sigpending(void) { assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); - mp->mp_reply.PM_SIG_SET = (long) mp->mp_sigpending; + mp->mp_reply.PM_SIG_SET = mp->mp_sigpending; return OK; } @@ -117,7 +117,7 @@ int do_sigprocmask(void) assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); set = m_in.PM_SIG_SET; - mp->mp_reply.PM_SIG_SET = (long) mp->mp_sigmask; + mp->mp_reply.PM_SIG_SET = mp->mp_sigmask; switch (m_in.PM_SIG_HOW) { case SIG_BLOCK: @@ -162,7 +162,7 @@ int do_sigsuspend(void) assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); mp->mp_sigmask2 = mp->mp_sigmask; /* save the old mask */ - mp->mp_sigmask = (sigset_t) m_in.PM_SIG_SET; + mp->mp_sigmask = m_in.PM_SIG_SET; sigdelset(&mp->mp_sigmask, SIGKILL); sigdelset(&mp->mp_sigmask, SIGSTOP); mp->mp_flags |= SIGSUSPENDED; @@ -182,7 +182,7 @@ int do_sigreturn(void) assert(!(mp->mp_flags & (PROC_STOPPED | VFS_CALL | UNPAUSED))); - mp->mp_sigmask = (sigset_t) m_in.PM_SIG_SET; + mp->mp_sigmask = m_in.PM_SIG_SET; sigdelset(&mp->mp_sigmask, SIGKILL); sigdelset(&mp->mp_sigmask, SIGSTOP); @@ -772,7 +772,7 @@ int signo; /* signal to send to process (1 to _NSIG-1) */ * Return TRUE if this succeeded, FALSE otherwise. */ struct sigmsg sigmsg; - int r, sigflags, slot; + int i, r, sigflags, slot; assert(rmp->mp_flags & PROC_STOPPED); @@ -787,7 +787,10 @@ int signo; /* signal to send to process (1 to _NSIG-1) */ sigmsg.sm_sighandler = (vir_bytes) rmp->mp_sigact[signo].sa_handler; sigmsg.sm_sigreturn = rmp->mp_sigreturn; - rmp->mp_sigmask |= rmp->mp_sigact[signo].sa_mask; + for (i = 1; i < _NSIG; i++) { + if (sigismember(&rmp->mp_sigact[signo].sa_mask, i)) + sigaddset(&rmp->mp_sigmask, i); + } if (sigflags & SA_NODEFER) sigdelset(&rmp->mp_sigmask, signo); diff --git a/sys/arch/arm/include/signal.h b/sys/arch/arm/include/signal.h index 8c539f188..5ff12d707 100644 --- a/sys/arch/arm/include/signal.h +++ b/sys/arch/arm/include/signal.h @@ -28,7 +28,7 @@ struct sigcontext { int sc_flags; /* sigstack state to restore (including * MF_FPU_INITIALIZED) */ - long sc_mask; /* signal mask to restore */ + sigset_t sc_mask; /* signal mask to restore */ sigregs sc_regs; /* register set to restore */ }; diff --git a/sys/arch/i386/include/signal.h b/sys/arch/i386/include/signal.h index 6bac4db25..ee5d49533 100644 --- a/sys/arch/i386/include/signal.h +++ b/sys/arch/i386/include/signal.h @@ -29,7 +29,7 @@ struct sigcontext { int sc_flags; /* sigstack state to restore (including * MF_FPU_INITIALIZED) */ - long sc_mask; /* signal mask to restore */ + sigset_t sc_mask; /* signal mask to restore */ sigregs sc_regs; /* register set to restore */ union fpu_state_u sc_fpu_state; }; diff --git a/sys/sys/signal.h b/sys/sys/signal.h index 913bf9c82..fc1dbba93 100644 --- a/sys/sys/signal.h +++ b/sys/sys/signal.h @@ -42,93 +42,76 @@ #include #include -#define _NSIG 27 -#define NSIG _NSIG - - -/* Regular signals. */ -#define SIGHUP 1 /* hangup */ -#define SIGINT 2 /* interrupt (DEL) */ -#define SIGQUIT 3 /* quit (ASCII FS) */ -#define SIGILL 4 /* illegal instruction */ -#define SIGTRAP 5 /* trace trap (not reset when caught) */ -#define SIGABRT 6 /* IOT instruction */ -#define SIGBUS 7 /* bus error */ -#define SIGFPE 8 /* floating point exception */ -#define SIGKILL 9 /* kill (cannot be caught or ignored) */ -#define SIGUSR1 10 /* user defined signal # 1 */ -#define SIGSEGV 11 /* segmentation violation */ -#define SIGUSR2 12 /* user defined signal # 2 */ -#define SIGPIPE 13 /* write on a pipe with no one to read it */ -#define SIGALRM 14 /* alarm clock */ -#define SIGTERM 15 /* software termination signal from kill */ -#define SIGEMT 16 /* EMT instruction */ -#define SIGCHLD 17 /* child process terminated or stopped */ -#define SIGWINCH 21 /* window size has changed */ -#define SIGVTALRM 24 /* virtual alarm */ -#define SIGPROF 25 /* profiler alarm */ -#define SIGINFO 26 /* information request */ - -/* POSIX requires the following signals to be defined, even if they are - * not supported. Here are the definitions, but they are not supported. - */ -#define SIGCONT 18 /* continue if stopped */ -#define SIGSTOP 19 /* stop signal */ -#define SIGTSTP 20 /* interactive stop signal */ -#define SIGTTIN 22 /* background process wants to read */ -#define SIGTTOU 23 /* background process wants to write */ - -#if defined(__minix) && defined(_NETBSD_SOURCE) -#define SIGIOT SIGABRT /* for people who speak PDP-11 */ +#define _NSIG 64 -/* MINIX specific signals. These signals are not used by user proceses, - * but meant to inform system processes, like the PM, about system events. - * The order here determines the order signals are processed by system - * processes in user-space. Higher-priority signals should be first. - */ -/* Signals delivered by a signal manager. */ -#define SIGSNDELAY 27 /* end of delay for signal delivery */ - -#define SIGS_FIRST SIGHUP /* first system signal */ -#define SIGS_LAST SIGSNDELAY /* last system signal */ -#define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST) - -/* Signals delivered by the kernel. */ -#define SIGKMEM 28 /* kernel memory request pending */ -#define SIGKMESS 29 /* new kernel message */ -#define SIGKSIGSM 30 /* kernel signal pending for signal manager */ -#define SIGKSIG 31 /* kernel signal pending */ - -#define SIGK_FIRST SIGKMEM /* first kernel signal */ -#define SIGK_LAST SIGKSIG /* last kernel signal */ -#define IS_SIGK(signo) (signo>=SIGK_FIRST && signo<=SIGK_LAST) +#if defined(_NETBSD_SOURCE) +#define NSIG _NSIG -/* Termination signals for Minix system processes. */ -#define SIGS_IS_LETHAL(sig) \ - (sig == SIGILL || sig == SIGBUS || sig == SIGFPE || sig == SIGSEGV \ - || sig == SIGEMT || sig == SIGABRT) -#define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \ - || (sig == SIGKILL || sig == SIGPIPE)) -#define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT) +#endif /* _NETBSD_SOURCE */ -#endif /* defined(__minix) && deinfed(_NETBSD_SOURCE) */ +#define SIGHUP 1 /* hangup */ +#define SIGINT 2 /* interrupt */ +#define SIGQUIT 3 /* quit */ +#define SIGILL 4 /* illegal instruction (not reset when caught) */ +#define SIGTRAP 5 /* trace trap (not reset when caught) */ +#define SIGABRT 6 /* abort() */ +#define SIGIOT SIGABRT /* compatibility */ +#define SIGEMT 7 /* EMT instruction */ +#define SIGFPE 8 /* floating point exception */ +#define SIGKILL 9 /* kill (cannot be caught or ignored) */ +#define SIGBUS 10 /* bus error */ +#define SIGSEGV 11 /* segmentation violation */ +#define SIGSYS 12 /* bad argument to system call */ +#define SIGPIPE 13 /* write on a pipe with no one to read it */ +#define SIGALRM 14 /* alarm clock */ +#define SIGTERM 15 /* software termination signal from kill */ +#define SIGURG 16 /* urgent condition on IO channel */ +#define SIGSTOP 17 /* sendable stop signal not from tty */ +#define SIGTSTP 18 /* stop signal from tty */ +#define SIGCONT 19 /* continue a stopped process */ +#define SIGCHLD 20 /* to parent on child stop or exit */ +#define SIGTTIN 21 /* to readers pgrp upon background tty read */ +#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ +#define SIGIO 23 /* input/output possible signal */ +#define SIGXCPU 24 /* exceeded CPU time limit */ +#define SIGXFSZ 25 /* exceeded file size limit */ +#define SIGVTALRM 26 /* virtual time alarm */ +#define SIGPROF 27 /* profiling time alarm */ +#define SIGWINCH 28 /* window size changes */ +#define SIGINFO 29 /* information request */ +#define SIGUSR1 30 /* user defined signal 1 */ +#define SIGUSR2 31 /* user defined signal 2 */ +#define SIGPWR 32 /* power fail/restart (not reset when caught) */ + +#ifndef __minix +#ifdef _KERNEL +#define SIGRTMIN 33 /* Kernel only; not exposed to userland yet */ +#define SIGRTMAX 63 /* Kernel only; not exposed to userland yet */ +#endif +#endif #ifndef _KERNEL #include #endif -typedef void (*__sighandler_t)(int); - -/* Macros used as function pointers. */ -#define SIG_ERR ((__sighandler_t) -1) /* error return */ -#define SIG_DFL ((__sighandler_t) 0) /* default signal handling */ -#define SIG_IGN ((__sighandler_t) 1) /* ignore signal */ -#define SIG_HOLD ((__sighandler_t) 2) /* block signal */ -#define SIG_CATCH ((__sighandler_t) 3) /* catch signal */ +#define SIG_DFL ((void (*)(int)) 0) +#define SIG_IGN ((void (*)(int)) 1) +#define SIG_ERR ((void (*)(int)) -1) +#define SIG_HOLD ((void (*)(int)) 3) #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ defined(_NETBSD_SOURCE) +#if defined(_KERNEL) +#define sigaddset(s, n) __sigaddset(s, n) +#define sigdelset(s, n) __sigdelset(s, n) +#define sigismember(s, n) __sigismember(s, n) +#define sigemptyset(s) __sigemptyset(s) +#define sigfillset(s) __sigfillset(s) +#define sigplusset(s, t) __sigplusset(s, t) +#define sigminusset(s, t) __sigminusset(s, t) +#endif /* _KERNEL */ + #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ defined(_NETBSD_SOURCE) #include @@ -162,20 +145,39 @@ struct sigaction { #include /* sigcontext; codes for SIGILL, SIGFPE */ -/* Fields for sa_flags. */ -#define SA_ONSTACK 0x0001 /* deliver signal on alternate stack */ -#define SA_RESETHAND 0x0002 /* reset signal handler when signal caught */ -#define SA_NODEFER 0x0004 /* don't block signal while catching it */ -#define SA_RESTART 0x0008 /* automatic system call restart */ -#define SA_SIGINFO 0x0010 /* extended signal handling */ -#define SA_NOCLDWAIT 0x0020 /* don't create zombies */ -#define SA_NOCLDSTOP 0x0040 /* don't receive SIGCHLD when child stops */ - -/* POSIX requires these values for use with sigprocmask(2). */ -#define SIG_BLOCK 0 /* for blocking signals */ -#define SIG_UNBLOCK 1 /* for unblocking signals */ -#define SIG_SETMASK 2 /* for setting the signal mask */ -#define SIG_INQUIRE 4 /* for internal use only */ +#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) +#define SA_ONSTACK 0x0001 /* take signal on signal stack */ +#define SA_RESTART 0x0002 /* restart system call on signal return */ +#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */ +#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */ +#endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ +/* Only valid for SIGCHLD. */ +#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ +#define SA_NOCLDWAIT 0x0020 /* do not generate zombies on unwaited child */ +#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ + defined(_NETBSD_SOURCE) +#ifndef __minix +#define SA_SIGINFO 0x0040 /* take sa_sigaction handler */ +#endif +#endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */ +#if defined(_NETBSD_SOURCE) +#define SA_NOKERNINFO 0x0080 /* siginfo does not print kernel info on tty */ +#endif /*_NETBSD_SOURCE */ +#ifdef _KERNEL +#define SA_ALLBITS 0x00ff +#endif + +/* + * Flags for sigprocmask(): + */ +#define SIG_BLOCK 1 /* block specified signal set */ +#define SIG_UNBLOCK 2 /* unblock specified signal set */ +#define SIG_SETMASK 3 /* set specified signal set */ + +#ifdef __minix +#define SIG_INQUIRE 10 /* for internal use only */ +#endif #if defined(_NETBSD_SOURCE) typedef void (*sig_t)(int); /* type of signal function */ @@ -186,10 +188,12 @@ typedef void (*sig_t)(int); /* type of signal function */ /* * Flags used with stack_t/struct sigaltstack. */ -#define SS_ONSTACK 1 /* Process is executing on an alternate stack */ -#define SS_DISABLE 2 /* Alternate stack is disabled */ - -#define MINSIGSTKSZ 2048 /* Minimal stack size is 2k */ +#define SS_ONSTACK 0x0001 /* take signals on alternate stack */ +#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ +#ifdef _KERNEL +#define SS_ALLBITS 0x0005 +#endif +#define MINSIGSTKSZ 8192 /* minimum allowable stack */ #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ #endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ @@ -240,5 +244,47 @@ struct sigevent { */ __BEGIN_DECLS void (*signal(int, void (*)(int)))(int); +#if (_POSIX_C_SOURCE - 0) >= 200112L || defined(_NETBSD_SOURCE) +int sigqueue(pid_t, int, const union sigval); +#endif +#if defined(_NETBSD_SOURCE) +int sigqueueinfo(pid_t, const siginfo_t *); +#endif __END_DECLS + +#if defined(__minix) && defined(_NETBSD_SOURCE) + +/* MINIX specific signals. These signals are not used by user proceses, + * but meant to inform system processes, like the PM, about system events. + * The order here determines the order signals are processed by system + * processes in user-space. Higher-priority signals should be first. + */ +/* Signals delivered by a signal manager. */ + +#define SIGSNDELAY 70 /* end of delay for signal delivery */ + +#define SIGS_FIRST SIGHUP /* first system signal */ +#define SIGS_LAST SIGSNDELAY /* last system signal */ +#define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST) + +/* Signals delivered by the kernel. */ +#define SIGKMEM 71 /* kernel memory request pending */ +#define SIGKMESS 72 /* new kernel message */ +#define SIGKSIGSM 73 /* kernel signal pending for signal manager */ +#define SIGKSIG 74 /* kernel signal pending */ + +#define SIGK_FIRST SIGKMEM /* first kernel signal */ +#define SIGK_LAST SIGKSIG /* last kernel signal; _NSIG must cover it! */ +#define IS_SIGK(signo) (signo>=SIGK_FIRST && signo<=SIGK_LAST) + +/* Termination signals for Minix system processes. */ +#define SIGS_IS_LETHAL(sig) \ + (sig == SIGILL || sig == SIGBUS || sig == SIGFPE || sig == SIGSEGV \ + || sig == SIGEMT || sig == SIGABRT) +#define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \ + || (sig == SIGKILL || sig == SIGPIPE)) +#define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT) + +#endif /* __minix && _NETBSD_SOURCE */ + #endif /* !_SYS_SIGNAL_H_ */ diff --git a/sys/sys/sigtypes.h b/sys/sys/sigtypes.h index dd571f819..ae65a8181 100644 --- a/sys/sys/sigtypes.h +++ b/sys/sys/sigtypes.h @@ -56,41 +56,52 @@ typedef _BSD_SIZE_T_ size_t; #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ defined(_NETBSD_SOURCE) -typedef unsigned long sigset_t; + +typedef struct { + __uint32_t __bits[4]; +} sigset_t; /* * Macro for manipulating signal masks. */ -#ifndef __minix -#define __sigmask(n) (1 << (((unsigned int)(n) - 1))) -#else /* __minix */ -#define __sigmask(n) (1 << (unsigned int)(n)) -#endif /* !__minix */ -#define __sigaddset(s, n) \ - do { \ - *(s) = *(unsigned long *)(s) | __sigmask(n); \ - } while(0) -#define __sigdelset(s, n) \ - do { \ - *(s) = *(unsigned long *)(s) & ~__sigmask(n); \ - } while (0) - -#define __sigismember(s, n) (((*(const unsigned long *)(s)) & __sigmask(n)) != 0) -#define __sigemptyset(s) (*(unsigned long *)(s) = 0) -#define __sigsetequal(s1, s2) (*(unsigned long *)(s1) = *(unsigned long *)(s2)) -#define __sigfillset(s) (*(long *)(s) = -1L) -#define __sigplusset(s, t) \ - do { \ - *(t) = *(unsigned long *)(t) | *(unsigned long *)(s); \ - } while (0) -#define __sigminusset(s, t) \ - do { \ - *(t) = *(unsigned long *)(t) & ~*(unsigned long *)(s); \ - } while (0) -#define __sigandset(s, t) \ - do { \ - *(t) = *(unsigned long *)(t) & *(unsigned long *)(s); \ - } while (0) +#define __sigmask(n) (1 << (((unsigned int)(n) - 1) & 31)) +#define __sigword(n) (((unsigned int)(n) - 1) >> 5) +#define __sigaddset(s, n) ((s)->__bits[__sigword(n)] |= __sigmask(n)) +#define __sigdelset(s, n) ((s)->__bits[__sigword(n)] &= ~__sigmask(n)) +#define __sigismember(s, n) (((s)->__bits[__sigword(n)] & __sigmask(n)) != 0) +#define __sigemptyset(s) ((s)->__bits[0] = 0x00000000, \ + (s)->__bits[1] = 0x00000000, \ + (s)->__bits[2] = 0x00000000, \ + (s)->__bits[3] = 0x00000000) +#define __sigsetequal(s1,s2) ((s1)->__bits[0] == (s2)->__bits[0] && \ + (s1)->__bits[1] == (s2)->__bits[1] && \ + (s1)->__bits[2] == (s2)->__bits[2] && \ + (s1)->__bits[3] == (s2)->__bits[3]) +#define __sigfillset(s) ((s)->__bits[0] = 0xffffffff, \ + (s)->__bits[1] = 0xffffffff, \ + (s)->__bits[2] = 0xffffffff, \ + (s)->__bits[3] = 0xffffffff) +#define __sigplusset(s, t) \ + do { \ + (t)->__bits[0] |= (s)->__bits[0]; \ + (t)->__bits[1] |= (s)->__bits[1]; \ + (t)->__bits[2] |= (s)->__bits[2]; \ + (t)->__bits[3] |= (s)->__bits[3]; \ + } while (/* CONSTCOND */ 0) +#define __sigminusset(s, t) \ + do { \ + (t)->__bits[0] &= ~(s)->__bits[0]; \ + (t)->__bits[1] &= ~(s)->__bits[1]; \ + (t)->__bits[2] &= ~(s)->__bits[2]; \ + (t)->__bits[3] &= ~(s)->__bits[3]; \ + } while (/* CONSTCOND */ 0) +#define __sigandset(s, t) \ + do { \ + (t)->__bits[0] &= (s)->__bits[0]; \ + (t)->__bits[1] &= (s)->__bits[1]; \ + (t)->__bits[2] &= (s)->__bits[2]; \ + (t)->__bits[3] &= (s)->__bits[3]; \ + } while (/* CONSTCOND */ 0) #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) diff --git a/test/test3.c b/test/test3.c index 1d66ada5e..bcc1766ad 100644 --- a/test/test3.c +++ b/test/test3.c @@ -99,10 +99,10 @@ void test3a() if (sigdelset(&s, SIGUSR1) != 0) e(40); if (sigdelset(&s, SIGUSR2) != 0) e(41); - if (s != s1) e(42); + if (memcmp(&s, &s1, sizeof(s))) e(42); if (sigaddset(&s, SIGILL) != 0) e(43); - if (s == s1) e(44); + if (!memcmp(&s, &s1, sizeof(s))) e(42); if (sigfillset(&s) != 0) e(45); if (sigismember(&s, SIGABRT) != 1) e(46); diff --git a/test/test37.c b/test/test37.c index 17635b785..3e2e86d06 100644 --- a/test/test37.c +++ b/test/test37.c @@ -9,6 +9,7 @@ #include #include #include +#include #define ITERATIONS 2 #define SIGS 14 @@ -130,6 +131,7 @@ void test37a() if (sigismember(&s, SIGPIPE) != 0) e(15); if (sigismember(&s, SIGALRM) != 0) e(16); if (sigismember(&s, SIGTERM) != 0) e(17); + if (sigismember(&s, SIGPWR) != 0) e(17); /* Create a full set and see if any bits are off. */ if (sigfillset(&s) != 0) e(19); @@ -150,6 +152,7 @@ void test37a() if (sigismember(&s, SIGPIPE) != 1) e(35); if (sigismember(&s, SIGALRM) != 1) e(36); if (sigismember(&s, SIGTERM) != 1) e(37); + if (sigismember(&s, SIGPWR) != 1) e(37); /* Create an empty set, then turn on bits individually. */ if (sigemptyset(&s) != 0) e(39); @@ -158,6 +161,7 @@ void test37a() if (sigaddset(&s, SIGQUIT) != 0) e(42); if (sigaddset(&s, SIGILL) != 0) e(43); if (sigaddset(&s, SIGTRAP) != 0) e(44); + if (sigaddset(&s, SIGPWR) != 0) e(44); /* See if the bits just turned on are indeed on. */ if (sigismember(&s, SIGHUP) != 1) e(45); @@ -165,6 +169,7 @@ void test37a() if (sigismember(&s, SIGQUIT) != 1) e(47); if (sigismember(&s, SIGILL) != 1) e(48); if (sigismember(&s, SIGTRAP) != 1) e(49); + if (sigismember(&s, SIGPWR) != 1) e(49); /* The others should be turned off. */ if (sigismember(&s, SIGABRT) != 0) e(50); @@ -184,6 +189,7 @@ void test37a() if (sigdelset(&s, SIGQUIT) != 0) e(64); if (sigdelset(&s, SIGILL) != 0) e(65); if (sigdelset(&s, SIGTRAP) != 0) e(66); + if (sigdelset(&s, SIGPWR) != 0) e(66); if (sigismember(&s, SIGHUP) != 0) e(67); if (sigismember(&s, SIGINT) != 0) e(68); @@ -200,6 +206,7 @@ void test37a() if (sigismember(&s, SIGPIPE) != 0) e(80); if (sigismember(&s, SIGALRM) != 0) e(81); if (sigismember(&s, SIGTERM) != 0) e(82); + if (sigismember(&s, SIGPWR) != 0) e(82); } void func1(sig) @@ -214,6 +221,26 @@ int sig; sig2++; } + +int sigmemcmp(sigset_t *s1, sigset_t *s2, int size) +{ + int i; + int mismatch = 0; + assert(size == sizeof(sigset_t)); + for(i = 1; i < _NSIG; i++) { + if(sigismember(s1, i) && !sigismember(s2, i)) { + fprintf(stderr, "sig %d set in first but not in 2nd\n", i); + mismatch = 1; + } + if(!sigismember(s1, i) && sigismember(s2, i)) { + fprintf(stderr, "sig %d not set in first but is in 2nd\n", i); + mismatch = 1; + } + } + + return mismatch; +} + void test37b() { /* Test sigprocmask and sigpending. */ @@ -260,8 +287,8 @@ void test37b() osa.sa_flags = 0; if (sigaction(SIGHUP, &sa, &osa) != 0) e(9); if (osa.sa_handler != SIG_DFL) e(10); - if (osa.sa_mask != 0) e(11); - if (osa.sa_flags != s_empty) e(12); + if (sigmemcmp(&osa.sa_mask, &s_empty, sizeof(s_empty))) e(11); + if (osa.sa_flags != 0) e(12); /* Replace action and see if old value is read back correctly. */ sa.sa_handler = func2; @@ -272,7 +299,7 @@ void test37b() osa.sa_flags = 0; if (sigaction(SIGHUP, &sa, &osa) != 0) e(13); if (osa.sa_handler != func1) e(14); - if (osa.sa_mask != s_ill) e(15); + if (sigmemcmp(&osa.sa_mask, &s_ill, sizeof(s_ill))) e(15); if (osa.sa_flags != SA_NODEFER && osa.sa_flags != (SA_NODEFER | SA_NOCLDSTOP)) e(16); @@ -284,7 +311,7 @@ void test37b() osa.sa_flags = 0; if (sigaction(SIGHUP, &sa, &osa) != 0) e(17); if (osa.sa_handler != func2) e(18); - if (osa.sa_mask != s_ill_pip) e(19); + if (sigmemcmp(&osa.sa_mask, &s_ill_pip, sizeof(s_ill_pip))) e(19); if (osa.sa_flags != (SA_RESETHAND | SA_NODEFER)) e(20); /* Test sigprocmask(SIG_SETMASK, ...). */ @@ -292,65 +319,65 @@ void test37b() if (sigemptyset(&s1) != 0) e(19); errno = 0; if (sigprocmask(SIG_SETMASK, &s_empty, &s1) != 0) e(20); /* block none */ - if (s1 != s_nokill_stop) e(21); + if (sigmemcmp(&s1, &s_nokill_stop, sizeof(s1))) e(21); if (sigprocmask(SIG_SETMASK, &s_ill, &s1) != 0) e(22); /* block SIGILL */ errno = 0; - if (s1 != s_empty) e(23); + if (sigmemcmp(&s1, &s_empty, sizeof(s1))) e(23); if (sigprocmask(SIG_SETMASK, &s_ill_pip, &s1) != 0) e(24); /* SIGILL+PIP */ - if (s1 != s_ill) e(25); + if (sigmemcmp(&s1, &s_ill, sizeof(s1))) e(25); if (sigprocmask(SIG_SETMASK, &s_full, &s1) != 0) e(26); /* block all */ - if (s1 != s_ill_pip) e(27); + if (sigmemcmp(&s1, &s_ill_pip, sizeof(s1))) e(27); /* Test sigprocmask(SIG_UNBLOCK, ...) */ if (sigprocmask(SIG_UNBLOCK, &s_ill, &s1) != 0) e(28); - if (s1 != s_nokill_stop) e(29); + if (sigmemcmp(&s1, &s_nokill_stop, sizeof(s1))) e(29); if (sigprocmask(SIG_UNBLOCK, &s_ill_pip, &s1) != 0) e(30); s = s_nokill_stop; if (sigdelset(&s, SIGILL) != 0) e(31); - if (s != s1) e(32); + if (sigmemcmp(&s, &s1, sizeof(s))) e(32); if (sigprocmask(SIG_UNBLOCK, &s_empty, &s1) != 0) e(33); s = s_nokill_stop; if (sigdelset(&s, SIGILL) != 0) e(34); if (sigdelset(&s, SIGPIPE) != 0) e(35); - if (s != s1) e(36); + if (sigmemcmp(&s, &s1, sizeof(s))) e(36); s1 = s_nokill_stop; if (sigprocmask(SIG_SETMASK, &s_empty, &s1) != 0) e(37); - if (s != s1) e(38); + if (sigmemcmp(&s, &s1, sizeof(s))) e(38); /* Test sigprocmask(SIG_BLOCK, ...) */ if (sigprocmask(SIG_BLOCK, &s_ill, &s1) != 0) e(39); - if (s1 != s_empty) e(40); + if (sigmemcmp(&s1, &s_empty, sizeof(s1))) e(40); if (sigprocmask(SIG_BLOCK, &s_ill_pip, &s1) != 0) e(41); - if (s1 != s_ill) e(42); + if (sigmemcmp(&s1, &s_ill, sizeof(s1))) e(42); if (sigprocmask(SIG_SETMASK, &s_full, &s1) != 0) e(43); - if (s1 != s_ill_pip) e(44); + if (sigmemcmp(&s1, &s_ill_pip, sizeof(s1))) e(44); /* Check error condition. */ errno = 0; if (sigprocmask(20000, &s_full, &s1) != -1) e(45); if (errno != EINVAL) e(46); if (sigprocmask(SIG_SETMASK, &s_full, &s1) != 0) e(47); - if (s1 != s_nokill_stop) e(48); + if (sigmemcmp(&s1, &s_nokill_stop, sizeof(s1))) e(48); /* If second arg is 0, nothing is set. */ if (sigprocmask(SIG_SETMASK, (sigset_t *) NULL, &s1) != 0) e(49); - if (s1 != s_nokill_stop) e(50); + if (sigmemcmp(&s1, &s_nokill_stop, sizeof(s1))) e(50); if (sigprocmask(SIG_SETMASK, &s_ill_pip, &s1) != 0) e(51); - if (s1 != s_nokill_stop) e(52); + if (sigmemcmp(&s1, &s_nokill_stop, sizeof(s1))) e(52); if (sigprocmask(SIG_SETMASK, (sigset_t *) NULL, &s1) != 0) e(53); - if (s1 != s_ill_pip) e(54); + if (sigmemcmp(&s1, &s_ill_pip, sizeof(s1))) e(54); if (sigprocmask(SIG_BLOCK, (sigset_t *) NULL, &s1) != 0) e(55); - if (s1 != s_ill_pip) e(56); + if (sigmemcmp(&s1, &s_ill_pip, sizeof(s1))) e(56); if (sigprocmask(SIG_UNBLOCK, (sigset_t *) NULL, &s1) != 0) e(57); - if (s1 != s_ill_pip) e(58); + if (sigmemcmp(&s1, &s_ill_pip, sizeof(s1))) e(58); /* Trying to block SIGKILL is not allowed, but is not an error, either. */ s = s_empty; if (sigaddset(&s, SIGKILL) != 0) e(59); if (sigprocmask(SIG_BLOCK, &s, &s1) != 0) e(60); - if (s1 != s_ill_pip) e(61); + if (sigmemcmp(&s1, &s_ill_pip, sizeof(s1))) e(61); if (sigprocmask(SIG_SETMASK, &s_full, &s1) != 0) e(62); - if (s1 != s_ill_pip) e(63); + if (sigmemcmp(&s1, &s_ill_pip, sizeof(s1))) e(63); /* Test sigpending. At this moment, all signals are blocked. */ sa.sa_handler = func2; @@ -361,11 +388,11 @@ void test37b() if (sigpending(&s) != 0) e(65); if (sigemptyset(&s1) != 0) e(66); if (sigaddset(&s1, SIGHUP) != 0) e(67); - if (s != s1) e(68); + if (sigmemcmp(&s, &s1, sizeof(s))) e(68); sa.sa_handler = SIG_IGN; if (sigaction(SIGHUP, &sa, &osa) != 0) e(69); if (sigpending(&s) != 0) e(70); - if (s != s_empty) e(71); + if (sigmemcmp(&s, &s_empty, sizeof(s))) e(71); } /*---------------------------------------------------------------------------*/ @@ -489,7 +516,7 @@ void test37d() z = 0; act.sa_handler = catch3; - act.sa_mask = 0; + sigemptyset(&act.sa_mask); act.sa_flags = SA_NODEFER; /* Otherwise, nested occurence of * SIGINT is blocked. */ if (sigaction(SIGHUP, &act, (struct sigaction *) NULL) != 0) e(2); @@ -509,6 +536,7 @@ int signo; { sigset_t oset; sigset_t set; + int i; if (sigemptyset(&set) == -1) e(5001); if (sigaddset(&set, SIGTERM) == -1) e(5002); @@ -516,7 +544,7 @@ int signo; if (sigaddset(&set, SIGINT) == -1) e(5004); if (sigaddset(&set, SIGPIPE) == -1) e(5005); if (sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset) != 0) e(5006); - if (oset != set) e(5007); + if (sigmemcmp(&oset, &set, sizeof(set))) e(5007); } void test37e() @@ -541,7 +569,7 @@ void test37e() if (sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset) == -1) e(7); if (sigemptyset(&set) == -1) e(8); if (sigaddset(&set, SIGPIPE) == -1) e(9); - if (set != oset) e(10); + if (sigmemcmp(&set, &oset, sizeof(set))) e(10); } /*---------------------------------------------------------------------------*/ @@ -844,11 +872,11 @@ void test37j() if (sigpending(&set) == -1) e(8); if (sigemptyset(&set2) == -1) e(9); if (sigaddset(&set2, SIGHUP) == -1) e(10); - if (set2 != set) e(11); + if (sigmemcmp(&set2, &set, sizeof(set))) e(11); alarm(6); sleep(7); if (sigpending(&set) == -1) e(12); - if (set != set2) e(13); + if (sigmemcmp(&set, &set2, sizeof(set))) e(13); if (y != 0) e(14); if (z != 1) e(15); } @@ -874,20 +902,25 @@ void test37l() void _name(void) \ { \ _type jb; \ - sigset_t ss, ssexp; \ + sigset_t ss, ss2, ss_orig; \ \ subtest = _subtest; \ clearsigstate(); \ \ - ss = 0x32; \ + sigemptyset(&ss); sigemptyset(&ss2); \ + sigaddset(&ss, 2); sigaddset(&ss, 4); sigaddset(&ss, 5); \ + sigaddset(&ss2, 20); sigaddset(&ss2, 22); sigaddset(&ss2, 65); \ + memcpy(&ss_orig, &ss, sizeof(ss)); \ if (sigprocmask(SIG_SETMASK, &ss, (sigset_t *)NULL) == -1) e(1); \ if (_setjmp) { \ + sigset_t ssexp; \ if (sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &ss) == -1) e(2); \ - ssexp = _save ? 0x32 : 0x3abc; \ - if ((ss ^ ssexp) & ~(1 << SIGKILL)) e(388); \ + ssexp = _save ? ss_orig : ss2; \ + sigdelset(&ssexp, SIGKILL); \ + if (sigmemcmp(&ss, &ssexp, sizeof(ss))) e(388); \ return; \ } \ - ss = 0x3abc; \ + ss = ss2; \ if (sigprocmask(SIG_SETMASK, &ss, (sigset_t *)NULL) == -1) e(4); \ _longjmp; \ } @@ -936,7 +969,7 @@ void test37n() y = 0; act.sa_flags = 0; - act.sa_mask = 0; + sigemptyset(&act.sa_mask); act.sa_handler = (sighandler_t) catch14; /* fudge */ if (sigaction(SIGSEGV, &act, (struct sigaction *) NULL) == -1) e(3); if (kill(getpid(), SIGSEGV) == -1) e(4); @@ -972,7 +1005,7 @@ void test37o() z = 0; act.sa_flags = 0; - act.sa_mask = 0; + sigemptyset(&act.sa_mask); act.sa_handler = catch15; if (sigaction(SIGALRM, &act, (struct sigaction *) NULL) == -1) e(2); diff --git a/test/test4.c b/test/test4.c index 3cf6c9fa5..e7156bf4b 100644 --- a/test/test4.c +++ b/test/test4.c @@ -55,9 +55,9 @@ void subr() /* Parent 3 */ if (pid3 < 0) nofork(); for (i = 0; i < 10000; i++); - kill(pid2, 9); - kill(pid1, 9); - kill(pid0, 9); + kill(pid2, SIGKILL); + kill(pid1, SIGKILL); + kill(pid0, SIGKILL); wait(&s); wait(&s); wait(&s); diff --git a/test/test5.c b/test/test5.c index 7a7757d96..7650ee6db 100644 --- a/test/test5.c +++ b/test/test5.c @@ -17,7 +17,7 @@ int max_error = 3; int subtest; int zero[1024]; -int sigmap[5] = {9, 10, 11}; +int sigmap[5] = {SIGKILL, SIGUSR1, SIGSEGV}; int main(int argc, char *argv[]); @@ -73,8 +73,8 @@ void test5a() for (zp = &zero[0]; zp < &zero[1024]; zp++) if (*zp != 0) flag = 1; if (flag) e(0); /* check if bss is cleared to 0 */ - if (signal(1, func1) == SIG_ERR) e(1); - if (signal(10, func10) == SIG_ERR) e(2); + if (signal(SIGHUP, func1) == SIG_ERR) e(1); + if (signal(SIGUSR1, func10) == SIG_ERR) e(2); parpid = getpid(); if ((childpid = fork()) != 0) { if (childpid < 0) ex(); @@ -82,8 +82,8 @@ void test5a() } else { child(parpid); } - if (signal(1, SIG_DFL) == SIG_ERR) e(4); - if (signal(10, SIG_DFL) == SIG_ERR) e(5); + if (signal(SIGHUP, SIG_DFL) == SIG_ERR) e(4); + if (signal(SIGUSR1, SIG_DFL) == SIG_ERR) e(5); } void parent(childpid) @@ -92,7 +92,7 @@ int childpid; int i, pid; for (i = 0; i < 3; i++) { - if (kill(childpid, 1) < 0) e(6); + if (kill(childpid, SIGHUP) < 0) e(6); while (parsigs == 0); parsigs--; } @@ -109,7 +109,7 @@ int parpid; for (i = 0; i < 3; i++) { while (childsigs == 0); childsigs--; - if (kill(parpid, 10) < 0) e(9); + if (kill(parpid, SIGUSR1) < 0) e(9); } exit(6); } @@ -117,7 +117,7 @@ int parpid; void func1(s) int s; /* for ANSI */ { - if (signal(1, func1) == SIG_ERR) e(10); + if (signal(SIGHUP, func1) == SIG_ERR) e(10); childsigs++; } @@ -129,7 +129,7 @@ int s; void func10(s) int s; /* for ANSI */ { - if (signal(10, func10) == SIG_ERR) e(11); + if (signal(SIGUSR1, func10) == SIG_ERR) e(11); parsigs++; } @@ -150,7 +150,7 @@ void test5b() if (pid < 0) ex(); if ((cpid = fork()) != 0) { if (cpid < 0) ex(); - if (kill(cpid, 9) < 0) e(12); + if (kill(cpid, SIGKILL) < 0) e(12); if (wait(&n) < 0) e(13); if (wait(&n) < 0) e(14); if (wait(&n) < 0) e(15); @@ -214,14 +214,14 @@ void test5e() int n; subtest = 5; - if (signal(8, func8) == SIG_ERR) e(25); + if (signal(SIGFPE, func8) == SIG_ERR) e(25); if ((n = fork()) != 0) { /* Parent must delay to give child a chance to pause. */ if (n < 0) ex(); sleep(1); - if (kill(n, 8) < 0) e(26); + if (kill(n, SIGFPE) < 0) e(26); if (wait(&n) < 0) e(27); - if (signal(8, SIG_DFL) == SIG_ERR) e(28); + if (signal(SIGFPE, SIG_DFL) == SIG_ERR) e(28); } else { (void) pause(); if (errno != EINTR && -errno != EINTR) e(29); @@ -265,11 +265,11 @@ void test5g() int n; subtest = 7; - signal(11, func11); - signal(11, SIG_IGN); + signal(SIGSEGV, func11); + signal(SIGSEGV, SIG_IGN); n = getpid(); - if (kill(n, 11) != 0) e(1); - signal(11, SIG_DFL); + if (kill(n, SIGSEGV) != 0) e(1); + signal(SIGSEGV, SIG_DFL); } void funcalrm(s) @@ -287,7 +287,7 @@ void test5h() subtest = 8; unlink("XXX.test5"); - if (signal(8, func8) == SIG_ERR) e(1); + if (signal(SIGFPE, func8) == SIG_ERR) e(1); pipe(fd); if ((n = fork()) != 0) { /* Parent must delay to give child a chance to pause. */ @@ -295,9 +295,9 @@ void test5h() while (access("XXX.test5", 0) != 0) /* just wait */ ; sleep(1); unlink("XXX.test5"); - if (kill(n, 8) < 0) e(2); + if (kill(n, SIGFPE) < 0) e(2); if (wait(&n) < 0) e(3); - if (signal(8, SIG_DFL) == SIG_ERR) e(4); + if (signal(SIGFPE, SIG_DFL) == SIG_ERR) e(4); if (close(fd[0]) != 0) e(5); if (close(fd[1]) != 0) e(6); } else {