summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2006-12-13 17:10:11 +0000
committerDmitry V. Levin <ldv@altlinux.org>2006-12-13 17:10:11 +0000
commita7945a3d4e144674a8dd1d885e7086bc274e391b (patch)
treed0fd8f9ac31e16987540f7200c3b2307a210a453 /time.c
parent4ebb4e3d312bb8215f4eea9130cce6bb8bdb972f (diff)
downloadstrace-a7945a3d4e144674a8dd1d885e7086bc274e391b.tar.gz
strace-a7945a3d4e144674a8dd1d885e7086bc274e391b.tar.bz2
strace-a7945a3d4e144674a8dd1d885e7086bc274e391b.tar.xz
2006-12-10 Dmitry V. Levin <ldv@altlinux.org>
Add biarch support for "struct timeval". * defs.h (bitness_t): New enum type. (printtv_bitness, sprinttv): New function prototypes. (printtv): Convert to macro wrapper around printtv_bitness(). (printtv32): Remove. * desc.c (decode_select): Use printtv_bitness() and sprinttv(). (sys_oldselect, sys_osf_select, sys_select, sys_pselect6): Update decode_select() use. * file.c [ALPHA] (sys_osf_utimes): Use printtv_bitness(). * time.c (printtv_bitness, sprinttv): New functions. (printtv, printtv32): Remove. [ALPHA] (sys_osf_settimeofday, sys_osf_settimeofday): Use printtv_bitness(). Fixes RH#171626, RH#173050.
Diffstat (limited to 'time.c')
-rw-r--r--time.c100
1 files changed, 68 insertions, 32 deletions
diff --git a/time.c b/time.c
index ebd788f..cbfa556 100644
--- a/time.c
+++ b/time.c
@@ -38,48 +38,84 @@
#include <linux/rtc.h>
#endif /* LINUX */
-void
-printtv(tcp, addr)
-struct tcb *tcp;
-long addr;
+struct timeval32
{
- struct timeval tv;
+ u_int32_t tv_sec, tv_usec;
+};
+void
+printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
+{
if (addr == 0)
tprintf("NULL");
else if (!verbose(tcp))
tprintf("%#lx", addr);
- else if (umove(tcp, addr, &tv) < 0)
- tprintf("{...}");
else
- tprintf("{%lu, %lu}", (long) tv.tv_sec, (long) tv.tv_usec);
-}
+ {
+ int rc;
-#ifdef ALPHA
-struct timeval32
-{
- unsigned tv_sec;
- unsigned tv_usec;
-};
+ if (bitness == BITNESS_32
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+ || personality_wordsize[current_personality] == 4
+#endif
+ )
+ {
+ struct timeval32 tv;
+
+ if ((rc = umove(tcp, addr, &tv)) >= 0)
+ tprintf("{%u, %u}",
+ tv.tv_sec, tv.tv_usec);
+ } else
+ {
+ struct timeval tv;
+
+ if ((rc = umove(tcp, addr, &tv)) >= 0)
+ tprintf("{%lu, %lu}",
+ (unsigned long) tv.tv_sec,
+ (unsigned long) tv.tv_usec);
+ }
+
+ if (rc < 0)
+ tprintf("{...}");
+ }
+}
void
-printtv32(tcp, addr)
-struct tcb *tcp;
-long addr;
+sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf)
{
- struct timeval32 tv;
+ if (addr == 0)
+ strcpy(buf, "NULL");
+ else if (!verbose(tcp))
+ sprintf(buf, "%#lx", addr);
+ else
+ {
+ int rc;
- if (addr == 0)
- tprintf("NULL");
- else if (!verbose(tcp))
- tprintf("%#lx", addr);
- else if (umove(tcp, addr, &tv) < 0)
- tprintf("{...}");
- else
- tprintf("{%u, %u}", tv.tv_sec, tv.tv_usec);
-}
+ if (bitness == BITNESS_32
+#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
+ || personality_wordsize[current_personality] == 4
#endif
+ )
+ {
+ struct timeval32 tv;
+
+ if ((rc = umove(tcp, addr, &tv)) >= 0)
+ sprintf(buf, "{%u, %u}",
+ tv.tv_sec, tv.tv_usec);
+ } else
+ {
+ struct timeval tv;
+
+ if ((rc = umove(tcp, addr, &tv)) >= 0)
+ sprintf(buf, "{%lu, %lu}",
+ (unsigned long) tv.tv_sec,
+ (unsigned long) tv.tv_usec);
+ }
+ if (rc < 0)
+ strcpy(buf, "{...}");
+ }
+}
int
sys_time(tcp)
@@ -134,10 +170,10 @@ struct tcb *tcp;
tcp->u_arg[0], tcp->u_arg[1]);
return 0;
}
- printtv32(tcp, tcp->u_arg[0]);
+ printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
#ifndef SVR4
tprintf(", ");
- printtv32(tcp, tcp->u_arg[1]);
+ printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
#endif /* !SVR4 */
}
return 0;
@@ -164,10 +200,10 @@ sys_osf_settimeofday(tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
- printtv32(tcp, tcp->u_arg[0]);
+ printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
#ifndef SVR4
tprintf(", ");
- printtv32(tcp, tcp->u_arg[1]);
+ printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
#endif /* !SVR4 */
}
return 0;