/*
 * $Header: /smsa/bsd:include/signal.h:bsd  1.4  $
 * $Source: /smsa/bsd:include/signal.h: $
 *
 * Copyright (c) 1988,1990 Acorn Computers Ltd., Cambridge, England
 */
/*
 * Copyright (c) 1982, 1986 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 *
 *	@(#)signal.h	7.1 (Berkeley) 6/4/86
 */

#ifndef	__signal_h
#define	__signal_h

#if (defined (_BSD_C) || defined(_XOPEN_C)) && !defined (NSIG)
#define NSIG	32
#endif

#define	SIGHUP	1	/* hangup    (normally from modem (tty)) */
#define	SIGINT	2	/* interrupt (normally ^C from keyboard) */
#define	SIGQUIT	3	/* quit      (normally ^\ from keyboard) */
#define	SIGILL	4	/* illegal instruction */
#if defined (_BSD_C)
/* Sub-codes for SIGILL */
#define	    ILL_RESAD_FAULT	0x0	/* reserved addressing fault */
#define	    ILL_PRIVIN_FAULT	0x1	/* privileged instruction fault */
#define	    ILL_RESOP_FAULT	0x2	/* reserved operand fault */
#endif/*_BSD_C*/
#define	SIGTRAP	5	/* trace trap */
#define	SIGABRT	6	/* ABORT signal (ANSI, X/Open) */
#define	SIGIOT	6	/* == "IOT instruction" - historical (PDP-11) */
#define	SIGEMT	7	/* "EMT instruction" - historical (PDP-11) */
#define	SIGFPE	8	/* floating point exception */
#if defined (_BSD_C)
#define	    FPE_INTOVF_TRAP	0x1	/* integer overflow */
#define	    FPE_INTDIV_TRAP	0x2	/* integer divide by zero */
#define	    FPE_FLTOVF_TRAP	0x3	/* floating overflow */
#define	    FPE_FLTDIV_TRAP	0x4	/* floating/decimal divide by zero */
#define	    FPE_FLTUND_TRAP	0x5	/* floating underflow */
#define	    FPE_DECOVF_TRAP	0x6	/* decimal overflow */
#define	    FPE_SUBRNG_TRAP	0x7	/* subscript out of range */
#define	    FPE_FLTOVF_FAULT	0x8	/* floating overflow fault */
#define	    FPE_FLTDIV_FAULT	0x9	/* divide by zero floating fault */
#define	    FPE_FLTUND_FAULT	0xa	/* floating underflow fault */
#define	    FPE_INVALID_OP      0xb     /* floating invalid operand */
#define     FPE_INEXACT         0xc	/* floating inexactitude! */
#endif/*_BSD_C*/
#define	SIGKILL	9	/* kill (cannot be caught or ignored) */
#define	SIGBUS	10	/* bus error (ARM/MEMC: data/prefetch abort) */
#define	SIGSEGV	11	/* segmentation violation (ARM: address exception) */
#define	SIGSYS	12	/* bad argument to system call, unknown sys call */
#define	SIGPIPE	13	/* write on a pipe with no one to read it */
#define	SIGALRM	14	/* alarm clock (real time alarm) */
#define	SIGTERM	15	/* software termination signal from kill command */
#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	SIGCLD	SIGCHLD	/* compatibility */
#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	SIGLOST 29	/* resource lost (eg, record-lock lost) */
#define SIGUSR1 30	/* user defined signal 1 */
#define SIGUSR2 31	/* user defined signal 2 */

#if defined (_BSD_C)
typedef int (*_signal_proc)();
#else
typedef void (*_signal_proc)();
#endif

typedef int sig_atomic_t;			/* ANSI */

#if defined (_BSD_C)
/*
 * Signal vector "template" used in sigvec call.
 */
