xlat: introduce XLAT_STYLE_FMT_D

As there are some possible users for it, apparently.

* defs.h (XLAT_STYLE_FORMAT_MASK): Update the value in order to
accommodate XLAT_STYLE_FMT_D.
(enum xlat_style) <XLAT_STYLE_FMT_D>: New enumeration entity.
(printxval64_d, printxval_d): New function, a shorthand for
printxvals_ex with a single xlat and XLAT_STYLE_FMT_D xlat style.
* xlat.c (sprint_xlat_val): Handle XLAT_STYLE_FMT_D.
This commit is contained in:
Eugene Syromyatnikov 2018-04-04 13:24:54 +02:00
parent d451b0e283
commit 78be7e9d8a
2 changed files with 18 additions and 1 deletions

15
defs.h
View File

@ -587,7 +587,7 @@ extern void printaddr(kernel_ulong_t addr);
#define XLAT_STYLE_VERBOSITY_MASK (XLAT_STYLE_RAW | XLAT_STYLE_ABBREV)
#define XLAT_STYLE_FORMAT_SHIFT 2
#define XLAT_STYLE_FORMAT_MASK (1 << XLAT_STYLE_FORMAT_SHIFT)
#define XLAT_STYLE_FORMAT_MASK (3 << XLAT_STYLE_FORMAT_SHIFT)
enum xlat_style {
/**
@ -610,6 +610,7 @@ enum xlat_style {
XLAT_STYLE_FMT_X = 0 << XLAT_STYLE_FORMAT_SHIFT,
XLAT_STYLE_FMT_U = 1 << XLAT_STYLE_FORMAT_SHIFT,
XLAT_STYLE_FMT_D = 2 << XLAT_STYLE_FORMAT_SHIFT,
};
extern enum xlat_style xlat_verbosity;
@ -866,6 +867,18 @@ printxval_u(const struct xlat *x, const unsigned int val, const char *dflt)
return printxvals_ex(val, dflt, XLAT_STYLE_FMT_U, x, NULL);
}
static inline int
printxval64_d(const struct xlat *x, const int64_t val, const char *dflt)
{
return printxvals_ex(val, dflt, XLAT_STYLE_FMT_D, x, NULL);
}
static inline int
printxval_d(const struct xlat *x, const int val, const char *dflt)
{
return printxvals_ex(val, dflt, XLAT_STYLE_FMT_D, x, NULL);
}
static inline void
tprint_iov(struct tcb *tcp, kernel_ulong_t len, kernel_ulong_t addr,
enum iov_decode decode_iov)

4
xlat.c
View File

@ -51,6 +51,10 @@ sprint_xlat_val(uint64_t val, enum xlat_style style)
static char buf[sizeof(val) * 3];
switch (xlat_format(style)) {
case XLAT_STYLE_FMT_D:
xsprintf(buf, "%" PRId64, val);
break;
case XLAT_STYLE_FMT_U:
xsprintf(buf, "%" PRIu64, val);
break;