2 * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
3 * Copyright (c) 2014-2019 The strace developers.
6 * SPDX-License-Identifier: LGPL-2.1-or-later
12 #include "xlat/ioprio_who.h"
13 #include "xlat/ioprio_class.h"
15 #define IOPRIO_CLASS_SHIFT (13)
16 #define IOPRIO_PRIO_MASK ((1ul << IOPRIO_CLASS_SHIFT) - 1)
18 #define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT)
19 #define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK)
22 sprint_ioprio(unsigned int ioprio)
24 static char outstr[256];
26 unsigned int class, data;
28 class = IOPRIO_PRIO_CLASS(ioprio);
29 data = IOPRIO_PRIO_DATA(ioprio);
30 sprintxval(class_buf, sizeof(class_buf), ioprio_class, class,
32 xsprintf(outstr, "IOPRIO_PRIO_VALUE(%s, %d)", class_buf, data);
38 print_ioprio(unsigned int ioprio)
40 if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
41 tprintf("%#x", ioprio);
43 if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
46 const char *str = sprint_ioprio(ioprio);
48 (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE
49 ? tprints_comment : tprints)(str);
56 printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???");
58 tprintf(", %d", (int) tcp->u_arg[1]);
63 if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
66 tcp->auxstr = sprint_ioprio(tcp->u_rval);
74 printxval(ioprio_who, tcp->u_arg[0], "IOPRIO_WHO_???");
76 tprintf(", %d, ", (int) tcp->u_arg[1]);
78 if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV)
79 tprintf("%d", (int) tcp->u_arg[2]);
81 if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW)
84 (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE
85 ? tprints_comment : tprints)(sprint_ioprio(tcp->u_arg[2]));