Make SIGEV_THREAD_ID decoding less glibc specific
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 11 Nov 2013 23:54:30 +0000 (23:54 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Nov 2013 15:00:13 +0000 (15:00 +0000)
SIGEV_THREAD_ID decoding requires access to an internal member of
struct sigevent.  There seems to be no portable way to do it besides
adding a configure check.

* configure.ac (AC_CHECK_MEMBERS): Check for
struct sigevent._sigev_un._pad and struct sigevent.__pad.
* time.c (printsigevent): Use an appropriate struct sigevent member
to print thread id.

Reported by John Spencer.

configure.ac
time.c

index a2cc89b0ae2ec68bc71e0c9e77b03074be7c4289..a60b25f25c3f28038f26781e6d4d985ec5cb5f89 100644 (file)
@@ -258,6 +258,9 @@ AC_CHECK_TYPES([struct user_desc],,, [#include <asm/ldt.h>])
 
 AC_CHECK_MEMBERS([struct utsname.domainname],,, [#include <sys/utsname.h>])
 
+AC_CHECK_MEMBERS([struct sigevent._sigev_un._pad,
+                 struct sigevent.__pad],,, [#include <signal.h>])
+
 AC_CHECK_DECLS([sys_errlist])
 AC_CHECK_DECLS([sys_siglist, _sys_siglist],,, [#include <signal.h>])
 AC_CHECK_DECLS(m4_normalize([
diff --git a/time.c b/time.c
index 49ebcea0303e5e007b56b3e59bd37115967d68ed..236428120da1caed403c4d2ccfade96d27d6fd90 100644 (file)
--- a/time.c
+++ b/time.c
@@ -781,10 +781,17 @@ printsigevent(struct tcb *tcp, long arg)
                printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
                tprints(", ");
                if (sev.sigev_notify == SIGEV_THREAD_ID)
+#if defined(HAVE_STRUCT_SIGEVENT__SIGEV_UN__PAD)
                        /* _pad[0] is the _tid field which might not be
                           present in the userlevel definition of the
                           struct.  */
                        tprintf("{%d}", sev._sigev_un._pad[0]);
+#elif defined(HAVE_STRUCT_SIGEVENT___PAD)
+                       tprintf("{%d}", sev.__pad[0]);
+#else
+# warning unfamiliar struct sigevent => incomplete SIGEV_THREAD_ID decoding
+                       tprints("{...}");
+#endif
                else if (sev.sigev_notify == SIGEV_THREAD)
                        tprintf("{%p, %p}", sev.sigev_notify_function,
                                sev.sigev_notify_attributes);