0001
0002
0003
0004 #ifndef _TEST_BTF_H
0005 #define _TEST_BTF_H
0006
0007 #define BTF_END_RAW 0xdeadbeef
0008
0009 #define BTF_INFO_ENC(kind, kind_flag, vlen) \
0010 ((!!(kind_flag) << 31) | ((kind) << 24) | ((vlen) & BTF_MAX_VLEN))
0011
0012 #define BTF_TYPE_ENC(name, info, size_or_type) \
0013 (name), (info), (size_or_type)
0014
0015 #define BTF_INT_ENC(encoding, bits_offset, nr_bits) \
0016 ((encoding) << 24 | (bits_offset) << 16 | (nr_bits))
0017 #define BTF_TYPE_INT_ENC(name, encoding, bits_offset, bits, sz) \
0018 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_INT, 0, 0), sz), \
0019 BTF_INT_ENC(encoding, bits_offset, bits)
0020
0021 #define BTF_FWD_ENC(name, kind_flag) \
0022 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_FWD, kind_flag, 0), 0)
0023
0024 #define BTF_ARRAY_ENC(type, index_type, nr_elems) \
0025 (type), (index_type), (nr_elems)
0026 #define BTF_TYPE_ARRAY_ENC(type, index_type, nr_elems) \
0027 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_ARRAY, 0, 0), 0), \
0028 BTF_ARRAY_ENC(type, index_type, nr_elems)
0029
0030 #define BTF_STRUCT_ENC(name, nr_elems, sz) \
0031 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_STRUCT, 0, nr_elems), sz)
0032
0033 #define BTF_UNION_ENC(name, nr_elems, sz) \
0034 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_UNION, 0, nr_elems), sz)
0035
0036 #define BTF_VAR_ENC(name, type, linkage) \
0037 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_VAR, 0, 0), type), (linkage)
0038 #define BTF_VAR_SECINFO_ENC(type, offset, size) \
0039 (type), (offset), (size)
0040
0041 #define BTF_MEMBER_ENC(name, type, bits_offset) \
0042 (name), (type), (bits_offset)
0043 #define BTF_ENUM_ENC(name, val) (name), (val)
0044 #define BTF_ENUM64_ENC(name, val_lo32, val_hi32) (name), (val_lo32), (val_hi32)
0045 #define BTF_MEMBER_OFFSET(bitfield_size, bits_offset) \
0046 ((bitfield_size) << 24 | (bits_offset))
0047
0048 #define BTF_TYPEDEF_ENC(name, type) \
0049 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_TYPEDEF, 0, 0), type)
0050
0051 #define BTF_PTR_ENC(type) \
0052 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), type)
0053
0054 #define BTF_CONST_ENC(type) \
0055 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), type)
0056
0057 #define BTF_VOLATILE_ENC(type) \
0058 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_VOLATILE, 0, 0), type)
0059
0060 #define BTF_RESTRICT_ENC(type) \
0061 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_RESTRICT, 0, 0), type)
0062
0063 #define BTF_FUNC_PROTO_ENC(ret_type, nargs) \
0064 BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_FUNC_PROTO, 0, nargs), ret_type)
0065
0066 #define BTF_FUNC_PROTO_ARG_ENC(name, type) \
0067 (name), (type)
0068
0069 #define BTF_FUNC_ENC(name, func_proto) \
0070 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_FUNC, 0, 0), func_proto)
0071
0072 #define BTF_TYPE_FLOAT_ENC(name, sz) \
0073 BTF_TYPE_ENC(name, BTF_INFO_ENC(BTF_KIND_FLOAT, 0, 0), sz)
0074
0075 #define BTF_DECL_TAG_ENC(value, type, component_idx) \
0076 BTF_TYPE_ENC(value, BTF_INFO_ENC(BTF_KIND_DECL_TAG, 0, 0), type), (component_idx)
0077
0078 #define BTF_TYPE_TAG_ENC(value, type) \
0079 BTF_TYPE_ENC(value, BTF_INFO_ENC(BTF_KIND_TYPE_TAG, 0, 0), type)
0080
0081 #endif