svn commit: branches/uClibc-nptl: libc/signal libc/sysdeps/linux/common li etc...

sjhill at uclibc.org sjhill at uclibc.org
Sun Feb 5 05:46:09 UTC 2006


Author: sjhill
Date: 2006-02-04 21:46:07 -0800 (Sat, 04 Feb 2006)
New Revision: 13850

Log:
Finish implementation of new signals for NPTL which are SIGCANCEL, SIGTIMER and SIGSETXID.


Added:
   branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigwaitinfo.c

Modified:
   branches/uClibc-nptl/libc/signal/Makefile.in
   branches/uClibc-nptl/libc/signal/sigwait.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigtimedwait.c
   branches/uClibc-nptl/libc/sysdeps/linux/common/sigprocmask.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigaction.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigfillset.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigprocmask.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c
   branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c


Changeset:
Modified: branches/uClibc-nptl/libc/signal/Makefile.in
===================================================================
--- branches/uClibc-nptl/libc/signal/Makefile.in	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libc/signal/Makefile.in	2006-02-05 05:46:07 UTC (rev 13850)
@@ -11,6 +11,10 @@
 	sigorset.c sigpause.c sigrelse.c sigset.c sigsetmask.c sigsetops.c \
 	sysv_signal.c sigwait.c
 
+ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
+CSRC:=$(filter-out raise.c,$(CSRC))
+endif
+
 ifneq ($(strip $(ARCH_OBJS)),)
 CSRC:=$(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC))
 endif

Modified: branches/uClibc-nptl/libc/signal/sigwait.c
===================================================================
--- branches/uClibc-nptl/libc/signal/sigwait.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libc/signal/sigwait.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -1,7 +1,8 @@
 /* vi: set sw=4 ts=4: */
 /* sigwait
  *
- * Copyright (C) 2003 by Erik Andersen <andersen at uclibc.org>
+ * Copyright (C) 2006 by Steven J. Hill <sjhill at realitydiluted.com>
+ * Copyright (C) 2003-2005 by Erik Andersen <andersen at uclibc.org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +25,81 @@
 #include <signal.h>
 #include <string.h>
 
-#undef sigwait
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# include <sysdep-cancel.h>
+
+# ifdef __NR_rt_sigtimedwait
+
+/* Return any pending signal or wait for one for the given time.  */
+static int do_sigwait(const sigset_t *set, int *sig)
+{
+	int ret;
+
+#  ifdef SIGCANCEL
+	sigset_t tmpset;
+	if (set != NULL
+		&& (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+#   ifdef SIGSETXID
+		|| __builtin_expect (__sigismember (set, SIGSETXID), 0)
+#   endif
+		))
+	{
+		/* Create a temporary mask without the bit for SIGCANCEL set.  */
+		// We are not copying more than we have to.
+#   ifdef IS_IN_libc
+		__memcpy(&tmpset, set, _NSIG / 8);
+#   else
+		memcpy(&tmpset, set, _NSIG / 8);
+#   endif
+		__sigdelset(&tmpset, SIGCANCEL);
+#   ifdef SIGSETXID
+		__sigdelset(&tmpset, SIGSETXID);
+#   endif
+		set = &tmpset;
+	}
+#  endif
+
+	/* XXX The size argument hopefully will have to be changed to the
+	   real size of the user-level sigset_t.  */
+#  ifdef INTERNAL_SYSCALL
+	INTERNAL_SYSCALL_DECL(err);
+	do
+		ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set, NULL,
+			NULL, _NSIG / 8);
+	while (INTERNAL_SYSCALL_ERROR_P (ret, err)
+		&& INTERNAL_SYSCALL_ERRNO (ret, err) == EINTR);
+	if (! INTERNAL_SYSCALL_ERROR_P (ret, err))
+	{
+		*sig = ret;
+		ret = 0;
+	}
+else
+	ret = INTERNAL_SYSCALL_ERRNO (ret, err);
+#  else
+#   error INTERNAL_SYSCALL must be defined!!!
+#  endif
+
+	return ret;
+}
+
+int __sigwait (const sigset_t *set, int *sig)
+{
+	if(SINGLE_THREAD_P)
+		return do_sigwait(set, sig);
+
+	int oldtype = LIBC_CANCEL_ASYNC();
+
+	int result = do_sigwait(set, sig);
+
+	LIBC_CANCEL_RESET(oldtype);
+
+	return result;
+}
+# else
+#  error We must have rt_sigtimedwait defined!!!
+# endif
+#else
+# undef sigwait
 int attribute_hidden __sigwait (const sigset_t *set, int *sig)
 {
 	int ret = 1;
@@ -34,6 +109,5 @@
 	}
 	return 1;
 }
