time: use indexed lookups
* defs.h (xlat_idx): New prototype. * xlat.c (xlat_idx): Remove static qualifier. * time.c (do_adjtimex): Use xlat_idx instead of xlookup. (SYS_FUNC(getitimer), SYS_FUNC(setitimer)): Use printxval_index instead of printxval. [ALPHA] (SYS_FUNC(osf_getitimer), SYS_FUNC(osf_setitimer)): Likewise. (printclockname) [CLOCKID_TO_FD]: Likewise. * xlat/adjtimex_state.in: Add "#value_indexed" directive. * xlat/clocknames.in: Likewise. * xlat/cpuclocknames.in: Add "#value_indexed" directive, add default values to constants. * xlat/itimer_which.in: Likewise.
This commit is contained in:
parent
0c75ebaad0
commit
4e0c0becf9
1
defs.h
1
defs.h
@ -536,6 +536,7 @@ extern enum sock_proto getfdproto(struct tcb *, int);
|
||||
|
||||
extern const char *xlookup(const struct xlat *, const uint64_t);
|
||||
extern const char *xlat_search(const struct xlat *, const size_t, const uint64_t);
|
||||
extern const char *xlat_idx(const struct xlat *xlat, size_t nmemb, uint64_t val);
|
||||
|
||||
struct dyxlat;
|
||||
struct dyxlat *dyxlat_alloc(size_t nmemb);
|
||||
|
30
time.c
30
time.c
@ -116,7 +116,8 @@ SYS_FUNC(nanosleep)
|
||||
SYS_FUNC(getitimer)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
|
||||
printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
|
||||
"ITIMER_???");
|
||||
tprints(", ");
|
||||
} else {
|
||||
print_itimerval(tcp, tcp->u_arg[1]);
|
||||
@ -128,7 +129,8 @@ SYS_FUNC(getitimer)
|
||||
SYS_FUNC(osf_getitimer)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
|
||||
printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
|
||||
"ITIMER_???");
|
||||
tprints(", ");
|
||||
} else {
|
||||
print_itimerval32(tcp, tcp->u_arg[1]);
|
||||
@ -140,7 +142,8 @@ SYS_FUNC(osf_getitimer)
|
||||
SYS_FUNC(setitimer)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
|
||||
printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
|
||||
"ITIMER_???");
|
||||
tprints(", ");
|
||||
print_itimerval(tcp, tcp->u_arg[1]);
|
||||
tprints(", ");
|
||||
@ -154,7 +157,8 @@ SYS_FUNC(setitimer)
|
||||
SYS_FUNC(osf_setitimer)
|
||||
{
|
||||
if (entering(tcp)) {
|
||||
printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
|
||||
printxval_index(itimer_which, (unsigned int) tcp->u_arg[0],
|
||||
"ITIMER_???");
|
||||
tprints(", ");
|
||||
print_itimerval32(tcp, tcp->u_arg[1]);
|
||||
tprints(", ");
|
||||
@ -172,7 +176,8 @@ do_adjtimex(struct tcb *const tcp, const kernel_ulong_t addr)
|
||||
{
|
||||
if (print_timex(tcp, addr))
|
||||
return 0;
|
||||
tcp->auxstr = xlookup(adjtimex_state, (kernel_ulong_t) tcp->u_rval);
|
||||
tcp->auxstr = xlat_idx(adjtimex_state, ARRAY_SIZE(adjtimex_state) - 1,
|
||||
(kernel_ulong_t) tcp->u_rval);
|
||||
return RVAL_STR;
|
||||
}
|
||||
|
||||
@ -196,16 +201,19 @@ printclockname(int clockid)
|
||||
if ((clockid & CLOCKFD_MASK) == CLOCKFD)
|
||||
tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
|
||||
else {
|
||||
if (CPUCLOCK_PERTHREAD(clockid))
|
||||
tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
|
||||
else
|
||||
tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
|
||||
printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
|
||||
tprintf("%s(%d,",
|
||||
CPUCLOCK_PERTHREAD(clockid) ?
|
||||
"MAKE_THREAD_CPUCLOCK" :
|
||||
"MAKE_PROCESS_CPUCLOCK",
|
||||
CPUCLOCK_PID(clockid));
|
||||
printxval_index(cpuclocknames,
|
||||
(unsigned int) clockid & CLOCKFD_MASK,
|
||||
"CPUCLOCK_???");
|
||||
tprints(")");
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
printxval(clocknames, clockid, "CLOCK_???");
|
||||
printxval_index(clocknames, clockid, "CLOCK_???");
|
||||
}
|
||||
|
||||
SYS_FUNC(clock_settime)
|
||||
|
2
xlat.c
2
xlat.c
@ -226,7 +226,7 @@ printxval_searchn_ex(const struct xlat *xlat, size_t xlat_size, uint64_t val,
|
||||
xlat_search);
|
||||
}
|
||||
|
||||
static const char *
|
||||
const char *
|
||||
xlat_idx(const struct xlat *xlat, size_t nmemb, uint64_t val)
|
||||
{
|
||||
if (val >= nmemb)
|
||||
|
@ -1,3 +1,4 @@
|
||||
#value_indexed
|
||||
TIME_OK 0
|
||||
TIME_INS 1
|
||||
TIME_DEL 2
|
||||
|
@ -1,3 +1,4 @@
|
||||
#value_indexed
|
||||
CLOCK_REALTIME 0
|
||||
CLOCK_MONOTONIC 1
|
||||
CLOCK_PROCESS_CPUTIME_ID 2
|
||||
|
@ -1,3 +1,4 @@
|
||||
CPUCLOCK_PROF
|
||||
CPUCLOCK_VIRT
|
||||
CPUCLOCK_SCHED
|
||||
#value_indexed
|
||||
CPUCLOCK_PROF 0
|
||||
CPUCLOCK_VIRT 1
|
||||
CPUCLOCK_SCHED 2
|
||||
|
@ -1,3 +1,4 @@
|
||||
ITIMER_REAL
|
||||
ITIMER_VIRTUAL
|
||||
ITIMER_PROF
|
||||
#value_indexed
|
||||
ITIMER_REAL 0
|
||||
ITIMER_VIRTUAL 1
|
||||
ITIMER_PROF 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user