]> granicus.if.org Git - strace/blob - xlat.h
maint: update for linux v5.3-rc8
[strace] / xlat.h
1 /*
2  * Copyright (c) 2016-2018 The strace developers.
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  */
7
8 #ifndef STRACE_XLAT_H
9 # define STRACE_XLAT_H
10
11 # include <stdint.h>
12
13 enum xlat_type {
14         XT_NORMAL,
15         XT_SORTED,
16         XT_INDEXED,
17 };
18
19 enum xlat_style {
20         /**
21          * Special value that is used for passing to *print{xval,flags}*_ex
22          * routines that indicates that no overriding of user-supplied xlat
23          * verbosity/formatting configuration is intended.
24          */
25         XLAT_STYLE_DEFAULT = 0,
26
27         /** Print xlat value as is without xlat processing */
28         XLAT_STYLE_RAW     = 1 << 0,
29         /**
30          * Historic strace style, process xlat and print the result (xlat
31          * constant name/combination of flags), raw number only if nothing is
32          * found.
33          */
34         XLAT_STYLE_ABBREV  = 1 << 1,
35         /** Always print both raw number and xlat processing result. */
36         XLAT_STYLE_VERBOSE = XLAT_STYLE_RAW | XLAT_STYLE_ABBREV,
37
38 # define XLAT_STYLE_FORMAT_SHIFT   2
39 # define XLAT_STYLE_VERBOSITY_MASK ((1 << XLAT_STYLE_FORMAT_SHIFT) - 1)
40
41         XLAT_STYLE_FMT_X   = 0 << XLAT_STYLE_FORMAT_SHIFT,
42         XLAT_STYLE_FMT_U   = 1 << XLAT_STYLE_FORMAT_SHIFT,
43         XLAT_STYLE_FMT_D   = 2 << XLAT_STYLE_FORMAT_SHIFT,
44
45 # define XLAT_STYLE_FORMAT_MASK    (3 << XLAT_STYLE_FORMAT_SHIFT)
46
47 # define XLAT_STYLE_SPEC_BITS (XLAT_STYLE_FORMAT_SHIFT + 2)
48 # define XLAT_STYLE_MASK ((1 << XLAT_STYLE_SPEC_BITS) - 1)
49 };
50
51 struct xlat_data {
52         uint64_t val;
53         const char *str;
54 };
55
56 struct xlat {
57         const struct xlat_data *data;
58         uint32_t size;
59         enum xlat_type type;
60 };
61
62 # define XLAT(val)                      { (unsigned)(val), #val }
63 # define XLAT_PAIR(val, str)            { (unsigned)(val), str  }
64 # define XLAT_TYPE(type, val)           {     (type)(val), #val }
65 # define XLAT_TYPE_PAIR(type, val, str) {     (type)(val), str  }
66 # define XLAT_END                       {               0, 0    }
67
68 #endif /* !STRACE_XLAT_H */