about summary refs log tree commit diff
path: root/signal
diff options
context:
space:
mode:
Diffstat (limited to 'signal')
-rw-r--r--signal/Makefile7
-rw-r--r--signal/allocrtsig.c89
-rw-r--r--signal/signal.h44
3 files changed, 137 insertions, 3 deletions
diff --git a/signal/Makefile b/signal/Makefile
index e35fb12345..29aeea5f2b 100644
--- a/signal/Makefile
+++ b/signal/Makefile
@@ -22,7 +22,7 @@
 subdir	:= signal
 
 headers	:= signal.h sys/signal.h bits/signum.h bits/sigcontext.h \
-	   bits/sigaction.h bits/sigset.h
+	   bits/sigaction.h bits/sigset.h bits/siginfo.h
 
 routines	:= signal raise killpg \
 		   sigaction sigprocmask kill \
@@ -32,11 +32,12 @@ routines	:= signal raise killpg \
 		   sigsetops sigempty sigfillset sigaddset sigdelset sigismem \
 		   sigreturn \
 		   siggetmask sysv_signal \
-		   sigisempty sigandset sigorset
+		   sigisempty sigandset sigorset \
+		   allocrtsig sigtimedwait sigwaitinfo sigqueue
 
 tests		:= tst-signal
 
-distribute	:= sigsetops.h
+distribute	:= sigsetops.h testrtsig.h
 
 
 include ../Rules
diff --git a/signal/allocrtsig.c b/signal/allocrtsig.c
new file mode 100644
index 0000000000..678bc8b17b
--- /dev/null
+++ b/signal/allocrtsig.c
@@ -0,0 +1,89 @@
+/* Handle real-time signal allocation.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <signal.h>
+
+/* In these variables we keep track of the used variables.  If the
+   platform does not support any real-time signals we will define the
+   values to some unreasonable value which will signal failing of all
+   the functions below.  */
+#ifndef __SIGRTMIN
+static int current_rtmin = -1;
+static int current_rtmax = -1;
+#else
+static int current_rtmin = __SIGRTMIN;
+static int current_rtmax = __SIGRTMAX;
+
+static int initialized;
+
+#include "testrtsig.h"
+
+static void
+init (void)
+{
+  if (!kernel_has_rtsig ())
+    {
+      current_rtmin = -1;
+      current_rtmax = -1;
+    }
+  initialized = 1;
+}
+#endif
+
+/* Return number of available real-time signal with highest priority.  */
+int
+__libc_current_sigrtmin (void)
+{
+#ifdef __SIGRTMIN
+  if (!initialized)
+    init ();
+#endif
+  return current_rtmin;
+}
+
+/* Return number of available real-time signal with lowest priority.  */
+int
+__libc_current_sigrtmax (void)
+{
+#ifdef __SIGRTMIN
+  if (!initialized)
+    init ();
+#endif
+  return current_rtmax;
+}
+
+/* Allocate real-time signal with highest/lowest available
+   priority.  Please note that we don't use a lock since we assume
+   this function to be called at program start.  */
+int
+__libc_allocate_rtsig (int high)
+{
+#ifndef __SIGRTMIN
+  return -1;
+#else
+  if (!initialized)
+    init ();
+  if (current_rtmin != -1 || current_rtmin > current_rtmax)
+    /* We don't have anymore signal available.  */
+    return -1;
+
+  return high ? current_rtmin++ : current_rtmax--;
+#endif
+}
diff --git a/signal/signal.h b/signal/signal.h
index 5fb4bc2a14..8691b6880e 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -172,6 +172,20 @@ typedef __sigset_t sigset_t;
 
 # ifdef _SIGNAL_H
 
+/* We need `struct timespec' later on.  */
+#  define __need_timespec
+#  include <time.h>
+
+/* Type for data associated with a signal.  */
+typedef union sigval
+  {
+    int sival_int;
+    void *sival_ptr;
+  } sigval_t;
+
+/* Get the `siginfo_t' type plus the needed symbols.  */
+# include <bits/siginfo.h>
+
 /* Clear all signals from SET.  */
 extern int sigemptyset __P ((sigset_t *__set));
 
@@ -229,6 +243,24 @@ extern int sigpending __P ((sigset_t *__set));
 extern int __sigwait __P ((__const sigset_t *__set, int *__sig));
 extern int sigwait __P ((__const sigset_t *__set, int *__sig));
 
+/* Select any of pending signals from SET and place information in INFO.  */
+extern int __sigwaitinfo __P ((__const sigset_t *__set, siginfo_t *__info));
+extern int sigwaitinfo __P ((__const sigset_t *__set, siginfo_t *__info));
+
+/* Select any of pending signals from SET and place information in INFO.
+   Wait the imte specified by TIMEOUT if no signal is pending.  */
+extern int __sigtimedwait __P ((__const sigset_t *__set, siginfo_t *__info,
+				__const struct timespec *__timeout));
+extern int sigtimedwait __P ((__const sigset_t *__set, siginfo_t *__info,
+			      __const struct timespec *__timeout));
+
+/* Send signal SIG to the process PID.  Associate data in VAL with the
+   signal.  */
+extern int __sigqueue __P ((__pid_t __pid, int __sig,
+			    __const union sigval __val));
+extern int sigqueue __P ((__pid_t __pid, int __sig,
+			  __const union sigval __val));
+
 # endif /* <signal.h> included.  */
 
 #endif /* Use POSIX.  */
@@ -313,6 +345,18 @@ extern int sigaltstack __P ((__const struct sigaltstack *__ss,
 
 #endif /* signal.h included and use BSD or X/Open Unix.  */
 
+
+/* The following functions are used internally in the C library and in
+   other code which need deep insights.  */
+
+/* Return number of available real-time signal with highest priority.  */
+extern int __libc_current_sigrtmin __P ((void));
+/* Return number of available real-time signal with lowest priority.  */
+extern int __libc_current_sigrtmax __P ((void));
+
+/* Allocate real-time signal with highest/lowest available priority.  */
+extern int __libc_allocate_rtsig __P ((int __high));
+
 __END_DECLS
 
 #endif /* signal.h  */