svn commit: branches/uClibc-nptl/libc: inet signal sysdeps/linux/common/bits

carmelo at uclibc.org carmelo at uclibc.org
Thu Dec 11 13:43:08 UTC 2008


Author: carmelo
Date: 2008-12-11 05:43:07 -0800 (Thu, 11 Dec 2008)
New Revision: 24377

Log:
Synch with trunk @ 24261
Step 19: merge change in rev 24250
- Use runtime pagesize (Jeremy Kerr)
Some powerpc machines can support 64k pages, enabled by the
CONFIG_64K_PAGES option in linux.


Modified:
   branches/uClibc-nptl/libc/inet/getaddrinfo.c
   branches/uClibc-nptl/libc/signal/sigaction.c
   branches/uClibc-nptl/libc/signal/sigempty.c
   branches/uClibc-nptl/libc/signal/sigfillset.c
   branches/uClibc-nptl/libc/signal/sigset-cvt-mask.h
   branches/uClibc-nptl/libc/sysdeps/linux/common/bits/sigset.h


Changeset:
Modified: branches/uClibc-nptl/libc/inet/getaddrinfo.c
===================================================================
--- branches/uClibc-nptl/libc/inet/getaddrinfo.c	2008-12-11 10:32:43 UTC (rev 24376)
+++ branches/uClibc-nptl/libc/inet/getaddrinfo.c	2008-12-11 13:43:07 UTC (rev 24377)
@@ -56,7 +56,6 @@
 #include <assert.h>
 #include <errno.h>
 #include <netdb.h>
-#include <resolv.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

