1 #ifndef STRACE_XLAT_H
2 #define STRACE_XLAT_H
3 
4 # include <stdint.h>
5 
6 enum xlat_type {
7 	XT_NORMAL,
8 	XT_SORTED,
9 	XT_INDEXED,
10 };
11 
12 enum xlat_style {
13 	/**
14 	 * Special value that is used for passing to *print{xval,flags}*_ex
15 	 * routines that indicates that no overriding of user-supplied xlat
16 	 * verbosity/formatting configuration is intended.
17 	 */
18 	XLAT_STYLE_DEFAULT = 0,
19 
20 	/** Print xlat value as is without xlat processing */
21 	XLAT_STYLE_RAW     = 1 << 0,
22 	/**
23 	 * Historic strace style, process xlat and print the result (xlat
24 	 * constant name/combination of flags), raw number only if nothing is
25 	 * found.
26 	 */
27 	XLAT_STYLE_ABBREV  = 1 << 1,
28 	/** Always print both raw number and xlat processing result. */
29 	XLAT_STYLE_VERBOSE = XLAT_STYLE_RAW | XLAT_STYLE_ABBREV,
30 
31 #define XLAT_STYLE_FORMAT_SHIFT   2
32 #define XLAT_STYLE_VERBOSITY_MASK ((1 << XLAT_STYLE_FORMAT_SHIFT) - 1)
33 
34 	XLAT_STYLE_FMT_X   = 0 << XLAT_STYLE_FORMAT_SHIFT,
35 	XLAT_STYLE_FMT_U   = 1 << XLAT_STYLE_FORMAT_SHIFT,
36 	XLAT_STYLE_FMT_D   = 2 << XLAT_STYLE_FORMAT_SHIFT,
37 
38 #define XLAT_STYLE_FORMAT_MASK    (3 << XLAT_STYLE_FORMAT_SHIFT)
39 
40 #define XLAT_STYLE_SPEC_BITS (XLAT_STYLE_FORMAT_SHIFT + 2)
41 #define XLAT_STYLE_MASK ((1 << XLAT_STYLE_SPEC_BITS) - 1)
42 };
43 
44 struct xlat {
45 	uint64_t val;
46 	const char *str;
47 };
48 
49 # define XLAT(val)			{ (unsigned)(val), #val }
50 # define XLAT_PAIR(val, str)		{ (unsigned)(val), str  }
51 # define XLAT_TYPE(type, val)		{     (type)(val), #val }
52 # define XLAT_TYPE_PAIR(type, val, str)	{     (type)(val), str  }
53 # define XLAT_END			{		0, 0    }
54 
55 #endif /* !STRACE_XLAT_H */
56