]> granicus.if.org Git - strace/commitdiff
Use SIGRTMIN from kernel headers
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 5 Mar 2015 05:03:41 +0000 (05:03 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 5 Mar 2015 05:42:30 +0000 (05:42 +0000)
* configure.ac (ASM_SIGRTMIN): Define to SIGRTMIN from <asm/signal.h>.
* signal.c: Use ASM_SIGRTMIN instead of constants provided by libc.
* tests/sigreturn.c: Use ASM_SIGRTMIN instead of hardcoded value.
Use lower RT_* numbers to support pre-3.18 hppa kernels.
* tests/sigreturn.test: Update regexp.

configure.ac
signal.c
tests/sigreturn.c
tests/sigreturn.test

index 4f2e02bfc1d55fa3fc8ed0b4ee82db1f399a9959..e73958caabb6a257015c0769f9e58771a30d32c1 100644 (file)
@@ -711,13 +711,22 @@ AC_CHECK_SIZEOF([long])
 AC_CHECK_SIZEOF([long long])
 AC_CHECK_SIZEOF([off_t],,[#include <sys/types.h>])
 
-AC_CACHE_CHECK([for SA_RESTORER], [st_cv_sa_restorer],
-              [st_cv_sa_restorer="$(echo SA_RESTORER |
+AC_CACHE_CHECK([for SIGRTMIN], [st_cv_SIGRTMIN],
+              [[st_cv_SIGRTMIN="$(echo SIGRTMIN |
+                       $CPP $CPPFLAGS -P -imacros asm/signal.h - |
+                       grep '^[0-9]')"
+                test -n "$st_cv_SIGRTMIN" || st_cv_SIGRTMIN=no]])
+if test "x$st_cv_SIGRTMIN" != xno; then
+       AC_DEFINE_UNQUOTED([ASM_SIGRTMIN], [$st_cv_SIGRTMIN],
+                          [SIGRTMIN defined in <asm/signal.h>])
+fi
+AC_CACHE_CHECK([for SA_RESTORER], [st_cv_SA_RESTORER],
+              [st_cv_SA_RESTORER="$(echo SA_RESTORER |
                        $CPP $CPPFLAGS -P -imacros asm/signal.h - |
                        grep ^0x)"
-               test -n "$st_cv_sa_restorer" || st_cv_sa_restorer=no])
-if test "x$st_cv_sa_restorer" != xno; then
-       AC_DEFINE_UNQUOTED([ASM_SA_RESTORER], [$st_cv_sa_restorer],
+               test -n "$st_cv_SA_RESTORER" || st_cv_SA_RESTORER=no])
+if test "x$st_cv_SA_RESTORER" != xno; then
+       AC_DEFINE_UNQUOTED([ASM_SA_RESTORER], [$st_cv_SA_RESTORER],
                           [SA_RESTORER defined in <asm/signal.h>])
 fi
 
index a970355c74057a01bd7a4950630990160bd6abb0..6aab54f700cd4a75356a15709f6ddcafc83fd2c4 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -102,13 +102,21 @@ struct sigcontext {
 #include "xlat/sigprocmaskcmds.h"
 
 /* Anonymous realtime signals. */
-/* Under glibc 2.1, SIGRTMIN et al are functions, but __SIGRTMIN is a
-   constant.  This is what we want.  Otherwise, just use SIGRTMIN. */
-#ifdef SIGRTMIN
-#ifndef __SIGRTMIN
-#define __SIGRTMIN SIGRTMIN
-#define __SIGRTMAX SIGRTMAX /* likewise */
+#ifndef ASM_SIGRTMIN
+/* Linux kernel >= 3.18 defines SIGRTMIN to 32 on all architectures. */
+# define ASM_SIGRTMIN 32
 #endif
+#ifndef ASM_SIGRTMAX
+/* Under glibc 2.1, SIGRTMAX et al are functions, but __SIGRTMAX is a
+   constant.  This is what we want.  Otherwise, just use SIGRTMAX. */
+# ifdef SIGRTMAX
+#  ifndef __SIGRTMAX
+#   define __SIGRTMAX SIGRTMAX
+#  endif
+# endif
+# ifdef __SIGRTMAX
+#  define ASM_SIGRTMAX __SIGRTMAX
+# endif
 #endif
 
 /* Note on the size of sigset_t:
@@ -143,9 +151,9 @@ signame(const int sig)
 
                if (s < nsignals)
                        return signalent[s];
-#ifdef SIGRTMIN
-               if (s >= __SIGRTMIN && s <= __SIGRTMAX) {
-                       sprintf(buf, "SIGRT_%u", s - __SIGRTMIN);
+#ifdef ASM_SIGRTMAX
+               if (s >= ASM_SIGRTMIN && s <= ASM_SIGRTMAX) {
+                       sprintf(buf, "SIGRT_%u", s - ASM_SIGRTMIN);
                        return buf;
                }
 #endif
@@ -214,9 +222,9 @@ sprintsigmask_n(const char *prefix, const void *sig_mask, unsigned int bytes)
                if ((unsigned) i < nsignals) {
                        s = stpcpy(s, signalent[i] + 3);
                }
-#ifdef SIGRTMIN
-               else if (i >= __SIGRTMIN && i <= __SIGRTMAX) {
-                       s += sprintf(s, "RT_%u", i - __SIGRTMIN);
+#ifdef ASM_SIGRTMAX
+               else if (i >= ASM_SIGRTMIN && i <= ASM_SIGRTMAX) {
+                       s += sprintf(s, "RT_%u", i - ASM_SIGRTMIN);
                }
 #endif
                else {
index 252f152a23377d08e31ce74e604be9cf7aabbfae..a84f65e98e8065a1710f1024ec5c321f768c3e43 100644 (file)
@@ -1,12 +1,20 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 #include <stdlib.h>
 #include <signal.h>
 
+#ifdef ASM_SIGRTMIN
+# define RT_0 ASM_SIGRTMIN
+#else
+/* Linux kernel >= 3.18 defines SIGRTMIN to 32 on all architectures. */
+# define RT_0 32
+#endif
+
 static void handler(int sig)
 {
 }
 
-#define RT_0 32
-
 int main(void) {
        sigset_t set;
        sigemptyset(&set);
@@ -15,8 +23,8 @@ int main(void) {
        sigaddset(&set, RT_0 +  2);
        sigaddset(&set, RT_0 +  3);
        sigaddset(&set, RT_0 +  4);
-       sigaddset(&set, RT_0 + 31);
-       sigaddset(&set, RT_0 + 32);
+       sigaddset(&set, RT_0 + 26);
+       sigaddset(&set, RT_0 + 27);
        sigprocmask(SIG_SETMASK, &set, NULL);
        signal(SIGUSR1, handler);
        raise(SIGUSR1);
index 0395e8250044053eae6976801c55f80683f5986b..1e96eded981b66a17a46bd9185c1b3ba168115a3 100755 (executable)
@@ -21,7 +21,7 @@ grep_log()
        }
 }
 
-mask='\[(USR2 CHLD|CHLD USR2) RT_2 RT_3 RT_4 RT_31 RT_32\]'
+mask='\[(USR2 CHLD|CHLD USR2) RT_2 RT_3 RT_4 RT_26 RT_27\]'
 rt_sigprocmask='rt_sigprocmask\(SIG_SETMASK, '"$mask"', NULL, [[:digit:]]+\) += 0'
 osf_sigprocmask='osf_sigprocmask\(SIG_SETMASK, '"$mask"'\) += 0 +\(old mask \[[^]]*\]\)'
 grep_log "$rt_sigprocmask|$osf_sigprocmask"