+#include <sys/_types.h>
+
+#include <machine/_mcontext.h>
+
+#ifndef KERNEL
+#include <sys/_pthread/_pthread_attr_t.h>
+#endif /* KERNEL */
+
+#include <sys/_types/_sigaltstack.h>
+#include <sys/_types/_ucontext.h>
+
+#include <sys/_types/_pid_t.h>
+#include <sys/_types/_sigset_t.h>
+#include <sys/_types/_size_t.h>
+#include <sys/_types/_uid_t.h>
+
+union sigval {
+ /* Members as suggested by Annex C of POSIX 1003.1b. */
+ int sival_int;
+ void *sival_ptr;
+};
+
+#define SIGEV_NONE 0 /* No async notification */
+#define SIGEV_SIGNAL 1 /* aio - completion notification */
+#define SIGEV_THREAD 3 /* [NOTIMP] [RTS] call notification function */
+
+#ifndef KERNEL
+struct sigevent {
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union sigval sigev_value; /* Signal value */
+ void (*sigev_notify_function)(union sigval); /* Notification function */
+ pthread_attr_t *sigev_notify_attributes; /* Notification attributes */
+};
+#endif /* KERNEL */
+
+#ifdef BSD_KERNEL_PRIVATE
+
+union user64_sigval {
+ struct {
+ uint32_t pad; /* assumes Motorola byte order */
+ int32_t sival_int;
+ } size_equivalent;
+ user64_addr_t sival_ptr;
+};
+
+union user32_sigval {
+ /* Members as suggested by Annex C of POSIX 1003.1b. */
+ int32_t sival_int;
+ user32_addr_t sival_ptr;
+};
+
+union user_sigval {
+ struct {
+ uint32_t pad; /* assumes Motorola byte order */
+ int32_t sival_int;
+ } size_equivalent;
+ user_addr_t sival_ptr;
+};
+
+struct user64_sigevent {
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union user64_sigval sigev_value; /* Signal value */
+ user64_addr_t sigev_notify_function; /* Notify function */
+ user64_addr_t sigev_notify_attributes; /* Notify attributes */
+};
+
+struct user32_sigevent {
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union user32_sigval sigev_value; /* Signal value */
+ user32_addr_t sigev_notify_function; /* Notify function */
+ user32_addr_t sigev_notify_attributes; /* Notify attributes */
+};
+
+struct user_sigevent {
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union user_sigval sigev_value; /* Signal value */
+ user_addr_t sigev_notify_function; /* Notify function */
+ user_addr_t sigev_notify_attributes; /* Notify attributes */
+};
+
+#endif /* BSD_KERNEL_PRIVATE */
+
+typedef struct __siginfo {
+ int si_signo; /* signal number */
+ int si_errno; /* errno association */
+ int si_code; /* signal code */
+ pid_t si_pid; /* sending process */
+ uid_t si_uid; /* sender's ruid */
+ int si_status; /* exit value */
+ void *si_addr; /* faulting instruction */
+ union sigval si_value; /* signal value */
+ long si_band; /* band event for SIGPOLL */
+ unsigned long __pad[7]; /* Reserved for Future Use */
+} siginfo_t;
+
+#ifdef BSD_KERNEL_PRIVATE
+
+typedef struct user_siginfo {
+ int si_signo; /* signal number */
+ int si_errno; /* errno association */
+ int si_code; /* signal code */
+ pid_t si_pid; /* sending process */
+ uid_t si_uid; /* sender's ruid */
+ int si_status; /* exit value */
+ user_addr_t si_addr; /* faulting instruction (see below) */
+ union user_sigval si_value; /* signal value */
+ user_long_t si_band; /* band event for SIGPOLL */
+ user_ulong_t pad[7]; /* Reserved for Future Use */
+} user_siginfo_t;
+
+typedef struct user64_siginfo {
+ int si_signo; /* signal number */
+ int si_errno; /* errno association */
+ int si_code; /* signal code */
+ pid_t si_pid; /* sending process */
+ uid_t si_uid; /* sender's ruid */
+ int si_status; /* exit value */
+ user64_addr_t si_addr; /* faulting instruction (see below) */
+ union user64_sigval si_value; /* signal value */
+ user64_long_t si_band; /* band event for SIGPOLL */
+ user64_ulong_t __pad[7]; /* Reserved for Future Use */
+} user64_siginfo_t;
+
+typedef struct user32_siginfo {
+ int si_signo; /* signal number */
+ int si_errno; /* errno association */
+ int si_code; /* signal code */
+ pid_t si_pid; /* sending process */
+ uid_t si_uid; /* sender's ruid */
+ int si_status; /* exit value */
+ user32_addr_t si_addr; /* faulting instruction (see below) */
+ union user32_sigval si_value; /* signal value */
+ user32_long_t si_band; /* band event for SIGPOLL */
+ user32_ulong_t __pad[7]; /* Reserved for Future Use */
+} user32_siginfo_t;
+
+void siginfo_user_to_user32(user_siginfo_t *, user32_siginfo_t *);
+void siginfo_user_to_user64(user_siginfo_t *, user64_siginfo_t *);
+
+#endif /* BSD_KERNEL_PRIVATE */
+
+/*
+ * When the signal is SIGILL or SIGFPE, si_addr contains the address of
+ * the faulting instruction.
+ * When the signal is SIGSEGV or SIGBUS, si_addr contains the address of
+ * the faulting memory reference. Although for x86 there are cases of SIGSEGV
+ * for which si_addr cannot be determined and is NULL.
+ * If the signal is SIGCHLD, the si_pid field will contain the child process ID,
+ * si_status contains the exit value or signal and
+ * si_uid contains the real user ID of the process that sent the signal.
+ */
+
+/* Values for si_code */
+
+/* Codes for SIGILL */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define ILL_NOOP 0 /* if only I knew... */
+#endif
+#define ILL_ILLOPC 1 /* [XSI] illegal opcode */
+#define ILL_ILLTRP 2 /* [XSI] illegal trap */
+#define ILL_PRVOPC 3 /* [XSI] privileged opcode */
+#define ILL_ILLOPN 4 /* [XSI] illegal operand -NOTIMP */
+#define ILL_ILLADR 5 /* [XSI] illegal addressing mode -NOTIMP */
+#define ILL_PRVREG 6 /* [XSI] privileged register -NOTIMP */
+#define ILL_COPROC 7 /* [XSI] coprocessor error -NOTIMP */
+#define ILL_BADSTK 8 /* [XSI] internal stack error -NOTIMP */
+
+/* Codes for SIGFPE */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define FPE_NOOP 0 /* if only I knew... */
+#endif
+#define FPE_FLTDIV 1 /* [XSI] floating point divide by zero */
+#define FPE_FLTOVF 2 /* [XSI] floating point overflow */
+#define FPE_FLTUND 3 /* [XSI] floating point underflow */
+#define FPE_FLTRES 4 /* [XSI] floating point inexact result */
+#define FPE_FLTINV 5 /* [XSI] invalid floating point operation */
+#define FPE_FLTSUB 6 /* [XSI] subscript out of range -NOTIMP */
+#define FPE_INTDIV 7 /* [XSI] integer divide by zero */
+#define FPE_INTOVF 8 /* [XSI] integer overflow */
+
+/* Codes for SIGSEGV */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define SEGV_NOOP 0 /* if only I knew... */
+#endif
+#define SEGV_MAPERR 1 /* [XSI] address not mapped to object */
+#define SEGV_ACCERR 2 /* [XSI] invalid permission for mapped object */
+
+/* Codes for SIGBUS */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define BUS_NOOP 0 /* if only I knew... */
+#endif
+#define BUS_ADRALN 1 /* [XSI] Invalid address alignment */
+#define BUS_ADRERR 2 /* [XSI] Nonexistent physical address -NOTIMP */
+#define BUS_OBJERR 3 /* [XSI] Object-specific HW error - NOTIMP */
+
+/* Codes for SIGTRAP */
+#define TRAP_BRKPT 1 /* [XSI] Process breakpoint -NOTIMP */
+#define TRAP_TRACE 2 /* [XSI] Process trace trap -NOTIMP */
+
+/* Codes for SIGCHLD */
+#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+#define CLD_NOOP 0 /* if only I knew... */
+#endif
+#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 */
+};