use netbsd <sys/signal.h> 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
This commit is contained in:
Ben Gras 2013-10-22 17:08:15 +02:00 committed by Lionel Sambuc
parent 6c3dfa5f3c
commit 8ccb12bb5a
48 changed files with 407 additions and 291 deletions

View file

@ -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:
/*

View file

@ -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);
}

View file

@ -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);

View file

@ -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; i<NR_RS_LINES; i++, rs++)
{
if (irq_set & (1 << rs->irq))

View file

@ -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 */

View file

@ -1,6 +1,8 @@
#ifndef _ARM_STACKFRAME_H
#define _ARM_STACKFRAME_H
#include <sys/types.h>
typedef u32_t reg_t; /* machine register */
struct stackframe_s {

View file

@ -1,6 +1,8 @@
#ifndef STACK_FRAME_H
#define STACK_FRAME_H
#include <sys/types.h>
typedef unsigned reg_t; /* machine register */
typedef reg_t segdesc_t;

View file

@ -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. */

View file

@ -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 */

View file

@ -4,6 +4,7 @@
#include <minix/ipcconst.h>
#include <minix/type.h>
#include <minix/const.h>
#include <sys/signal.h>
/*==========================================================================*
* 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

View file

@ -7,6 +7,7 @@
#endif
#include <sys/types.h>
#include <sys/sigtypes.h>
#include <stdint.h>
@ -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 */

View file

@ -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 */

View file

@ -34,6 +34,7 @@
#include <stddef.h>
#include <signal.h>
#include <assert.h>
#include <string.h>
#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; \
}

View file

@ -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 */

View file

@ -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);

View file

@ -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 */

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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:

View file

@ -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}

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -1,5 +1,8 @@
#include <sys/cdefs.h>
#include <sys/signal.h>
#include <sys/sigtypes.h>
#include <lib.h>
#include <string.h>
#include "namespace.h"
#include <string.h>
@ -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);
}

View file

@ -1,17 +1,19 @@
#include "namespace.h"
#include <sys/cdefs.h>
#include <lib.h>
#include "namespace.h"
#include <string.h>
#include <signal.h>
#include <string.h>
#include <sys/signal.h>
#include <machine/signal.h>
#ifdef __weak_alias
__weak_alias(sigreturn, _sigreturn)
#endif
int sigreturn(scp)
register struct sigcontext *scp;
int sigreturn(struct sigcontext *scp)
{
sigset_t set;

View file

@ -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));
}

View file

@ -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:

View file

@ -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);
}

View file

@ -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];

View file

@ -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:

View file

@ -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}

View file

@ -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);

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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));
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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");

View file

@ -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);

View file

@ -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 */
};

View file

@ -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;
};

View file

@ -42,93 +42,76 @@
#include <sys/featuretest.h>
#include <sys/sigtypes.h>
#define _NSIG 27
#define _NSIG 64
#if defined(_NETBSD_SOURCE)
#define NSIG _NSIG
#endif /* _NETBSD_SOURCE */
/* 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 */
#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&LTOSTOP) */
#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) */
/* 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 */
/* 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)
/* 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 /* defined(__minix) && deinfed(_NETBSD_SOURCE) */
#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 <sys/cdefs.h>
#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 <sys/siginfo.h>
@ -162,20 +145,39 @@ struct sigaction {
#include <machine/signal.h> /* 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 */
#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
/* 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 */
/*
* 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_ */

View file

@ -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)

View file

@ -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);

View file

@ -9,6 +9,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#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);

View file

@ -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);

View file

@ -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 {