-
-/* psm: keep this weak, because the one in libpthread.so could overwrite it */
+#endif
 weak_alias(__sigwait, sigwait)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigtimedwait.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigtimedwait.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigtimedwait.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -2,6 +2,7 @@
 /*
  * __rt_sigtimedwait() for uClibc
  *
+ * Copyright (C) 2006 by Steven Hill <sjhill at realitydiluted.com>
  * Copyright (C) 2000-2004 by Erik Andersen <andersen at codepoet.org>
  *
  * GNU Library General Public License (LGPL) version 2 or later.
@@ -9,35 +10,84 @@
 
 #include "syscalls.h"
 #include <signal.h>
-#define __need_NULL
-#include <stddef.h>
+
 #ifdef __NR_rt_sigtimedwait
-#define __NR___rt_sigtimedwait __NR_rt_sigtimedwait
-static _syscall4(int, __rt_sigtimedwait, const sigset_t *, set, siginfo_t *, info,
-		  const struct timespec *, timeout, size_t, setsize);
 
-int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info)
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#  include <sysdep-cancel.h>
+
+static int do_sigtimedwait(const sigset_t *set, siginfo_t *info,
+						   const struct timespec *timeout)
 {
-	return __rt_sigtimedwait(set, info, NULL, _NSIG / 8);
+#  ifdef SIGCANCEL
+	sigset_t tmpset;
+
+	if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+#   ifdef SIGSETXID
+		|| __builtin_expect (__sigismember (set, SIGSETXID), 0)
+#   endif
+		))
+	{
+		/* Create a temporary mask without the bit for SIGCANCEL set.  */
+		// We are not copying more than we have to.
+		__memcpy (&tmpset, set, _NSIG / 8);
+		__sigdelset (&tmpset, SIGCANCEL);
+#   ifdef SIGSETXID
+		__sigdelset (&tmpset, SIGSETXID);
+#   endif
+		set = &tmpset;
+	}
+#  endif
+
+	/* XXX The size argument hopefully will have to be changed to the
+	   real size of the user-level sigset_t.  */
+	int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info,
+								 timeout, _NSIG / 8);
+
+	/* The kernel generates a SI_TKILL code in si_code in case tkill is
+	   used.  tkill is transparently used in raise().  Since having
+	   SI_TKILL as a code is useful in general we fold the results
+	   here.  */
+	if (result != -1 && info != NULL && info->si_code == SI_TKILL)
+		info->si_code = SI_USER;
+
+	return result;
 }
 
+/* Return any pending signal or wait for one for the given time.  */
+int __sigtimedwait(const sigset_t *set, siginfo_t *info,
+				   const struct timespec *timeout)
+{
+	if(SINGLE_THREAD_P)
+		return do_sigtimedwait(set, info, timeout);
+
+	int oldtype = LIBC_CANCEL_ASYNC();
+
+	/* XXX The size argument hopefully will have to be changed to the
+	   real size of the user-level sigset_t.  */
+	int result = do_sigtimedwait(set, info, timeout);
+
+	LIBC_CANCEL_RESET(oldtype);
+
+	return result;
+}
+# else
+#  define __need_NULL
+#  include <stddef.h>
+#  define __NR___rt_sigtimedwait __NR_rt_sigtimedwait
+static _syscall4(int, __rt_sigtimedwait, const sigset_t *, set,
+				 siginfo_t *, info, const struct timespec *, timeout,
+				 size_t, setsize);
+
 int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info,
-				 const struct timespec *timeout)
+									const struct timespec *timeout)
 {
 	return __rt_sigtimedwait(set, info, timeout, _NSIG / 8);
 }
+# endif
 #else
-int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info)
-{
-	if (set == NULL)
-		__set_errno(EINVAL);
-	else
-		__set_errno(ENOSYS);
-	return -1;
-}
-
 int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info,
