* print_time.c (sprint_timeval): New mpers printer.
[ALPHA] (sprint_timeval32): New function.
* defs.h [ALPHA] (sprint_timeval32): New prototype.
(bitness_t, TIMEVAL_TEXT_BUFSIZE, printtv_bitness, sprinttv): Remove.
* desc.c (decode_select): Replace bitness parameter with two printers.
Use them instead of printtv_bitness and sprinttv.
(sys_oldselect, sys_select): Pass print_timeval and sprint_timeval
to decode_select.
[ALPHA] (sys_osf_select): Pass print_timeval32 and sprint_timeval32
to decode_select.
(pselect6): Pass print_timespec and sprint_timespec to decode_select.
* time.c (UTIME_NOW, UTIME_OMIT, current_time_t_is_compat,
struct timeval32, printtv_bitness, do_sprinttv, sprinttv): Remove.
#undef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
-enum bitness_t { BITNESS_CURRENT = 0, BITNESS_32 };
-
void error_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
void perror_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
void error_msg_and_die(const char *fmt, ...)
extern void printpathn(struct tcb *, long, unsigned int);
#define TIMESPEC_TEXT_BUFSIZE \
(sizeof(intmax_t)*3 * 2 + sizeof("{tv_sec=%jd, tv_nsec=%jd}"))
-#define TIMEVAL_TEXT_BUFSIZE TIMESPEC_TEXT_BUFSIZE
-extern void printtv_bitness(struct tcb *, long, enum bitness_t, int);
-extern char *sprinttv(char *, struct tcb *, long, enum bitness_t, int special);
extern void printfd(struct tcb *, int);
extern bool print_sockaddr_by_inode(const unsigned long, const char *);
extern void print_dirfd(struct tcb *, int);
extern void print_sock_optmgmt(struct tcb *, long, int);
#ifdef ALPHA
extern void printrusage32(struct tcb *, long);
+extern const char *sprint_timeval32(struct tcb *tcp, long);
extern void print_timeval32(struct tcb *tcp, long);
extern void print_timeval32_pair(struct tcb *tcp, long);
extern void print_itimerval32(struct tcb *tcp, long);
#endif
static int
-decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
+decode_select(struct tcb *tcp, long *args,
+ void (*print_tv_ts) (struct tcb *, const long),
+ const char * (*sprint_tv_ts) (struct tcb *, const long))
{
int i, j;
int nfds, fdsize;
}
free(fds);
tprints(", ");
- printtv_bitness(tcp, args[4], bitness, 0);
+ print_tv_ts(tcp, args[4]);
} else {
static char outstr[1024];
char *outptr;
free(fds);
/* This contains no useful information on SunOS. */
if (args[4]) {
- if (outptr < end_outstr - (10 + TIMEVAL_TEXT_BUFSIZE)) {
- outptr += sprintf(outptr, "%sleft ", sep);
- outptr = sprinttv(outptr, tcp, args[4], bitness, /*special:*/ 0);
+ const char *str = sprint_tv_ts(tcp, args[4]);
+ if (outptr + sizeof("left ") + strlen(sep) + strlen(str) < end_outstr) {
+ outptr += sprintf(outptr, "%sleft %s", sep, str);
}
}
*outptr = '\0';
long_args[i] = oldselect_args[i];
}
#endif
- return decode_select(tcp, long_args, BITNESS_CURRENT);
+ return decode_select(tcp, long_args, print_timeval, sprint_timeval);
#undef oldselect_args
}
#ifdef ALPHA
SYS_FUNC(osf_select)
{
- return decode_select(tcp, tcp->u_arg, BITNESS_32);
+ return decode_select(tcp, tcp->u_arg, print_timeval32, sprint_timeval32);
}
#endif
SYS_FUNC(select)
{
- return decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
+ return decode_select(tcp, tcp->u_arg, print_timeval, sprint_timeval);
}
SYS_FUNC(pselect6)
{
- int rc = decode_select(tcp, tcp->u_arg, BITNESS_CURRENT);
+ int rc = decode_select(tcp, tcp->u_arg, print_timespec, sprint_timespec);
if (entering(tcp)) {
unsigned long data[2];
tprints("]");
}
+MPERS_PRINTER_DECL(const char *, sprint_timeval)(struct tcb *tcp, const long addr)
+{
+ timeval_t t;
+ static char buf[sizeof(time_fmt) + 3 * sizeof(t)];
+
+ if (!addr) {
+ strcpy(buf, "NULL");
+ } else if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
+ umove(tcp, addr, &t)) {
+ snprintf(buf, sizeof(buf), "%#lx", addr);
+ } else {
+ snprintf(buf, sizeof(buf), time_fmt,
+ (intmax_t) t.tv_sec, (intmax_t) t.tv_usec);
+ }
+
+ return buf;
+}
+
MPERS_PRINTER_DECL(void, print_itimerval)(struct tcb *tcp, const long addr)
{
timeval_t t[2];
tprints("}");
}
+const char *
+sprint_timeval32(struct tcb *tcp, const long addr)
+{
+ timeval32_t t;
+ static char buf[sizeof(time_fmt) + 3 * sizeof(t)];
+
+ if (!addr) {
+ strcpy(buf, "NULL");
+ } else if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)) ||
+ umove(tcp, addr, &t)) {
+ snprintf(buf, sizeof(buf), "%#lx", addr);
+ } else {
+ snprintf(buf, sizeof(buf), time_fmt,
+ (intmax_t) t.tv_sec, (intmax_t) t.tv_usec);
+ }
+
+ return buf;
+}
+
#endif /* ALPHA */
#include <signal.h>
#include <sys/timex.h>
-#ifndef UTIME_NOW
-#define UTIME_NOW ((1l << 30) - 1l)
-#endif
-#ifndef UTIME_OMIT
-#define UTIME_OMIT ((1l << 30) - 2l)
-#endif
-
-#if SUPPORTED_PERSONALITIES > 1
-# if defined X86_64 || defined X32
-# define current_time_t_is_compat (current_personality == 1)
-# else
-# define current_time_t_is_compat (current_wordsize == 4)
-# endif
-#else
-# define current_time_t_is_compat 0
-#endif
-
-struct timeval32
-{
- u_int32_t tv_sec, tv_usec;
-};
-
-void
-printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
-{
- char buf[TIMEVAL_TEXT_BUFSIZE];
- sprinttv(buf, tcp, addr, bitness, special);
- tprints(buf);
-}
-
-static char *
-do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec,
- const int special)
-{
- if (special) {
- switch (usec) {
- case UTIME_NOW:
- return stpcpy(buf, "UTIME_NOW");
- case UTIME_OMIT:
- return stpcpy(buf, "UTIME_OMIT");
- }
- }
- return buf + sprintf(buf, "{%ju, %ju}", sec, usec);
-}
-
-char *
-sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
-{
- if (addr == 0)
- return stpcpy(buf, "NULL");
-
- if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
- return buf + sprintf(buf, "%#lx", addr);
-
- if (bitness == BITNESS_32 || current_time_t_is_compat)
- {
- struct timeval32 tv;
-
- if (umove(tcp, addr, &tv) >= 0)
- return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
- } else {
- struct timeval tv;
-
- if (umove(tcp, addr, &tv) >= 0)
- return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
- }
-
- return buf + sprintf(buf, "%#lx", addr);
-}
-
static void
print_timezone(struct tcb *tcp, const long addr)
{