btf_encoder: Move add_enum() from btf_elf to btf encode_enum()

As it is all that it needs, rename from the __add_ pattern to __encode
to avoid a clash with libbpf btf__add_array() API.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-06-02 17:28:01 -03:00
parent f82bd80a5c
commit 188f25b741
3 changed files with 7 additions and 8 deletions

View File

@ -206,18 +206,19 @@ static uint32_t array_type__nelems(struct tag *tag)
static int32_t enumeration_type__encode(struct btf_elf *btfe, struct cu *cu, struct tag *tag)
{
struct type *etype = tag__type(tag);
struct btf *btf = btfe->btf;
struct enumerator *pos;
const char *name;
int32_t type_id;
name = dwarves__active_loader->strings__ptr(cu, etype->namespace.name);
type_id = btf_elf__add_enum(btfe, name, etype->size);
type_id = btf__encode_enum(btf, name, etype->size);
if (type_id < 0)
return type_id;
type__for_each_enumerator(etype, pos) {
name = dwarves__active_loader->strings__ptr(cu, pos->name);
if (btf_elf__add_enum_val(btfe, name, pos->value))
if (btf__encode_enum_val(btf, name, pos->value))
return -1;
}

View File

@ -521,9 +521,8 @@ int32_t btf__encode_struct(struct btf *btf, uint8_t kind, const char *name, uint
return id;
}
int32_t btf_elf__add_enum(struct btf_elf *btfe, const char *name, uint32_t bit_size)
int32_t btf__encode_enum(struct btf *btf, const char *name, uint32_t bit_size)
{
struct btf *btf = btfe->btf;
const struct btf_type *t;
int32_t id, size;
@ -539,9 +538,8 @@ int32_t btf_elf__add_enum(struct btf_elf *btfe, const char *name, uint32_t bit_s
return id;
}
int btf_elf__add_enum_val(struct btf_elf *btfe, const char *name, int32_t value)
int btf__encode_enum_val(struct btf *btf, const char *name, int32_t value)
{
struct btf *btf = btfe->btf;
int err;
err = btf__add_enum_value(btf, name, value);

View File

@ -45,8 +45,8 @@ int32_t btf__encode_ref_type(struct btf *btf, uint16_t kind, uint32_t type, cons
int btf__encode_member(struct btf *btf, const char *name, uint32_t type, uint32_t bitfield_size, uint32_t bit_offset);
int32_t btf__encode_struct(struct btf *btf, uint8_t kind, const char *name, uint32_t size);
int32_t btf__encode_array(struct btf *btf, uint32_t type, uint32_t index_type, uint32_t nelems);
int32_t btf_elf__add_enum(struct btf_elf *btf, const char *name, uint32_t size);
int btf_elf__add_enum_val(struct btf_elf *btf, const char *name, int32_t value);
int32_t btf__encode_enum(struct btf *btf, const char *name, uint32_t size);
int btf__encode_enum_val(struct btf *btf, const char *name, int32_t value);
int32_t btf_elf__add_func_proto(struct btf_elf *btf, struct cu *cu, struct ftype *ftype,
uint32_t type_id_off);
int32_t btf_elf__add_var_type(struct btf_elf *btfe, uint32_t type, const char *name,