[git commit prelink 1/1] *: inline constant __sig{add, del}set and __sigismember

Denys Vlasenko dvlasenk at redhat.com
Sun Nov 28 19:50:38 UTC 2010


commit: http://git.uclibc.org/uClibc/commit/?id=162cfaea20d807f0ae329efe39292a9b22593b41
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/prelink

    text           data     bss     dec     hex filename
-    318              4       0     322     142 libc/pwd_grp/lckpwdf.o
+    312              4       0     316     13c libc/pwd_grp/lckpwdf.o
-    166              0       1     167      a7 libc/stdlib/abort.o
+    157              0       1     158      9e libc/stdlib/abort.o
-     42              0       0      42      2a libc/sysdeps/linux/common/pause.o
+     27              0       0      27      1b libc/sysdeps/linux/common/pause.o

Signed-off-by: Denys Vlasenko <dvlasenk at redhat.com>
---
 libc/signal/sigsetops.c                            |    3 ++
 libc/stdlib/system.c                               |    5 ++-
 libc/sysdeps/linux/common/bits/sigset.h            |   35 +++++++++++++++++++-
 libc/sysdeps/linux/common/pause.c                  |    2 +-
 libc/unistd/sleep.c                                |    8 +----
 .../nptl/sysdeps/unix/sysv/linux/timer_routines.c  |    2 +-
 6 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/libc/signal/sigsetops.c b/libc/signal/sigsetops.c
index e39d32f..fa5fe6a 100644
--- a/libc/signal/sigsetops.c
+++ b/libc/signal/sigsetops.c
@@ -12,6 +12,9 @@
 
 /* Since we massaged signal.h into emitting non-inline function
  * definitions, we need to finish PLT avoidance trick: */
+#undef __sigismember
+#undef __sigaddset
+#undef __sigdelset
 libc_hidden_def(__sigismember)
 libc_hidden_def(__sigaddset)
 libc_hidden_def(__sigdelset)
diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c
index acd8676..59f5cc9 100644
--- a/libc/stdlib/system.c
+++ b/libc/stdlib/system.c
@@ -126,9 +126,10 @@ do_system (const char *line)
   struct sigaction sa;
   sigset_t omask;
 
+  memset(&sa, 0, sizeof(sa));
   sa.sa_handler = SIG_IGN;
-  sa.sa_flags = 0;
-  __sigemptyset (&sa.sa_mask);
+  /*sa.sa_flags = 0; - done by memset */
+  /*__sigemptyset (&sa.sa_mask); - done by memset */
 
   DO_LOCK ();
   if (ADD_REF () == 0)
diff --git a/libc/sysdeps/linux/common/bits/sigset.h b/libc/sysdeps/linux/common/bits/sigset.h
index 7c2ce0e..4ef2231 100644
--- a/libc/sysdeps/linux/common/bits/sigset.h
+++ b/libc/sysdeps/linux/common/bits/sigset.h
@@ -175,7 +175,7 @@ _EXTERN_INLINE int							\
 NAME (CONST __sigset_t *__set, int __sig)				\
 {									\
 	unsigned long __mask = __sigmask (__sig);			\
-	unsigned long __word = __sigword (__sig);			\
+	unsigned __word = __sigword (__sig);				\
 	return BODY;							\
 }
 
@@ -186,5 +186,38 @@ __SIGSETFN (__sigdelset, ((__set->__val[__word] &= ~__mask), 0), )
 #  undef __SIGSETFN
 # endif
 
+# ifdef _LIBC
+/* It's far too much PITA to __USE_EXTERN_INLINES from within libc.
+ * Especially since we want to inline only calls with const sig,
+ * but __USE_EXTERN_INLINES will inline all calls!
+ */
+static __always_inline unsigned long
+const_sigismember(const __sigset_t *set, int sig)
+{
+	unsigned long mask = __sigmask(sig);
+	unsigned word = __sigword(sig);
+	return (set->__val[word] & mask);
+}
+#  define __sigismember(set, sig) \
+	(__builtin_constant_p(sig) ? (const_sigismember(set, sig) != 0) : __sigismember(set, sig))
+static __always_inline void
+const_sigaddset(__sigset_t *set, int sig)
+{
+	unsigned long mask = __sigmask(sig);
+	unsigned word = __sigword(sig);
+	set->__val[word] |= mask;
+}
+#  define __sigaddset(set, sig) \
+	(__builtin_constant_p(sig) ? (const_sigaddset(set, sig), 0)  : __sigaddset(set, sig))
+static __always_inline void
+const_sigdelset(__sigset_t *set, int sig)
+{
+	unsigned long mask = __sigmask(sig);
+	unsigned word = __sigword(sig);
+	set->__val[word] &= ~mask;
+}
+#  define __sigdelset(set, sig) \
+	(__builtin_constant_p(sig) ? (const_sigdelset(set, sig), 0) : __sigdelset(set, sig))
+# endif
 
 #endif /* ! _SIGSET_H_fns.  */
diff --git a/libc/sysdeps/linux/common/pause.c b/libc/sysdeps/linux/common/pause.c
index 33eb409..ab16fa7 100644
--- a/libc/sysdeps/linux/common/pause.c
+++ b/libc/sysdeps/linux/common/pause.c
@@ -25,7 +25,7 @@ __libc_pause (void)
 {
   sigset_t set;
 
-  __sigemptyset (&set);
+  /*__sigemptyset (&set); - why? */
   sigprocmask (SIG_BLOCK, NULL, &set);
 
   /* pause is a cancellation point, but so is sigsuspend.
diff --git a/libc/unistd/sleep.c b/libc/unistd/sleep.c
index 6a237e3..c4b8a48 100644
--- a/libc/unistd/sleep.c
+++ b/libc/unistd/sleep.c
@@ -20,14 +20,8 @@
 
 #include <errno.h>
 #include <time.h>
-#include <unistd.h>
-/* Want fast and small __sigemptyset/__sigaddset/__sigismember: */
-/* TODO: make them available (to everybody) without this hack */
-#ifndef __USE_EXTERN_INLINES
-# define __USE_EXTERN_INLINES 1
-#endif
 #include <signal.h>
-
+#include <unistd.h>
 
 
 /* version perusing nanosleep */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
index 2681961..4319d8d 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_routines.c
@@ -175,7 +175,7 @@ __start_helper_thread (void)
   sigset_t ss;
   sigset_t oss;
   sigfillset (&ss);
-  __sigaddset (&ss, SIGCANCEL);
+  /*__sigaddset (&ss, SIGCANCEL); - already done by sigfillset */
   INTERNAL_SYSCALL_DECL (err);
   INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
 
-- 
1.7.2.2



More information about the uClibc-cvs mailing list