Modified: branches/uClibc-nptl/libc/signal/sigaction.c
===================================================================
--- branches/uClibc-nptl/libc/signal/sigaction.c	2008-12-11 10:32:43 UTC (rev 24376)
+++ branches/uClibc-nptl/libc/signal/sigaction.c	2008-12-11 13:43:07 UTC (rev 24377)
@@ -43,32 +43,25 @@
 {
 	int result;
 	struct kernel_sigaction kact, koact;
-	enum {
-		/* We try hard to actually have them equal,
-		 * but just for paranoid reasons, be safe */
-		SIGSET_MIN_SIZE = sizeof(kact.sa_mask) < sizeof(act->sa_mask)
-				? sizeof(kact.sa_mask) : sizeof(act->sa_mask)
-	};
 
 	if (act) {
 		kact.k_sa_handler = act->sa_handler;
-		memcpy (&kact.sa_mask, &act->sa_mask, SIGSET_MIN_SIZE);
+		memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
 		kact.sa_flags = act->sa_flags;
 # ifdef HAVE_SA_RESTORER
 		kact.sa_restorer = act->sa_restorer;
 # endif
 	}
 
-	/* NB: kernel (as of 2.6.25) will return EINVAL
-	 * if sizeof(kact.sa_mask) does not match kernel's sizeof(sigset_t) */
+	/* XXX The size argument hopefully will have to be changed to the
+	   real size of the user-level sigset_t.  */
 	result = __syscall_rt_sigaction(sig,
-			act ? __ptrvalue (&kact) : NULL,
-			oact ? __ptrvalue (&koact) : NULL,
-			sizeof(kact.sa_mask));
+			       act ? __ptrvalue (&kact) : NULL,
+			       oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
 
 	if (oact && result >= 0) {
 		oact->sa_handler = koact.k_sa_handler;
-		memcpy (&oact->sa_mask, &koact.sa_mask, SIGSET_MIN_SIZE);
+		memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
 		oact->sa_flags = koact.sa_flags;
 # ifdef HAVE_SA_RESTORER
 		oact->sa_restorer = koact.sa_restorer;
@@ -116,7 +109,7 @@
 #endif
 
 #ifndef LIBC_SIGACTION
-/* libc_hidden_proto(sigaction) */
+libc_hidden_proto(sigaction)
 weak_alias(__libc_sigaction,sigaction)
 libc_hidden_weak(sigaction)
 #endif

Modified: branches/uClibc-nptl/libc/signal/sigempty.c
===================================================================
--- branches/uClibc-nptl/libc/signal/sigempty.c	2008-12-11 10:32:43 UTC (rev 24376)
+++ branches/uClibc-nptl/libc/signal/sigempty.c	2008-12-11 13:43:07 UTC (rev 24377)
@@ -23,18 +23,16 @@
 /* Experimentally off - libc_hidden_proto(memset) */
 
 /* Clear all signals from SET.  */
-/* libc_hidden_proto(sigemptyset) */
+libc_hidden_proto(sigemptyset)
 int sigemptyset (sigset_t *set)
 {
-#if 0 /* is it really required by standards?! */
   if (set == NULL)
     {
       __set_errno (EINVAL);
       return -1;
     }
-#endif
 
-  __sigemptyset (set);
+  memset (set, 0, sizeof (sigset_t));
 
   return 0;
 }

Modified: branches/uClibc-nptl/libc/signal/sigfillset.c
===================================================================
--- branches/uClibc-nptl/libc/signal/sigfillset.c	2008-12-11 10:32:43 UTC (rev 24376)
+++ branches/uClibc-nptl/libc/signal/sigfillset.c	2008-12-11 13:43:07 UTC (rev 24377)
@@ -23,19 +23,17 @@
 /* Experimentally off - libc_hidden_proto(memset) */
 
 /* Set all signals in SET.  */
-/* libc_hidden_proto(sigfillset) */
+libc_hidden_proto(sigfillset)
 int
 sigfillset (sigset_t *set)
 {
-#if 0 /* is it really required by standards?! */
   if (set == NULL)
     {
       __set_errno (EINVAL);
       return -1;
     }
-#endif
 
-  __sigfillset (set);
+  memset (set, 0xff, sizeof (sigset_t));
 
   /* If the implementation uses a cancellation signal don't set the bit.  */
 #ifdef SIGCANCEL

Modified: branches/uClibc-nptl/libc/signal/sigset-cvt-mask.h
===================================================================
--- branches/uClibc-nptl/libc/signal/sigset-cvt-mask.h	2008-12-11 10:32:43 UTC (rev 24376)
+++ branches/uClibc-nptl/libc/signal/sigset-cvt-mask.h	2008-12-11 13:43:07 UTC (rev 24377)
@@ -19,14 +19,22 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-static __inline__ void __attribute__ ((unused))
+static __inline__ int __attribute__ ((unused))
 sigset_set_old_mask (sigset_t *set, int mask)
 {
-  if (_SIGSET_NWORDS == 2) /* typical */
-    set->__val[1] = 0;
-  if (_SIGSET_NWORDS > 2)
-    memset(set, 0, sizeof(*set));
-  set->__val[0] = (unsigned int) mask;
+  unsigned long int *ptr;
+  int cnt;
+
+  ptr = &set->__val[0];
+
+  *ptr++ = (unsigned int) mask;
+
+  cnt = _SIGSET_NWORDS - 2;
+  do
+    *ptr++ = 0ul;
+  while (--cnt >= 0);
+
+  return 0;
 }
 
 static __inline__ int __attribute__ ((unused))

Modified: branches/uClibc-nptl/libc/sysdeps/linux/common/bits/sigset.h
===================================================================
--- branches/uClibc-nptl/libc/sysdeps/linux/common/bits/sigset.h	2008-12-11 10:32:43 UTC (rev 24376)
+++ branches/uClibc-nptl/libc/sysdeps/linux/common/bits/sigset.h	2008-12-11 13:43:07 UTC (rev 24377)
@@ -22,27 +22,14 @@
 
 typedef int __sig_atomic_t;
 
-/* A 'sigset_t' has a bit for each signal.
- * glibc has space for 1024 signals (!), but most arches supported
- * by Linux have 64 signals, and only MIPS has 128.
- * There seems to be some historical baggage in sparc[64]
- * where they might have (or had in the past) 32 signals only,
- * I hope it's irrelevant now.
- * Signal 0 does not exist, so we have signals 1..64, not 0..63.
- * Note that struct sigaction has embedded sigset_t,
- * and this necessitates translation in sigaction()
- * to convert it to struct kernel_sigaction.
- * See libc/.../sigaction.c, libc/.../kernel_sigaction.h
- */
-#if defined(__mips__)
-# define _SIGSET_NWORDS	(128 / (8 * sizeof (unsigned long)))
-#else
-# define _SIGSET_NWORDS	(64 / (8 * sizeof (unsigned long)))
-#endif
-typedef struct {
-	unsigned long __val[_SIGSET_NWORDS];
-} __sigset_t;
+/* A `sigset_t' has a bit for each signal.  */
 
+# define _SIGSET_NWORDS	(1024 / (8 * sizeof (unsigned long int)))
+typedef struct
+  {
+    unsigned long int __val[_SIGSET_NWORDS];
+  } __sigset_t;
+
 #endif
 
 
@@ -62,96 +49,52 @@
 /* Return a mask that includes the bit for SIG only.  */
 /* Unsigned cast ensures shift/mask insns are used.  */
 # define __sigmask(sig) \
-  (((unsigned long) 1) << ((unsigned)((sig) - 1) % (8 * sizeof (unsigned long))))
+  (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int))))
 
 /* Return the word index for SIG.  */
