+#define CLD_EXITED 1 /* [XSI] child has exited */
+#define CLD_KILLED 2 /* [XSI] terminated abnormally, no core file */
+#define CLD_DUMPED 3 /* [XSI] terminated abnormally, core file */
+#define CLD_TRAPPED 4 /* [XSI] traced child has trapped */
+#define CLD_STOPPED 5 /* [XSI] child has stopped */
+#define CLD_CONTINUED 6 /* [XSI] stopped child has continued */
+
+/* Codes for SIGPOLL */
+#define POLL_IN 1 /* [XSR] Data input available */
+#define POLL_OUT 2 /* [XSR] Output buffers available */
+#define POLL_MSG 3 /* [XSR] Input message available */
+#define POLL_ERR 4 /* [XSR] I/O error */
+#define POLL_PRI 5 /* [XSR] High priority input available */
+#define POLL_HUP 6 /* [XSR] Device disconnected */
+
+/* union for signal handlers */
+union __sigaction_u {
+ void (*__sa_handler)(int);
+ void (*__sa_sigaction)(int, struct __siginfo *,
+ void *);
+};
+
+/* Signal vector template for Kernel user boundary */
+struct __sigaction {
+ union __sigaction_u __sigaction_u; /* signal handler */
+ void (*sa_tramp)(void *, int, int, siginfo_t *, void *);
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+/*
+ * Signal vector "template" used in sigaction call.
+ */
+struct sigaction {
+ union __sigaction_u __sigaction_u; /* signal handler */
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+#ifdef BSD_KERNEL_PRIVATE
+#include <machine/types.h>
+
+union __user32_sigaction_u {
+ user32_addr_t __sa_handler;
+ user32_addr_t __sa_sigaction;
+};
+
+struct user32_sigaction {
+ union __user32_sigaction_u __sigaction_u; /* signal handler */
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+struct __user32_sigaction {
+ union __user32_sigaction_u __sigaction_u; /* signal handler */
+ user32_addr_t sa_tramp;
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+union __user64_sigaction_u {
+ user64_addr_t __sa_handler;
+ user64_addr_t __sa_sigaction;
+};
+
+struct user64_sigaction {
+ union __user64_sigaction_u __sigaction_u; /* signal handler */
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+struct __user64_sigaction {
+ union __user64_sigaction_u __sigaction_u; /* signal handler */
+ user64_addr_t sa_tramp; /* signal mask to apply */
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+union __kern_sigaction_u {
+ user_addr_t __sa_handler;
+ user_addr_t __sa_sigaction;
+};
+
+struct kern_sigaction {
+ union __kern_sigaction_u __sigaction_u; /* signal handler */
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+struct __kern_sigaction {
+ union __kern_sigaction_u __sigaction_u; /* signal handler */
+ user_addr_t sa_tramp; /* signal mask to apply */
+ sigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+#undef SIG_DFL
+#undef SIG_IGN
+#undef SIG_ERR
+#define SIG_DFL ((user_addr_t)0LL)
+#define SIG_IGN ((user_addr_t)1LL)
+#define SIG_ERR ((user_addr_t)-1LL)
+
+#endif /* BSD_KERNEL_PRIVATE */
+
+
+/* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */
+#define sa_handler __sigaction_u.__sa_handler
+#define sa_sigaction __sigaction_u.__sa_sigaction
+
+#define SA_ONSTACK 0x0001 /* take signal on signal stack */
+#define SA_RESTART 0x0002 /* restart system on signal return */
+#ifdef BSD_KERNEL_PRIVATE
+#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack - for user_sigaltstack.ss_flags only */
+#endif /* BSD_KERNEL_PRIVATE */
+#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
+#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
+#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
+#define SA_NOCLDWAIT 0x0020 /* don't keep zombies around */
+#define SA_SIGINFO 0x0040 /* signal handler with SA_SIGINFO args */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
+/* This will provide 64bit register set in a 32bit user address space */
+#define SA_64REGSET 0x0200 /* signal handler with SA_SIGINFO args with 64bit regs information */
+#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
+#ifdef BSD_KERNEL_PRIVATE
+#define SA_VALIDATE_SIGRETURN_FROM_SIGTRAMP 0x0400 /* use token to validate sigreturn was called from matching sigtramp */
+#endif /* BSD_KERNEL_PRIVATE */
+
+/* the following are the only bits we support from user space, the
+ * rest are for kernel use only.
+ */
+#define SA_USERSPACE_MASK (SA_ONSTACK | SA_RESTART | SA_RESETHAND | SA_NOCLDSTOP | SA_NODEFER | SA_NOCLDWAIT | SA_SIGINFO)