-				 const struct timespec *timeout)
+									const struct timespec *timeout)
 {
 	if (set == NULL)
 		__set_errno(EINVAL);
@@ -46,6 +96,4 @@
 	return -1;
 }
 #endif
-/* keep these weak so that libpthread can overwrite them */
 weak_alias(__sigtimedwait,sigtimedwait)
-weak_alias(__sigwaitinfo,sigwaitinfo)

Added: branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigwaitinfo.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/__rt_sigwaitinfo.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -0,0 +1,95 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * __rt_sigwaitinfo() for uClibc
+ *
+ * Copyright (C) 2006 by Steven Hill <sjhill at realitydiluted.com>
+ * Copyright (C) 2000-2004 by Erik Andersen <andersen at codepoet.org>
+ *
+ * GNU Library General Public License (LGPL) version 2 or later.
+ */
+
+#include "syscalls.h"
+#include <signal.h>
+
+#ifdef __NR_rt_sigtimedwait
+
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#  include <sysdep-cancel.h>
+
+static int do_sigwaitinfo(const sigset_t *set, siginfo_t *info)
+{
+#  ifdef SIGCANCEL
+	sigset_t tmpset;
+
+	if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+#   ifdef SIGSETXID
+		|| __builtin_expect (__sigismember (set, SIGSETXID), 0)
+#   endif
+		))
+	{
+		/* Create a temporary mask without the bit for SIGCANCEL set.  */
+		// We are not copying more than we have to.
+		__memcpy (&tmpset, set, _NSIG / 8);
+		__sigdelset (&tmpset, SIGCANCEL);
+#   ifdef SIGSETXID
+		__sigdelset (&tmpset, SIGSETXID);
+#   endif
+		set = &tmpset;
+	}
+#  endif
+
+	/* XXX The size argument hopefully will have to be changed to the
+	   real size of the user-level sigset_t.  */
+	int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info,
+								 NULL, _NSIG / 8);
+
+	/* The kernel generates a SI_TKILL code in si_code in case tkill is
+	   used.  tkill is transparently used in raise().  Since having
+	   SI_TKILL as a code is useful in general we fold the results
+	   here.  */
+	if (result != -1 && info != NULL && info->si_code == SI_TKILL)
+		info->si_code = SI_USER;
+
+	return result;
+}
+
+/* Return any pending signal or wait for one for the given time.  */
+int __sigwaitinfo(const sigset_t *set, siginfo_t *info)
+{
+	if(SINGLE_THREAD_P)
+		return do_sigwaitinfo(set, info);
+
+	int oldtype = LIBC_CANCEL_ASYNC();
+
+	/* XXX The size argument hopefully will have to be changed to the
+	   real size of the user-level sigset_t.  */
+	int result = do_sigwaitinfo(set, info);
+
+	LIBC_CANCEL_RESET(oldtype);
+
+	return result;
+}
+# else
+#  define __need_NULL
+#  include <stddef.h>
+#  define __NR___rt_sigwaitinfo __NR_rt_sigwaitinfo
+static _syscall4(int, __rt_sigwaitinfo, const sigset_t *, set,
+				 siginfo_t *, info, const struct timespec *, timeout,
+				 size_t, setsize);
+
+int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info)
+{
+	return __rt_sigwaitinfo(set, info, NULL, _NSIG / 8);
+}
+# endif
+#else
+int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info)
+{
+	if (set == NULL)
+		__set_errno(EINVAL);
+	else
+		__set_errno(ENOSYS);
+	return -1;
+}
+#endif
+weak_alias(__sigwaitinfo,sigwaitinfo)

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/sigprocmask.c
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/sigprocmask.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/sigprocmask.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -2,6 +2,7 @@
 /*
  * sigprocmask() for uClibc
  *
+ * Copyright (C) 2006 by Steven J. Hill <sjhill at uclibc.org>
  * Copyright (C) 2000-2004 by Erik Andersen <andersen at codepoet.org>
  *
  * GNU Library General Public License (LGPL) version 2 or later.

Modified: branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigaction.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigaction.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigaction.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -28,7 +28,7 @@
    SIGCANCEL or SIGTIMER to be handled.  */
 # define LIBC_SIGACTION	1
 
-# include_next <sigaction.c>
+# include <sigaction.c>
 
 int
 __sigaction (sig, act, oact)