-# define __sigword(sig)	((unsigned)((sig) - 1) / (8 * sizeof (unsigned long)))
+# define __sigword(sig)	(((sig) - 1) / (8 * sizeof (unsigned long int)))
 
-/* gcc 4.3.1 is not clever enough to optimize for _SIGSET_NWORDS == 1 and 2,
- * which are about the only values which can be there */
-
 # if defined __GNUC__ && __GNUC__ >= 2
 #  define __sigemptyset(set) \
-(__extension__ ({ \
-	sigset_t *__set = (set);					\
-	if (_SIGSET_NWORDS <= 2) {					\
-		__set->__val[0] = 0;					\
-		if (_SIGSET_NWORDS == 2)				\
-			__set->__val[1] = 0;				\
-	} else {							\
-		int __cnt = _SIGSET_NWORDS;				\
-		while (--__cnt >= 0) __set->__val[__cnt] = 0;		\
-	}								\
-	0;								\
-}))
+  (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
+		    sigset_t *__set = (set);				      \
+		    while (--__cnt >= 0) __set->__val[__cnt] = 0;	      \
+		    0; }))
 #  define __sigfillset(set) \
-(__extension__ ({ \
-	sigset_t *__set = (set);					\
-	if (_SIGSET_NWORDS <= 2) {					\
-		__set->__val[0] = ~0UL;					\
-		if (_SIGSET_NWORDS == 2)				\
-			__set->__val[1] = ~0UL;				\
-	} else {							\
-		int __cnt = _SIGSET_NWORDS;				\
-		while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;	\
-	}								\
-	0;								\
-}))
+  (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
+		    sigset_t *__set = (set);				      \
+		    while (--__cnt >= 0) __set->__val[__cnt] = ~0UL;	      \
+		    0; }))
 
 #  ifdef __USE_GNU
 /* The POSIX does not specify for handling the whole signal set in one
    command.  This is often wanted and so we define three more functions
    here.  */
 #   define __sigisemptyset(set) \
