From c842118871756d030225c3f1ddf07cf1a4cc5501 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 4 May 2019 23:15:52 +0000 Subject: [PATCH] time.c: introduce do_clock_gettime, do_clock_settime, and do_clock_nanosleep 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 | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/time.c b/time.c index 80dddd43..21b839e1 100644 --- 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) { -- 2.40.0