]> granicus.if.org Git - strace/commitdiff
time.c: introduce do_clock_gettime, do_clock_settime, and do_clock_nanosleep
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 4 May 2019 23:15:52 +0000 (23:15 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 4 May 2019 23:15:52 +0000 (23:15 +0000)
These are going to be used to implement parsers of clock_gettime64,
clock_settime64, and clock_nanosleep_time64 syscalls.

* time.c (do_clock_settime, do_clock_gettime, do_clock_nanosleep): New
functions.
((SYS_FUNC(clock_settime)): Turn into a thin wrapper around
do_clock_settime.
((SYS_FUNC(clock_gettime)): Turn into a thin wrapper around
do_clock_gettime.
((SYS_FUNC(clock_nanosleep)): Turn into a thin wrapper around
do_clock_nanosleep.

time.c

diff --git a/time.c b/time.c
index 80dddd438b823968acd0d22bacd323c896f530aa..21b839e17c9a15c0e50fe122971b5dbc01694a94 100644 (file)
--- a/time.c
+++ b/time.c
@@ -209,34 +209,47 @@ printclockname(int clockid)
                printxval_index(clocknames, clockid, "CLOCK_???");
 }
 
-SYS_FUNC(clock_settime)
+static int
+do_clock_settime(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
 {
        printclockname(tcp->u_arg[0]);
        tprints(", ");
-       print_timespec(tcp, tcp->u_arg[1]);
+       print_ts(tcp, tcp->u_arg[1]);
 
        return RVAL_DECODED;
 }
 
-SYS_FUNC(clock_gettime)
+SYS_FUNC(clock_settime)
+{
+       return do_clock_settime(tcp, print_timespec);
+}
+
+static int
+do_clock_gettime(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
 {
        if (entering(tcp)) {
                printclockname(tcp->u_arg[0]);
                tprints(", ");
        } else {
-               print_timespec(tcp, tcp->u_arg[1]);
+               print_ts(tcp, tcp->u_arg[1]);
        }
        return 0;
 }
 
-SYS_FUNC(clock_nanosleep)
+SYS_FUNC(clock_gettime)
+{
+       return do_clock_gettime(tcp, print_timespec);
+}
+
+static int
+do_clock_nanosleep(struct tcb *const tcp, const print_obj_by_addr_fn print_ts)
 {
        if (entering(tcp)) {
                printclockname(tcp->u_arg[0]);
                tprints(", ");
                printflags(clockflags, tcp->u_arg[1], "TIMER_???");
                tprints(", ");
-               print_timespec(tcp, tcp->u_arg[2]);
+               print_ts(tcp, tcp->u_arg[2]);
                tprints(", ");
        } else {
                /*
@@ -245,7 +258,7 @@ SYS_FUNC(clock_nanosleep)
                 */
                if (!tcp->u_arg[1] && is_erestart(tcp)) {
                        temporarily_clear_syserror(tcp);
-                       print_timespec(tcp, tcp->u_arg[3]);
+                       print_ts(tcp, tcp->u_arg[3]);
                        restore_cleared_syserror(tcp);
                } else {
                        printaddr(tcp->u_arg[3]);
@@ -254,6 +267,11 @@ SYS_FUNC(clock_nanosleep)
        return 0;
 }
 
+SYS_FUNC(clock_nanosleep)
+{
+       return do_clock_nanosleep(tcp, print_timespec);
+}
+
 static int
 do_clock_adjtime(struct tcb *const tcp, const print_obj_by_addr_fn print_tx)
 {