From: Dmitry V. Levin Date: Thu, 5 Mar 2015 05:03:41 +0000 (+0000) Subject: Use SIGRTMIN from kernel headers X-Git-Tag: v4.10~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59f63d3106cfd49b507de31497c76c9b8ba85eb8;p=strace Use SIGRTMIN from kernel headers * configure.ac (ASM_SIGRTMIN): Define to SIGRTMIN from . * 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. --- diff --git a/configure.ac b/configure.ac index 4f2e02bf..e73958ca 100644 --- a/configure.ac +++ b/configure.ac @@ -711,13 +711,22 @@ AC_CHECK_SIZEOF([long]) AC_CHECK_SIZEOF([long long]) AC_CHECK_SIZEOF([off_t],,[#include ]) -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 ]) +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 ]) fi diff --git a/signal.c b/signal.c index a970355c..6aab54f7 100644 --- 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 { diff --git a/tests/sigreturn.c b/tests/sigreturn.c index 252f152a..a84f65e9 100644 --- a/tests/sigreturn.c +++ b/tests/sigreturn.c @@ -1,12 +1,20 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include #include +#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); diff --git a/tests/sigreturn.test b/tests/sigreturn.test index 0395e825..1e96eded 100755 --- a/tests/sigreturn.test +++ b/tests/sigreturn.test @@ -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"