-(__extension__ ({ \
-	long __ret;							\
-	const sigset_t *__set = (set);					\
-	if (_SIGSET_NWORDS == 1) {					\
-		__ret = __set->__val[0];				\
-	} else if (_SIGSET_NWORDS == 2) {				\
-		__ret = __set->__val[0] | __set->__val[1];		\
-	} else {							\
-		int __cnt = _SIGSET_NWORDS;				\
-		__ret = __set->__val[--__cnt];				\
-		while (!__ret && --__cnt >= 0)				\
-			__ret = __set->__val[__cnt];			\
-	}								\
-	__ret == 0;							\
-}))
+  (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
+		    const sigset_t *__set = (set);			      \
+		    int __ret = __set->__val[--__cnt];			      \
+		    while (!__ret && --__cnt >= 0)			      \
+			__ret = __set->__val[__cnt];			      \
+		    __ret == 0; }))
 #   define __sigandset(dest, left, right) \
-(__extension__ ({ \
-	sigset_t *__dest = (dest);					\
-	const sigset_t *__left = (left);				\
-	const sigset_t *__right = (right);				\
-	if (_SIGSET_NWORDS <= 2) {					\
-		__dest->__val[0] = __left->__val[0] & __right->__val[0];\
-		if (_SIGSET_NWORDS == 2)				\
-			__dest->__val[1] = __left->__val[1] & __right->__val[1];\
-	} else {							\
-		int __cnt = _SIGSET_NWORDS;				\
-		while (--__cnt >= 0)					\
-			__dest->__val[__cnt] = (__left->__val[__cnt]	\
-					& __right->__val[__cnt]);	\
-	}								\
-	0;								\
-}))
+  (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
+		    sigset_t *__dest = (dest);				      \
+		    const sigset_t *__left = (left);			      \
+		    const sigset_t *__right = (right);			      \
+		    while (--__cnt >= 0)				      \
+		      __dest->__val[__cnt] = (__left->__val[__cnt]	      \
+					      & __right->__val[__cnt]);	      \
+		    0; }))
 #   define __sigorset(dest, left, right) \
-(__extension__ ({ \
-	sigset_t *__dest = (dest);					\
-	const sigset_t *__left = (left);				\
-	const sigset_t *__right = (right);				\
-	if (_SIGSET_NWORDS <= 2) {					\
-		__dest->__val[0] = __left->__val[0] | __right->__val[0];\
-		if (_SIGSET_NWORDS == 2)				\
-			__dest->__val[1] = __left->__val[1] | __right->__val[1];\
-	} else {							\
-		int __cnt = _SIGSET_NWORDS;				\
-		while (--__cnt >= 0)					\
-			__dest->__val[__cnt] = (__left->__val[__cnt]	\
-					| __right->__val[__cnt]);	\
-	}								\
-	0;								\
-}))
+  (__extension__ ({ int __cnt = _SIGSET_NWORDS;				      \
+		    sigset_t *__dest = (dest);				      \
+		    const sigset_t *__left = (left);			      \
+		    const sigset_t *__right = (right);			      \
+		    while (--__cnt >= 0)				      \
+		      __dest->__val[__cnt] = (__left->__val[__cnt]	      \
+					      | __right->__val[__cnt]);	      \
+		    0; }))
 #  endif
 # endif
 
@@ -166,14 +109,14 @@
 libc_hidden_proto(__sigdelset)
 
 # ifdef __USE_EXTERN_INLINES
-#  define __SIGSETFN(NAME, BODY, CONST)					\
-_EXTERN_INLINE int							\
-NAME (CONST __sigset_t *__set, int __sig)				\
-{									\
-	unsigned long __mask = __sigmask (__sig);			\
-	unsigned long __word = __sigword (__sig);			\
-	return BODY;							\
-}
+#  define __SIGSETFN(NAME, BODY, CONST)					      \
+  _EXTERN_INLINE int							      \
+  NAME (CONST __sigset_t *__set, int __sig)				      \
+  {									      \
+    unsigned long int __mask = __sigmask (__sig);			      \
+    unsigned long int __word = __sigword (__sig);			      \
+    return BODY;							      \
+  }
 
 __SIGSETFN (__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, __const)
 __SIGSETFN (__sigaddset, ((__set->__val[__word] |= __mask), 0), )




More information about the uClibc-cvs mailing list