summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2007-11-01 21:50:54 +0000
committerRoland McGrath <roland@redhat.com>2007-11-01 21:50:54 +0000
commit6bc09daaf6b249b35dec4283b165b1f39e6d6a0d (patch)
treee686f33d720a8c9ef310da27a74d6a8924f879fb /time.c
parentf17106ee78b1c60ef3cdab3ca474bc11f1fe6923 (diff)
downloadstrace-6bc09daaf6b249b35dec4283b165b1f39e6d6a0d.tar.gz
strace-6bc09daaf6b249b35dec4283b165b1f39e6d6a0d.tar.bz2
strace-6bc09daaf6b249b35dec4283b165b1f39e6d6a0d.tar.xz
2007-09-22 Dmitry V. Levin <ldv@altlinux.org>
* time.c (print_timespec, sprint_timespec): New functions. * defs.h (print_timespec, sprint_timespec): Declare them. * desc.c (sys_io_getevents): Use print_timespec. * stream.c (sys_ppoll): Likewise. (decode_poll): Use sprint_timespec.
Diffstat (limited to 'time.c')
-rw-r--r--time.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/time.c b/time.c
index ce309b6..676aace 100644
--- a/time.c
+++ b/time.c
@@ -150,6 +150,76 @@ sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf)
}
}
+void print_timespec (struct tcb *tcp, long addr)
+{
+ if (addr == 0)
+ tprintf("NULL");
+ else if (!verbose(tcp))
+ tprintf("%#lx", addr);
+ else {
+ int rc;
+
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+ if (personality_wordsize[current_personality] == 4)
+ {
+ struct timeval32 tv;
+
+ if ((rc = umove(tcp, addr, &tv)) >= 0)
+ tprintf("{%u, %u}",
+ tv.tv_sec, tv.tv_usec);
+ } else
+ {
+#endif
+ struct timespec ts;
+
+ if ((rc = umove(tcp, addr, &ts)) >= 0)
+ tprintf("{%lu, %lu}",
+ (unsigned long) ts.tv_sec,
+ (unsigned long) ts.tv_nsec);
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+ }
+#endif
+
+ if (rc < 0)
+ tprintf("{...}");
+ }
+}
+
+void sprint_timespec (char *buf, struct tcb *tcp, long addr)
+{
+ if (addr == 0)
+ strcpy(buf, "NULL");
+ else if (!verbose(tcp))
+ sprintf(buf, "%#lx", addr);
+ else {
+ int rc;
+
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+ if (personality_wordsize[current_personality] == 4)
+ {
+ struct timeval32 tv;
+
+ if ((rc = umove(tcp, addr, &tv)) >= 0)
+ sprintf(buf, "{%u, %u}",
+ tv.tv_sec, tv.tv_usec);
+ } else
+ {
+#endif
+ struct timespec ts;
+
+ if ((rc = umove(tcp, addr, &ts)) >= 0)
+ sprintf(buf, "{%lu, %lu}",
+ (unsigned long) ts.tv_sec,
+ (unsigned long) ts.tv_nsec);
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+ }
+#endif
+
+ if (rc < 0)
+ strcpy(buf, "{...}");
+ }
+}
+
int
sys_time(tcp)
struct tcb *tcp;