@@ -44,7 +44,7 @@
 
   return __libc_sigaction (sig, act, oact);
 }
-weak_alias(__sigaction, sigaction)
+hidden_weak_alias(__sigaction, sigaction)
 
 #else
 

Modified: branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigfillset.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigfillset.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigfillset.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -18,4 +18,4 @@
 
 #include <pthreadP.h>
 
-#include_next <sigfillset.c>
+#include <../../../../libc/signal/sigfillset.c>

Modified: branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigprocmask.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigprocmask.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/pthread/sigprocmask.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -18,4 +18,4 @@
 
 #include <pthreadP.h>
 
-#include_next <sigprocmask.c>
+#include <../../../../libc/sysdeps/linux/common/sigprocmask.c>

Modified: branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -25,8 +25,8 @@
 #include <kernel-features.h>
 
 
-int
-raise (sig)
+int attribute_hidden
+__raise (sig)
      int sig;
 {
   struct pthread *pd = THREAD_SELF;
@@ -71,5 +71,4 @@
   return INLINE_SYSCALL (tkill, 2, selftid, sig);
 #endif
 }
-hidden_def (raise)
-weak_alias (raise, gsignal)
+weak_alias(__raise, raise)

Modified: branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c
===================================================================
--- branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c	2006-02-05 05:37:43 UTC (rev 13849)
+++ branches/uClibc-nptl/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c	2006-02-05 05:46:07 UTC (rev 13850)
@@ -1,105 +1,2 @@
-/* Copyright (C) 1997,1998,2000,2002-2004,2005 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
 #include <pthreadP.h>
-#include <errno.h>
-#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
-#include <string.h>
-
-#include <sysdep-cancel.h>
-#include <sys/syscall.h>
-
-#ifdef __NR_rt_sigtimedwait
-
-/* Return any pending signal or wait for one for the given time.  */
-static int
-do_sigwait (const sigset_t *set, int *sig)
-{
-  int ret;
-
-#ifdef SIGCANCEL
-  sigset_t tmpset;
-  if (set != NULL
-      && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
-# ifdef SIGSETXID
-	  || __builtin_expect (__sigismember (set, SIGSETXID), 0)
-# endif
-	  ))
-    {
-      /* Create a temporary mask without the bit for SIGCANCEL set.  */
-      // We are not copying more than we have to.
-      memcpy (&tmpset, set, _NSIG / 8);
-      __sigdelset (&tmpset, SIGCANCEL);
-# ifdef SIGSETXID
-      __sigdelset (&tmpset, SIGSETXID);
-# endif
-      set = &tmpset;
-    }
-#endif
-
-  /* XXX The size argument hopefully will have to be changed to the
-     real size of the user-level sigset_t.  */
-#ifdef INTERNAL_SYSCALL
-  INTERNAL_SYSCALL_DECL (err);
-  do
-    ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set,
-			    NULL, NULL, _NSIG / 8);
-  while (INTERNAL_SYSCALL_ERROR_P (ret, err)
-	 && INTERNAL_SYSCALL_ERRNO (ret, err) == EINTR);
-  if (! INTERNAL_SYSCALL_ERROR_P (ret, err))
-    {
-      *sig = ret;
-      ret = 0;
-    }
-  else
-    ret = INTERNAL_SYSCALL_ERRNO (ret, err);
-#else
-  do
-    ret = INLINE_SYSCALL (rt_sigtimedwait, 4, set,
-			  NULL, NULL, _NSIG / 8);
-  while (ret == -1 && errno == EINTR);
-  if (ret != -1)
-    {
-      *sig = ret;
-      ret = 0;
-    }
-  else
-    ret = errno;
-#endif
-
-  return ret;
-}
-
-int attribute_hidden
-__sigwait (const sigset_t *set, int *sig)
-{
-  if (SINGLE_THREAD_P)
-    return do_sigwait (set, sig);
-
-  int oldtype = LIBC_CANCEL_ASYNC ();
-
-  int result = do_sigwait (set, sig);
-
-  LIBC_CANCEL_RESET (oldtype);
-
-  return result;
-}
-weak_alias (__sigwait, sigwait)
-#endif
+#include "../../../../../../libc/signal/sigwait.c"




More information about the uClibc-cvs mailing list