#include <sys/signal.h>

#if 0
typedef int     sig_atomic_t;
#endif

#if defined(_POSIX_SOURCE) || defined(_QNX_SOURCE) || !defined(NO_EXT_KEYS)

#if __WATCOMC__ > 1000
#pragma pack(push,1);
#else
#pragma pack(1);
#endif

#define SI_FROMUSER(sip)	((sip)->si_code < 0)
#define SI_FROMKERNEL(sip)	((sip)->si_code > 0)

#define SI_USER				0
#define SI_RESERVE1			(-1)
#define SI_QUEUE			(-2)
#define SI_TIMER			(-3)
#define SI_ASYNCIO			(-4)
#define SI_MESGQ			(-5)
#define SI_RESERVE6			(-6)
#define SI_IRQ				(-7)
#define SI_PHOTON			(-8)
#define SI_SELECT			(-9)
#define SI_MINAVAIL			(-128)	/* QNX managers will never use this range */
#define SI_MAXAVAIL			(-64)

#define SI_MAXSZ	127

/*
 * SIGILL codes
 */
#define ILL_ILLOPC	1	/* Illegal opcode */
#define NSIGILL		1

/*
 * SIGSEGV codes
 */
#define SEGV_MAPERR	1	/* Address not mapped */
#define SEGV_ACCERR	2	/* No permissions */
#define SEGV_STKERR	2	/* Stack exception */
#define SEGV_GPERR	2	/* General protection */
#define SEGV_IRQERR	3	/* Interrupt handler fault */
#define NSIGSEGV	3

/*
 * SIGBUS codes
 */
#define BUS_ADRALN	1	/* Invalid address */
#define BUS_ADRERR	2	/* Non-existant physical address */
#define BUS_OBJERR	3	/* NMI parity error */
#define NSIGBUS		3

/*
 * SIGCHILD codes
 */
#define CLD_EXITED	1	/* Child has exited */
#define CLD_KILLED	2	/* Child was killed */
#define CLD_DUMPED	3	/* Child terminated abnormally */
#define CLD_TRAPPED	4	/* Traced child has trapped */
#define CLD_STOPPED	5	/* Child has stopped */
#define CLD_CONTINUED 6	/* Stopped child had continued */
#define NSIGCLD		6

/*
 * SIGTRAP codes
 */
#define TRAP_TRACE	2	/* Trace */
#define NSIGTRAP	2

/*
 * SIGFPE signal codes
 */
#define	FPE_INTDIV	1	/* Integer divide by zero */
#define	FPE_INTOVF	2	/* Integer overflow */
#define	FPE_FLTDIV	3	/* Floating point divide by zero */
#define	FPE_FLTOVF	4	/* Floating point overflow */
#define	FPE_FLTUND	5	/* Floating point underflow */
#define	FPE_FLTRES	6	/* Floating point inexact result */
#define	FPE_FLTINV	7	/* Invalid floating point operation */
#define	FPE_FLTSUB	8	/* Subscript out of range */
#define FPE_NOFPU	9	/* No FPU or emulator */
#define FPE_NOMEM	9	/* No kernel space for FPU save area */
#define	NSIGFPE		9

typedef struct {
	int		 si_signo;
	int		 si_code;
	int		 si_errno;
	union sigval	 si_value;
	void		*si_addr;
	int		 si_pid;
	int		 si_uid;
} siginfo_t;


#endif  /* _POSIX_SOURCE || _QNX_SOURCE || !NO_EXT_KEYS */

#if __WATCOMC__ > 1000
#pragma pack(pop);
#else
#pragma pack();
#endif

#define SIGCANCEL	29
#define NSIG		_SIGMAX

#define	__SIGEMPTYSET		0
#define	__SIGFILLSET		0xffffffff
#define	__SIGADDSET(s, n)	(*(s) |= 1 << ((n) - 1), 0)
#define	__SIGDELSET(s, n)	(*(s) &= ~(1 << ((n) - 1)), 0)
#define	__SIGISMEMBER(s, n)	((*(s) & (1 << ((n) - 1))) != 0)

