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.
#define P(args) ()
#endif
+enum bitness_t { BITNESS_CURRENT = 0, BITNESS_32 };
+
extern int set_personality P((int personality));
extern char *xlookup P((const struct xlat *, int));
extern struct tcb *alloctcb P((int));
extern void printnum_int P((struct tcb *, long, char *));
extern void printpath P((struct tcb *, long));
extern void printpathn P((struct tcb *, long, int));
-extern void printtv P((struct tcb *, long));
+extern void printtv_bitness P((struct tcb *, long, enum bitness_t));
+extern void sprinttv P((struct tcb *, long, enum bitness_t, char *));
#ifdef HAVE_SIGINFO_T
extern void printsiginfo P((siginfo_t *, int));
#endif
extern void printtrailer P((struct tcb *));
extern void tabto P((int));
extern void call_summary P((FILE *));
-extern void printtv32 P((struct tcb*, long));
extern void tprint_iov P((struct tcb *, unsigned long, unsigned long));
#ifdef LINUX
#define umove(pid, addr, objp) \
umoven((pid), (addr), sizeof *(objp), (char *) (objp))
+#define printtv(tcp, addr) \
+ printtv_bitness((tcp), (addr), BITNESS_CURRENT)
+
#ifdef __STDC__
#ifdef __GNUC__
extern void tprintf(const char *fmt, ...)
#endif /* ALPHA || FREEBSD || SUNOS4 */
static int
-decode_select(tcp, args, bitness)
-struct tcb *tcp;
-long *args;
-int bitness;
+decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
{
int i, j, nfds;
unsigned int fdsize = ((((args[0] + 7) / 8) + sizeof(long) - 1)
& -sizeof(long));
fd_set *fds;
- struct timeval tv;
-#ifdef ALPHA
- struct timeval32 {
- unsigned tv_sec;
- unsigned tv_usec;
- } *tv32;
-#endif
static char outstr[1024];
char *sep;
long arg;
tprintf("]");
}
free(fds);
- if (!args[4])
- tprintf(", NULL");
- else if (!verbose(tcp))
- tprintf(", %#lx", args[4]);
- else if (umove(tcp, args[4], &tv) < 0)
- tprintf(", {...}");
- else {
-#ifdef ALPHA
- if (bitness) {
- tv32=(struct timeval32*)&tv;
- tprintf(", {%u, %u}", tv32->tv_sec, tv32->tv_usec);
- } else
-#endif
- tprintf(", {%lu, %lu}",
- (long) tv.tv_sec, (long) tv.tv_usec);
- }
+ tprintf(", ");
+ printtv_bitness(tcp, args[4], bitness);
}
else
{
#ifdef LINUX
/* This contains no useful information on SunOS. */
if (args[4]) {
- char str[64];
+ char str[128];
- if (umove(tcp, args[4], &tv) >= 0) {
-#ifdef ALPHA
- if (bitness) {
- tv32=(struct timeval32*)&tv;
- sprintf(str, "%sleft {%u, %u}", sep,
- tv32->tv_sec, tv32->tv_usec);
- } else
-#endif
- sprintf(str, "%sleft {%lu, %lu}", sep,
- (long) tv.tv_sec, (long) tv.tv_usec);
-
- if ((cumlen += strlen(str)) < sizeof(outstr))
- strcat(outstr, str);
- }
+ sprintf(str, "%sleft ", sep);
+ sprinttv(tcp, args[4], bitness, str + strlen(str));
+ if ((cumlen += strlen(str)) < sizeof(outstr))
+ strcat(outstr, str);
}
#endif /* LINUX */
return RVAL_STR;
tprintf("[...]");
return 0;
}
- return decode_select(tcp, args, 0);
+ return decode_select(tcp, args, BITNESS_CURRENT);
}
#ifdef ALPHA
struct tcb *tcp;
{
long *args = tcp->u_arg;
- return decode_select(tcp, args, 1);
+ return decode_select(tcp, args, BITNESS_32);
}
#endif
sys_select(tcp)
struct tcb *tcp;
{
- return decode_select(tcp, tcp->u_arg, 0);
+ return decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
}
#ifdef LINUX
int
sys_pselect6(struct tcb *tcp)
{
- int rc = decode_select(tcp, tcp->u_arg, 0);
+ int rc = decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
if (exiting(tcp)) {
struct {
void *ss;
if (entering(tcp)) {
printpath(tcp, tcp->u_arg[0]);
tprintf(", ");
- printtv32(tcp, tcp->u_arg[1]);
+ printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
}
return 0;
}
#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)
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;
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;