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 Change-Id: I26494b8e0f27718628aab4c1f37eca924ad57cbf
This commit is contained in:
parent
01f5621580
commit
6999b62af8
|
|
@ -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.m_u.m_notify.interrupts);
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ void rs_interrupt(message *m)
|
|||
int i;
|
||||
rs232_t *rs;
|
||||
|
||||
irq_set= m->NOTIFY_ARG;
|
||||
irq_set= m->m_u.m_notify.interrupts;
|
||||
for (i= 0, rs = rs_lines; i<NR_RS_LINES; i++, rs++)
|
||||
{
|
||||
if (irq_set & (1 << rs->irq))
|
||||
|
|
|
|||
|
|
@ -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.m_u.m_notify.interrupts & rs_irq_set)
|
||||
rs_interrupt(&tty_mess);
|
||||
#endif
|
||||
/* run watchdogs of expired timers */
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -108,8 +108,7 @@
|
|||
(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
|
||||
|
||||
/*===========================================================================*
|
||||
* Messages for BUS controller drivers *
|
||||
|
|
@ -475,11 +474,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 SIG_ENDPT m_u.m_sigcalls.ep /* process number for inform */
|
||||
#define SIG_NUMBER m_u.m_sigcalls.sig /* signal number to send */
|
||||
#define SIG_FLAGS m_u.m_sigcalls.flags /* signal flags field */
|
||||
#define SIG_MAP m_u.m_sigcalls.sigs /* used to pass signal bit map */
|
||||
#define SIG_CTXT_PTR m_u.m_sigcalls.sigctx /* pointer to signal context */
|
||||
#define 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 */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <minix/ipcconst.h>
|
||||
#include <minix/type.h>
|
||||
#include <minix/const.h>
|
||||
#include <sys/signal.h>
|
||||
|
||||
/*==========================================================================*
|
||||
* Types relating to messages. *
|
||||
|
|
@ -18,6 +19,8 @@
|
|||
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;
|
||||
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 ever notify msg */
|
||||
unsigned int interrupts; /* only valid if from HARDWARE */
|
||||
sigset_t sigset; /* only valid if from SYSTEM */
|
||||
} mess_notify;
|
||||
|
||||
typedef struct {
|
||||
endpoint_t who;
|
||||
u32_t offset;
|
||||
|
|
@ -72,6 +81,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;
|
||||
int m_type; /* what kind of message is it */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -62,36 +62,28 @@ 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))
|
||||
#else
|
||||
int sigaddset(sigset_t *, int) __RENAME(__sigaddset14);
|
||||
int sigdelset(sigset_t *, int) __RENAME(__sigdelset14);
|
||||
int sigemptyset(sigset_t *) __RENAME(__sigemptyset14);
|
||||
int sigfillset(sigset_t *) __RENAME(__sigfillset14);
|
||||
int sigismember(const sigset_t *, int) __RENAME(__sigismember14);
|
||||
#endif
|
||||
int sigpending(sigset_t *) __RENAME(__sigpending14);
|
||||
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict)
|
||||
__RENAME(__sigprocmask14);
|
||||
|
|
@ -115,7 +107,6 @@ int *__errno(void);
|
|||
#define ___errno (*__errno())
|
||||
#endif
|
||||
|
||||
#if !defined(__minix) || !defined(_SYSTEM)
|
||||
__c99inline int
|
||||
sigaddset(sigset_t *set, int signo)
|
||||
{
|
||||
|
|
@ -161,7 +152,6 @@ sigfillset(sigset_t *set)
|
|||
__sigfillset(set);
|
||||
return (0);
|
||||
}
|
||||
#endif /* !defined(__minix) || !defined(_SYSTEM) */
|
||||
#endif /* __c99inline */
|
||||
#endif /* !__LIBC12_SOURCE__ */
|
||||
|
||||
|
|
@ -172,13 +162,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 +180,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 +193,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 */
|
||||
|
|
|
|||
|
|
@ -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)->m_u.m_notify.interrupts = 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)->m_u.m_notify.sigset, \
|
||||
&priv(dst_ptr)->s_sig_pending, \
|
||||
sizeof(sigset_t)); \
|
||||
sigemptyset(&priv(dst_ptr)->s_sig_pending); \
|
||||
break; \
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -393,7 +393,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->m_u.m_notify.interrupts);
|
||||
break;
|
||||
|
||||
case CLOCK:
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ sigset_t *set;
|
|||
message m;
|
||||
|
||||
if (_syscall(PM_PROC_NR, SIGPENDING, &m) < 0) return(-1);
|
||||
*set = (sigset_t) m.m2_l1;
|
||||
memcpy(set, &m.SIG_MAP, sizeof(*set));
|
||||
return(m.m_type);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <signal.h>
|
||||
|
|
@ -11,15 +14,21 @@ sigset_t *oset;
|
|||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
|
||||
sigemptyset(&m.SIG_MAP);
|
||||
|
||||
if (set == (sigset_t *) NULL) {
|
||||
m.m2_i1 = SIG_INQUIRE;
|
||||
m.m2_l1 = 0;
|
||||
m.SIG_HOW = SIG_INQUIRE;
|
||||
} else {
|
||||
m.m2_i1 = how;
|
||||
m.m2_l1 = (long) *set;
|
||||
m.SIG_HOW = how;
|
||||
memcpy(&m.SIG_MAP, set, sizeof(*set));
|
||||
}
|
||||
if (_syscall(PM_PROC_NR, SIGPROCMASK, &m) < 0) return(-1);
|
||||
if (oset != (sigset_t *) NULL) *oset = (sigset_t) (m.m2_l1);
|
||||
if (oset != (sigset_t *) NULL) {
|
||||
sigemptyset(oset);
|
||||
memcpy(oset, &m.SIG_MAP, sizeof(*oset));
|
||||
}
|
||||
return(m.m_type);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
#include <sys/cdefs.h>
|
||||
#include <lib.h>
|
||||
#include "namespace.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <lib.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;
|
||||
|
||||
|
|
@ -21,12 +23,14 @@ register struct sigcontext *scp;
|
|||
*/
|
||||
static message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
|
||||
/* Protect against race conditions by blocking all interrupts. */
|
||||
sigfillset(&set); /* splhi */
|
||||
sigprocmask(SIG_SETMASK, &set, (sigset_t *) NULL);
|
||||
|
||||
m.m2_l1 = scp->sc_mask;
|
||||
m.m2_i2 = scp->sc_flags;
|
||||
m.m2_p1 = (char *) scp;
|
||||
m.SIG_MAP = scp->sc_mask;
|
||||
m.SIG_FLAGS = scp->sc_flags;
|
||||
m.SIG_CTXT_PTR = (char *) scp;
|
||||
return(_syscall(PM_PROC_NR, SIGRETURN, &m)); /* normally this doesn't return */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ int sigsuspend(set)
|
|||
const sigset_t *set;
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m2_l1 = (long) *set;
|
||||
memset(&m, 0, sizeof(m));
|
||||
memcpy(&m.SIG_MAP, set, sizeof(*set));
|
||||
return(_syscall(PM_PROC_NR, SIGSUSPEND, &m));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -449,7 +449,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->m_u.m_notify.interrupts);
|
||||
break;
|
||||
|
||||
case CLOCK:
|
||||
|
|
|
|||
|
|
@ -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.m_u.m_notify.interrupts & (1 << i))
|
||||
{
|
||||
_ddekit_interrupt_trigger(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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->m_u.m_notify.interrupts);
|
||||
break;
|
||||
|
||||
case CLOCK:
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ 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->m_u.m_notify.sigset;
|
||||
for (signo = SIGK_FIRST; signo <= SIGK_LAST; signo++) {
|
||||
if (sigismember(&sigset, signo)) {
|
||||
/* Let the callback code handle the kernel signal. */
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@
|
|||
#define sig_osa m1_p2
|
||||
#define sig_ret m1_p3
|
||||
#define stat_nr m2_i1
|
||||
#define sig_set m2_l1
|
||||
#define sig_how m2_i1
|
||||
#define sig_context m2_p1
|
||||
#define reboot_flag m1_i1
|
||||
#define svrctl_req m2_i1
|
||||
#define svrctl_argp m2_p1
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ int do_sigaction()
|
|||
*===========================================================================*/
|
||||
int do_sigpending()
|
||||
{
|
||||
mp->mp_reply.reply_mask = (long) mp->mp_sigpending;
|
||||
memcpy(&mp->mp_reply.SIG_MAP, &mp->mp_sigpending, sizeof(sigset_t));
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
@ -111,30 +111,30 @@ int do_sigprocmask()
|
|||
|
||||
int i;
|
||||
|
||||
mp->mp_reply.reply_mask = (long) mp->mp_sigmask;
|
||||
memcpy(&mp->mp_reply.SIG_MAP, &mp->mp_sigmask, sizeof(mp->mp_sigmask));
|
||||
|
||||
switch (m_in.sig_how) {
|
||||
switch (m_in.SIG_HOW) {
|
||||
case SIG_BLOCK:
|
||||
sigdelset((sigset_t *)&m_in.sig_set, SIGKILL);
|
||||
sigdelset((sigset_t *)&m_in.sig_set, SIGSTOP);
|
||||
sigdelset(&m_in.SIG_MAP, SIGKILL);
|
||||
sigdelset(&m_in.SIG_MAP, SIGSTOP);
|
||||
for (i = 1; i < _NSIG; i++) {
|
||||
if (sigismember((sigset_t *)&m_in.sig_set, i))
|
||||
if (sigismember(&m_in.SIG_MAP, i))
|
||||
sigaddset(&mp->mp_sigmask, i);
|
||||
}
|
||||
break;
|
||||
|
||||
case SIG_UNBLOCK:
|
||||
for (i = 1; i < _NSIG; i++) {
|
||||
if (sigismember((sigset_t *)&m_in.sig_set, i))
|
||||
if (sigismember(&m_in.SIG_MAP, i))
|
||||
sigdelset(&mp->mp_sigmask, i);
|
||||
}
|
||||
check_pending(mp);
|
||||
break;
|
||||
|
||||
case SIG_SETMASK:
|
||||
sigdelset((sigset_t *) &m_in.sig_set, SIGKILL);
|
||||
sigdelset((sigset_t *) &m_in.sig_set, SIGSTOP);
|
||||
mp->mp_sigmask = (sigset_t) m_in.sig_set;
|
||||
sigdelset(&m_in.SIG_MAP, SIGKILL);
|
||||
sigdelset(&m_in.SIG_MAP, SIGSTOP);
|
||||
mp->mp_sigmask = m_in.SIG_MAP;
|
||||
check_pending(mp);
|
||||
break;
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ int do_sigprocmask()
|
|||
int do_sigsuspend()
|
||||
{
|
||||
mp->mp_sigmask2 = mp->mp_sigmask; /* save the old mask */
|
||||
mp->mp_sigmask = (sigset_t) m_in.sig_set;
|
||||
mp->mp_sigmask = m_in.SIG_MAP;
|
||||
sigdelset(&mp->mp_sigmask, SIGKILL);
|
||||
sigdelset(&mp->mp_sigmask, SIGSTOP);
|
||||
mp->mp_flags |= SIGSUSPENDED;
|
||||
|
|
@ -173,11 +173,11 @@ int do_sigreturn()
|
|||
|
||||
int r;
|
||||
|
||||
mp->mp_sigmask = (sigset_t) m_in.sig_set;
|
||||
mp->mp_sigmask = m_in.SIG_MAP;
|
||||
sigdelset(&mp->mp_sigmask, SIGKILL);
|
||||
sigdelset(&mp->mp_sigmask, SIGSTOP);
|
||||
|
||||
r = sys_sigreturn(who_e, (struct sigmsg *) m_in.sig_context);
|
||||
r = sys_sigreturn(who_e, (struct sigmsg *) m_in.SIG_CTXT_PTR);
|
||||
check_pending(mp);
|
||||
return(r);
|
||||
}
|
||||
|
|
@ -706,7 +706,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;
|
||||
|
||||
if (!(rmp->mp_flags & UNPAUSED))
|
||||
panic("sig_send: process not unpaused");
|
||||
|
|
@ -722,7 +722,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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
/minix/src/include/arch/i386/include/stackframe.h
|
||||
/home/minix/minix/330/src/include/arch/i386/include/stackframe.h
|
||||
226
sys/sys/signal.h
226
sys/sys/signal.h
|
|
@ -42,93 +42,73 @@
|
|||
#include <sys/featuretest.h>
|
||||
#include <sys/sigtypes.h>
|
||||
|
||||
#define _NSIG 28
|
||||
#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 27 /* 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 */
|
||||
|
||||
/* 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 26 /* end of delay for signal delivery */
|
||||
|
||||
#define SIGS_FIRST SIGHUP /* first system signal */
|
||||
#define SIGS_LAST SIGINFO /* 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) */
|
||||
#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) */
|
||||
#ifdef _KERNEL
|
||||
#define SIGRTMIN 33 /* Kernel only; not exposed to userland yet */
|
||||
#define SIGRTMAX 63 /* Kernel only; not exposed to userland yet */
|
||||
#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 +142,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 +185,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 +241,46 @@ 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 SIGPWR /* 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 */
|
||||
#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_ */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
101
test/test37.c
101
test/test37.c
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define ITERATIONS 2
|
||||
#define SIGS 14
|
||||
|
|
@ -214,6 +215,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 +281,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 +293,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 +305,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 +313,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 +382,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 +510,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 +530,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 +538,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 +563,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 +866,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 +896,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 +963,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 +999,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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user