struct	sigvec {
	_signal_proc	sv_handler;	/* signal handler */
	int		sv_mask;	/* signal mask to apply */
	int		sv_flags;	/* see signal options below */
};
#define SV_ONSTACK	0x0001	/* take signal on signal stack */
#define SV_INTERRUPT	0x0002	/* do not restart system on signal return */
#define SV_NOCLDSTOP	0x0004	/* do not generate SIGCHLD when children stop */
#define sv_onstack sv_flags	/* isn't compatibility wonderful! */

/*
 * Structure used in sigstack call.
 */
struct	sigstack {
	char	*ss_sp;			/* signal stack pointer */
	int	ss_onstack;		/* current status */
};

#ifndef __machine_fp_h
#include "machine/fp.h"
#endif
#ifndef __sys_types_h
#include "sys/types.h"
#endif

/*
 * Information pushed on stack when a signal is delivered.
 * This is used by the kernel to restore state following
 * execution of the signal handler.  It is also made available
 * to the handler to allow it to properly restore state if
 * a non-standard exit is performed.
 */
struct	sigcontext {
	int	sc_onstack;		/* sigstack state to restore */
	int	sc_mask;		/* signal mask to restore */
	int	sc_cpu_regs[16];	/* ARM cpu registers to restore */
	struct	fp_regs sc_fp_regs;	/* floating point register to restore */
};

struct	syslongjmpcontext {
	int	sc_onstack;		/* sigstack state to restore */
	int	sc_mask;		/* signal mask to restore */
	int	sc_r4, sc_r5, sc_r6;	/* r4-r6 to restore */
	int	sc_r7, sc_r8, sc_r9;	/* r7-r9 to restore */
	int	sc_sb;			/* static base (r10) to restore */
	int	sc_fp;			/* fp (r11) to restore */
	int	sc_spt;			/* sp temp (ip, r12) to restore */
	int	sc_sp;			/* sp (r13) to restore */
	int	sc_lr;			/* lr (r14) to restore */
	int	sc_pc;			/* pc (r15) to restore */
};
#endif/*_BSD_C*/

#define	SIG_DFL		((_signal_proc)0)
#define	SIG_IGN		((_signal_proc)1)
#define	SIG_ERR		((_signal_proc)(-1))

#ifdef	_KERNEL
#define	BADSIG		((_signal_proc)(-1))
#define	SIG_CATCH	((_signal_proc)2)
#define	SIG_HOLD	((_signal_proc)3)
#endif/*_KERNEL*/

#if defined (_BSD_C)
/*
 * Macro for converting signal number to a mask suitable for
 * sigblock().
 */
#define sigmask(m)	(1 << ((m)-1))
#endif/*_BSD_C*/

#if defined (_XOPEN_C)
typedef int sigset_t;

struct sigaction {
    _signal_proc sa_handler;
    sigset_t sa_mask;
    int sa_flags;
};

#define SA_NOCLDSTOP 1

#define SIG_BLOCK    0
#define SIG_UNBLOCK  1
#define SIG_SETMASK  2
#endif/*_XOPEN_C*/

#ifndef _KERNEL
extern int raise (int __sig);			/* ANSI */

#if defined (_BSD_C)
extern int (*signal(int sig, _signal_proc proc))();
#else
extern void (*signal(int sig, _signal_proc proc))();
#endif

#if defined (_XOPEN_C)
extern int kill (int /*pid_t __pid*/, int __sig);
extern int sigaction (int __sig, struct sigaction *__act, struct sigaction *__oact);
extern int sigaddset (sigset_t *__set, int __sig);
extern int sigdelset (sigset_t *__set, int __sig);
extern int sigemptyset (sigset_t *__set);
extern int sigfillset (sigset_t *__set);
extern int sigismember (sigset_t *__set, int __sig);
extern int sigpending (sigset_t *__set);
extern int sigprocmask (int __how, sigset_t *__set, sigset_t *__oset);
extern int sigsuspend (sigset_t *__set);
#endif/*_XOPEN_C*/
#endif/*_KERNEL*/

#endif /*__signal_h*/

/* EOF signal.h */
