]> granicus.if.org Git - strace/commitdiff
Convert parser of struct sigevent to new mpers infrastructure
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 16 Sep 2015 16:31:43 +0000 (16:31 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 16 Sep 2015 21:16:28 +0000 (21:16 +0000)
* defs.h (sigev_value): New prototype.
(printsigevent): Remove.
* print_sigevent.c (struct_sigevent): New typedef.  Mpersify it.
[IN_MPERS]: Do not include "xlat/sigev_value.h".
(printsigevent32): Remove.
(printsigevent): Rename to print_sigevent.  Mpersify it.
* mq.c (sys_mq_notify): Rename printsigevent to print_sigevent.
* time.c (sys_timer_create): Likewise.

defs.h
mq.c
print_sigevent.c
time.c

diff --git a/defs.h b/defs.h
index 5531bbc40ff498b874ced3f841c5cce44fc0b91d..9e5528cf8eef9bf2e0ef1b8e0bb0493b36633657 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -414,6 +414,7 @@ extern const struct xlat at_flags[];
 extern const struct xlat open_access_modes[];
 extern const struct xlat open_mode_flags[];
 extern const struct xlat resource_flags[];
+extern const struct xlat sigev_value[];
 extern const struct xlat whence_codes[];
 
 /* Format of syscall return values */
@@ -650,7 +651,6 @@ extern void printtv_bitness(struct tcb *, long, enum bitness_t, int);
 extern char *sprinttv(char *, struct tcb *, long, enum bitness_t, int special);
 extern void print_timespec(struct tcb *, long);
 extern void sprint_timespec(char *, struct tcb *, long);
-extern void printsigevent(struct tcb *tcp, long arg);
 extern void printfd(struct tcb *, int);
 extern bool print_sockaddr_by_inode(const unsigned long, const char *);
 extern void print_dirfd(struct tcb *, int);
diff --git a/mq.c b/mq.c
index 59a093a0edfa56fd7c29c67446e9025c2b2fd335..ca0cfdaf2831ddaa03b16eb60c893072c1838e7e 100644 (file)
--- a/mq.c
+++ b/mq.c
@@ -67,7 +67,7 @@ SYS_FUNC(mq_timedreceive)
 SYS_FUNC(mq_notify)
 {
        tprintf("%ld, ", tcp->u_arg[0]);
-       printsigevent(tcp, tcp->u_arg[1]);
+       print_sigevent(tcp, tcp->u_arg[1]);
        return RVAL_DECODED;
 }
 
index 52337cb7a51b035c0fa35e5a7dc2f474ea1cf9d1..f752120b498d98b72e39213e04847aa46eee7bbb 100644 (file)
 
 #include "defs.h"
 
-#include <signal.h>
-
-#include "xlat/sigev_value.h"
+#include DEF_MPERS_TYPE(struct_sigevent)
 
-#if SUPPORTED_PERSONALITIES > 1
-static void
-printsigevent32(struct tcb *tcp, long arg)
-{
-       struct {
-               int     sigev_value;
-               int     sigev_signo;
-               int     sigev_notify;
+#include <signal.h>
+typedef struct sigevent struct_sigevent;
 
-               union {
-                       int     tid;
-                       struct {
-                               int     function, attribute;
-                       } thread;
-               } un;
-       } sev;
+#include MPERS_DEFS
 
-       if (!umove_or_printaddr(tcp, arg, &sev)) {
-               tprintf("{%#x, ", sev.sigev_value);
-               if (sev.sigev_notify == SIGEV_SIGNAL)
-                       tprintf("%s, ", signame(sev.sigev_signo));
-               else
-                       tprintf("%u, ", sev.sigev_signo);
-               printxval(sigev_value, sev.sigev_notify, "SIGEV_???");
-               tprints(", ");
-               if (sev.sigev_notify == SIGEV_THREAD_ID)
-                       tprintf("{%d}", sev.un.tid);
-               else if (sev.sigev_notify == SIGEV_THREAD)
-                       tprintf("{%#x, %#x}",
-                               sev.un.thread.function,
-                               sev.un.thread.attribute);
-               else
-                       tprints("{...}");
-               tprints("}");
-       }
-}
+#ifndef IN_MPERS
+# include "xlat/sigev_value.h"
 #endif
 
-void
-printsigevent(struct tcb *tcp, long arg)
+MPERS_PRINTER_DECL(void, print_sigevent)(struct tcb *tcp, const long addr)
 {
-       struct sigevent sev;
+       struct_sigevent sev;
 
-#if SUPPORTED_PERSONALITIES > 1
-       if (current_wordsize == 4) {
-               printsigevent32(tcp, arg);
-               return;
-       }
-#endif
-       if (!umove_or_printaddr(tcp, arg, &sev)) {
-               tprintf("{%p, ", sev.sigev_value.sival_ptr);
+       if (!umove_or_printaddr(tcp, addr, &sev)) {
+               tprintf("{%#lx, ", (unsigned long) sev.sigev_value.sival_ptr);
                if (sev.sigev_notify == SIGEV_SIGNAL)
                        tprintf("%s, ", signame(sev.sigev_signo));
                else
@@ -102,8 +64,9 @@ printsigevent(struct tcb *tcp, long arg)
                        tprints("{...}");
 #endif
                else if (sev.sigev_notify == SIGEV_THREAD)
-                       tprintf("{%p, %p}", sev.sigev_notify_function,
-                               sev.sigev_notify_attributes);
+                       tprintf("{%#lx, %#lx}",
+                               (unsigned long) sev.sigev_notify_function,
+                               (unsigned long) sev.sigev_notify_attributes);
                else
                        tprints("{...}");
                tprints("}");
diff --git a/time.c b/time.c
index 429f4618492e027769484455c4b23c3e27c6ec91..91e091584272b876c1158bf509bbf90a344a5842 100644 (file)
--- a/time.c
+++ b/time.c
@@ -514,7 +514,7 @@ SYS_FUNC(timer_create)
        if (entering(tcp)) {
                printclockname(tcp->u_arg[0]);
                tprints(", ");
-               printsigevent(tcp, tcp->u_arg[1]);
+               print_sigevent(tcp, tcp->u_arg[1]);
                tprints(", ");
        } else {
                printnum_int(tcp, tcp->u_arg[2], "%d");