summaryrefslogtreecommitdiffstats
path: root/sys/sys/_sigset.h
diff options
context:
space:
mode:
authorcracauer <cracauer@FreeBSD.org>1999-07-06 07:13:48 +0000
committercracauer <cracauer@FreeBSD.org>1999-07-06 07:13:48 +0000
commit53573bf465904188986e8c982e8019835628d6b2 (patch)
tree3e7334c4226a10712d8c0459ab03a8d400a4eea7 /sys/sys/_sigset.h
parent0bb9e75fd21026c94438f2db514d21fd69b82377 (diff)
downloadFreeBSD-src-53573bf465904188986e8c982e8019835628d6b2.zip
FreeBSD-src-53573bf465904188986e8c982e8019835628d6b2.tar.gz
Implement SA_SIGINFO for i386. Thanks to Bruce Evans for much more
than a review, this was a nice puzzle. This is supposed to be binary and source compatible with older applications that access the old FreeBSD-style three arguments to a signal handler. Except those applications that access hidden signal handler arguments bejond the documented third one. If you have applications that do, please let me know so that we take the opportunity to provide the functionality they need in a documented manner. Also except application that use 'struct sigframe' directly. You need to recompile gdb and doscmd. `make world` is recommended. Example program that demonstrates how SA_SIGINFO and old-style FreeBSD handlers (with their three args) may be used in the same process is at http://www3.cons.org/tmp/fbsd-siginfo.c Programs that use the old FreeBSD-style three arguments are easy to change to SA_SIGINFO (although they don't need to, since the old style will still work): Old args to signal handler: void handler_sn(int sig, int code, struct sigcontext *scp) New args: void handler_si(int sig, siginfo_t *si, void *third) where: old:code == new:second->si_code old:scp == &(new:si->si_scp) /* Passed by value! */ The latter is also pointed to by new:third, but accessing via si->si_scp is preferred because it is type-save. FreeBSD implementation notes: - This is just the framework to make the interface POSIX compatible. For now, no additional functionality is provided. This is supposed to happen now, starting with floating point values. - We don't use 'sigcontext_t.si_value' for now (POSIX meant it for realtime-related values). - Documentation will be updated when new functionality is added and the exact arguments passed are determined. The comments in sys/signal.h are meant to be useful. Reviewed by: BDE
Diffstat (limited to 'sys/sys/_sigset.h')
-rw-r--r--sys/sys/_sigset.h76
1 files changed, 59 insertions, 17 deletions
diff --git a/sys/sys/_sigset.h b/sys/sys/_sigset.h
index 39d554e..471baa9 100644
--- a/sys/sys/_sigset.h
+++ b/sys/sys/_sigset.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)signal.h 8.4 (Berkeley) 5/4/95
- * $Id: signal.h,v 1.13 1998/03/28 11:50:43 dufault Exp $
+ * $Id: signal.h,v 1.14 1998/08/05 09:04:36 dfr Exp $
*/
#ifndef _SYS_SIGNAL_H_
@@ -113,6 +113,50 @@
*/
typedef void __sighandler_t __P((int));
+#if defined(_P1003_1B_VISIBLE_HISTORICALLY) || \
+ (!defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE))
+union sigval {
+ /* Members as suggested by Annex C of POSIX 1003.1b. */
+ int sigval_int;
+ void *sigval_ptr;
+};
+#endif /* !_ANSI_SOURCE && _P1003_1B_VISIBLE_HISTORICALLY */
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+/* POSIX 1003.1b required values. */
+#define SI_USER 0x10001
+#define SI_QUEUE 0x10002
+#define SI_TIMER 0x10003
+#define SI_ASYNCIO 0x10004
+#define SI_MESGQ 0x10005
+
+/* Additional FreeBSD values. */
+#define SI_UNDEFINED 0
+
+struct __siginfo {
+ struct sigcontext si_sc;
+ int si_signo; /* signal number */
+
+ /*
+ * Cause of signal, one of the SI_ macros or signal-specific
+ * values, i.e. one of the FPE_... values for SIGFPE. This
+ * value is equivalent to the second argument to an old-style
+ * FreeBSD signal handler.
+ */
+ int si_code;
+
+ union sigval si_value;
+};
+#else /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
+struct __siginfo;
+#endif /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
+
+typedef struct __siginfo siginfo_t;
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+typedef void __siginfohandler_t __P((int, siginfo_t *, void *));
+#endif /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
+
#define SIG_DFL ((__sighandler_t *)0)
#define SIG_IGN ((__sighandler_t *)1)
#define SIG_ERR ((__sighandler_t *)-1)
@@ -124,16 +168,26 @@ typedef unsigned int sigset_t;
* Signal vector "template" used in sigaction call.
*/
struct sigaction {
- __sighandler_t *sa_handler; /* signal handler */
+ union {
+ void (*__sa_handler) __P((int));
+ void (*__sa_sigaction) __P((int, siginfo_t *, void *));
+ } __sigaction_u; /* signal handler */
sigset_t sa_mask; /* signal mask to apply */
int sa_flags; /* see signal options below */
};
+/* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */
+#define sa_handler __sigaction_u.__sa_handler
+#ifndef _POSIX_SOURCE
+#define sa_sigaction __sigaction_u.__sa_sigaction
+#endif
+
#ifndef _POSIX_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 */
#define SA_NOCLDWAIT 0x0020 /* don't keep zombies around */
+#define SA_SIGINFO 0x0040 /* signal handler with SA_SIGINFO args */
#ifdef COMPAT_SUNOS
#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
#endif
@@ -183,6 +237,7 @@ struct sigvec {
#define SV_RESETHAND SA_RESETHAND
#define SV_NODEFER SA_NODEFER
#define SV_NOCLDSTOP SA_NOCLDSTOP
+#define SV_SIGINFO SA_SIGINFO
#define sv_onstack sv_flags /* isn't compatibility wonderful! */
/*
@@ -204,20 +259,7 @@ struct sigstack {
#endif /* !_POSIX_SOURCE */
#endif /* !_ANSI_SOURCE */
-#ifdef _P1003_1B_VISIBLE_HISTORICALLY
-
-/* sys/aio.h unconditionally defined these */
-
-union sigval {
- int sival_int; /* Integer signal value */
- void *sival_ptr; /* Pointer signal value */
-};
-
-typedef struct siginfo {
- int si_signo; /* Signal number */
- int si_code; /* Cause of the signal */
- union sigval si_value; /* Signal value */
-} siginfo_t;
+#if !defined(_ANSI_SOURCE) && defined(_P1003_1B_VISIBLE_HISTORICALLY)
struct sigevent {
int sigev_notify; /* Notification type */
@@ -228,7 +270,7 @@ struct sigevent {
#define SIGEV_NONE 0 /* No async notification */
#define SIGEV_SIGNAL 1 /* Generate a queued signal */
-#endif
+#endif /* ! _ANSI_SOURCE && _P1003_1B_VISIBLE_HISTORICALLY */
/*
* For historical reasons; programs expect signal's return value to be
OpenPOWER on IntegriCloud