This is the mail archive of the libc-hacker@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RT signals for linuxthreads


Hi,

This is the patch for glibc which moves __pthread_sig_restart,
__pthread_sig_cancel and __pthread_sig_debug to glibc. My next
gdb 4.17.0.11 will only work with glibc 2.1 plus my patches for
linuxthreads and glibc. glibc 2.0 is ok.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
Sun Feb  7 19:31:06 1999  H.J. Lu  <hjl@gnu.org>

	* signal/allocrtsig.c: Moved to ....
	sysdeps/unix/allocrtsig.c.

	* sysdeps/unix/allocrtsig.c (__libc_init_rtsigs): Renamed from
	init.

	* sysdeps/unix/sysv/linux/allocrtsig.c: New.

	* signal/Versions (__libc_init_rtsigs): Added to GLIBC_2.1.
	* sysdeps/unix/sysv/linux/Versions (__pthread_sig_restart,
	__pthread_sig_cancel, __pthread_sig_debug): Likewise.

	* sysdeps/unix/sysv/linux/testrtsig.h (kernel_has_rtsig): Add
	__inline.

	* signal/signal.h (__libc_init_rtsigs): New prototype.

Index: signal/Versions
===================================================================
RCS file: /home/work/cvs/gnu/glibc/signal/Versions,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 Versions
--- signal/Versions	1998/07/15 00:20:13	1.1.1.1
+++ signal/Versions	1999/02/08 01:36:01
@@ -33,7 +33,8 @@ libc {
   }
   GLIBC_2.1 {
     # helper functions
-    __libc_current_sigrtmin; __libc_current_sigrtmax; __libc_allocate_rtsig;
+    __libc_current_sigrtmin; __libc_current_sigrtmax;
+    __libc_allocate_rtsig; __libc_init_rtsigs;
 
     # s*
     sighold; sigrelse; sigignore; sigset; sysv_signal;
Index: signal/signal.h
===================================================================
RCS file: /home/work/cvs/gnu/glibc/signal/signal.h,v
retrieving revision 1.1.1.24
diff -u -p -r1.1.1.24 signal.h
--- signal/signal.h	1998/11/13 01:27:12	1.1.1.24
+++ signal/signal.h	1999/02/08 01:35:27
@@ -352,6 +352,9 @@ extern int __libc_current_sigrtmax __P (
 /* Allocate real-time signal with highest/lowest available priority.  */
 extern int __libc_allocate_rtsig __P ((int __high));
 
+/* Initialize real-time signals. */
+extern void __libc_init_rtsigs __P ((void));
+
 #endif /* signal.h  */
 
 __END_DECLS
Index: sysdeps/unix/sysv/linux/Versions
===================================================================
RCS file: /home/work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/Versions,v
retrieving revision 1.1.1.5
diff -u -p -r1.1.1.5 Versions
--- sysdeps/unix/sysv/linux/Versions	1999/01/09 18:16:13	1.1.1.5
+++ sysdeps/unix/sysv/linux/Versions	1999/02/08 01:36:17
@@ -55,8 +55,9 @@ libc {
     # functions used in inline functions or macros
     __libc_sa_len;
 
-    # functions used in other libraries
-    __syscall_rt_sigqueueinfo;
+    # functions and data symbols used in other libraries
+    __syscall_rt_sigqueueinfo; __pthread_sig_restart;
+    __pthread_sig_cancel; __pthread_sig_debug;
 
     # Since we have new signals this structure changed.
     _sys_siglist; sys_siglist; sys_sigabbrev;
Index: sysdeps/unix/sysv/linux/testrtsig.h
===================================================================
RCS file: /home/work/cvs/gnu/glibc/sysdeps/unix/sysv/linux/testrtsig.h,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 testrtsig.h
--- sysdeps/unix/sysv/linux/testrtsig.h	1998/01/09 16:42:25	1.1.1.2
+++ sysdeps/unix/sysv/linux/testrtsig.h	1999/02/07 19:24:10
@@ -21,7 +21,7 @@
 #include <string.h>
 #include <sys/utsname.h>
 
-static int
+static __inline int
 kernel_has_rtsig (void)
 {
   struct utsname name;
--- /dev/null	Tue May  5 13:32:27 1998
+++ sysdeps/unix/allocrtsig.c	Sun Feb  7 17:36:53 1999
@@ -0,0 +1,89 @@
+/* Handle real-time signal allocation.
+   Copyright (C) 1997, 1998 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"
+
+void
+__libc_init_rtsigs (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)
+    __libc_init_rtsigs ();
+#endif
+  return current_rtmin;
+}
+
+/* Return number of available real-time signal with lowest priority.  */
+int
+__libc_current_sigrtmax (void)
+{
+#ifdef __SIGRTMIN
+  if (!initialized)
+    __libc_init_rtsigs ();
+#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)
+    __libc_init_rtsigs ();
+  if (current_rtmin == -1 || current_rtmin > current_rtmax)
+    /* We don't have anymore signal available.  */
+    return -1;
+
+  return high ? current_rtmin++ : current_rtmax--;
+#endif
+}
--- /dev/null	Tue May  5 13:32:27 1998
+++ sysdeps/unix/sysv/linux/allocrtsig.c	Sun Feb  7 21:04:13 1999
@@ -0,0 +1,122 @@
+/* Handle real-time signal allocation.
+   Copyright (C) 1997, 1998, 1999 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;
+static int current_rtmax;
+
+extern int __pthread_threads_debug;
+weak_extern (__pthread_threads_debug);
+
+#if __SIGRTMAX - __SIGRTMIN >= 3
+int __pthread_sig_restart = __SIGRTMIN;
+int __pthread_sig_cancel = __SIGRTMIN + 1;
+int __pthread_sig_debug = __SIGRTMIN + 2;
+#else
+int __pthread_sig_restart = SIGUSR1;
+int __pthread_sig_cancel = SIGUSR2;
+int __pthread_sig_debug = 0;
+#endif
+
+static int initialized;
+
+#include "testrtsig.h"
+
+void
+__libc_init_rtsigs (void)
+{
+  if (!kernel_has_rtsig ())
+    {
+      current_rtmin = -1;
+      current_rtmax = -1;
+#if __SIGRTMAX - __SIGRTMIN >= 3
+      __pthread_sig_restart = SIGUSR1;
+      __pthread_sig_cancel = SIGUSR2;
+      __pthread_sig_debug = 0;
+#endif
+    }
+  else
+    {
+      if (&__pthread_threads_debug != NULL)
+        /* libpthread is linked in. */
+#if __SIGRTMAX - __SIGRTMIN >= 3
+	current_rtmin = __SIGRTMIN + 3;
+#else
+	current_rtmin = __SIGRTMIN;
+#endif
+      else
+	current_rtmin = __SIGRTMIN;
+
+      current_rtmax = __SIGRTMAX;
+    }
+
+  initialized = 1;
+}
+#endif
+
+/* Return number of available real-time signal with highest priority.  */
+int
+__libc_current_sigrtmin (void)
+{
+#ifdef __SIGRTMIN
+  if (!initialized)
+    __libc_init_rtsigs ();
+#endif
+  return current_rtmin;
+}
+
+/* Return number of available real-time signal with lowest priority.  */
+int
+__libc_current_sigrtmax (void)
+{
+#ifdef __SIGRTMIN
+  if (!initialized)
+    __libc_init_rtsigs ();
+#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)
+    __libc_init_rtsigs ();
+  if (current_rtmin == -1 || current_rtmin > current_rtmax)
+    /* We don't have anymore signal available.  */
+    return -1;
+
+  return high ? current_rtmin++ : current_rtmax--;
+#endif
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]