Lines Matching refs:t

288 static int btf_type_size(const struct btf_type *t)  in btf_type_size()  argument
291 __u16 vlen = btf_vlen(t); in btf_type_size()
293 switch (btf_kind(t)) { in btf_type_size()
324 pr_debug("Unsupported BTF_KIND:%u\n", btf_kind(t)); in btf_type_size()
329 static void btf_bswap_type_base(struct btf_type *t) in btf_bswap_type_base() argument
331 t->name_off = bswap_32(t->name_off); in btf_bswap_type_base()
332 t->info = bswap_32(t->info); in btf_bswap_type_base()
333 t->type = bswap_32(t->type); in btf_bswap_type_base()
336 static int btf_bswap_type_rest(struct btf_type *t) in btf_bswap_type_rest() argument
344 __u16 vlen = btf_vlen(t); in btf_bswap_type_rest()
347 switch (btf_kind(t)) { in btf_bswap_type_rest()
359 *(__u32 *)(t + 1) = bswap_32(*(__u32 *)(t + 1)); in btf_bswap_type_rest()
362 for (i = 0, e = btf_enum(t); i < vlen; i++, e++) { in btf_bswap_type_rest()
368 for (i = 0, e64 = btf_enum64(t); i < vlen; i++, e64++) { in btf_bswap_type_rest()
375 a = btf_array(t); in btf_bswap_type_rest()
382 for (i = 0, m = btf_members(t); i < vlen; i++, m++) { in btf_bswap_type_rest()
389 for (i = 0, p = btf_params(t); i < vlen; i++, p++) { in btf_bswap_type_rest()
395 btf_var(t)->linkage = bswap_32(btf_var(t)->linkage); in btf_bswap_type_rest()
398 for (i = 0, v = btf_var_secinfos(t); i < vlen; i++, v++) { in btf_bswap_type_rest()
405 btf_decl_tag(t)->component_idx = bswap_32(btf_decl_tag(t)->component_idx); in btf_bswap_type_rest()
408 pr_debug("Unsupported BTF_KIND:%u\n", btf_kind(t)); in btf_bswap_type_rest()
493 const struct btf_type *t; in determine_ptr_size() local
502 t = btf__type_by_id(btf, i); in determine_ptr_size()
503 if (!btf_is_int(t)) in determine_ptr_size()
506 if (t->size != 4 && t->size != 8) in determine_ptr_size()
509 name = btf__name_by_offset(btf, t->name_off); in determine_ptr_size()
515 return t->size; in determine_ptr_size()
592 static bool btf_type_is_void(const struct btf_type *t) in btf_type_is_void() argument
594 return t == &btf_void || btf_is_fwd(t); in btf_type_is_void()
597 static bool btf_type_is_void_or_null(const struct btf_type *t) in btf_type_is_void_or_null() argument
599 return !t || btf_type_is_void(t); in btf_type_is_void_or_null()
607 const struct btf_type *t; in btf__resolve_size() local
612 t = btf__type_by_id(btf, type_id); in btf__resolve_size()
613 for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t); i++) { in btf__resolve_size()
614 switch (btf_kind(t)) { in btf__resolve_size()
622 size = t->size; in btf__resolve_size()
634 type_id = t->type; in btf__resolve_size()
637 array = btf_array(t); in btf__resolve_size()
647 t = btf__type_by_id(btf, type_id); in btf__resolve_size()
661 const struct btf_type *t = btf__type_by_id(btf, id); in btf__align_of() local
662 __u16 kind = btf_kind(t); in btf__align_of()
669 return min(btf_ptr_sz(btf), (size_t)t->size); in btf__align_of()
677 return btf__align_of(btf, t->type); in btf__align_of()
679 return btf__align_of(btf, btf_array(t)->type); in btf__align_of()
682 const struct btf_member *m = btf_members(t); in btf__align_of()
683 __u16 vlen = btf_vlen(t); in btf__align_of()
695 if (btf_member_bitfield_size(t, i) == 0 && in btf__align_of()
703 if ((t->size % max_align) != 0) in btf__align_of()
709 pr_warn("unsupported BTF_KIND:%u\n", btf_kind(t)); in btf__align_of()
716 const struct btf_type *t; in btf__resolve_type() local
719 t = btf__type_by_id(btf, type_id); in btf__resolve_type()
721 !btf_type_is_void_or_null(t) && in btf__resolve_type()
722 (btf_is_mod(t) || btf_is_typedef(t) || btf_is_var(t))) { in btf__resolve_type()
723 type_id = t->type; in btf__resolve_type()
724 t = btf__type_by_id(btf, type_id); in btf__resolve_type()
728 if (depth == MAX_RESOLVE_DEPTH || btf_type_is_void_or_null(t)) in btf__resolve_type()
742 const struct btf_type *t = btf__type_by_id(btf, i); in btf__find_by_name() local
743 const char *name = btf__name_by_offset(btf, t->name_off); in btf__find_by_name()
761 const struct btf_type *t = btf__type_by_id(btf, i); in btf_find_by_name_kind() local
764 if (btf_kind(t) != kind) in btf_find_by_name_kind()
766 name = btf__name_by_offset(btf, t->name_off); in btf_find_by_name_kind()
1258 struct btf_type *t; in btf_get_raw_data() local
1283 t = p + btf->type_offs[i]; in btf_get_raw_data()
1288 if (btf_bswap_type_rest(t)) in btf_get_raw_data()
1290 btf_bswap_type_base(t); in btf_get_raw_data()
1546 static void btf_type_inc_vlen(struct btf_type *t) in btf_type_inc_vlen() argument
1548 t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, btf_kflag(t)); in btf_type_inc_vlen()
1606 struct btf_type *t; in btf__add_type() local
1617 t = btf_add_type_mem(btf, sz); in btf__add_type()
1618 if (!t) in btf__add_type()
1621 memcpy(t, src_type, sz); in btf__add_type()
1623 err = btf_type_visit_str_offs(t, btf_rewrite_str, &p); in btf__add_type()
1653 void *t; in btf__add_btf() local
1672 t = btf_add_type_mem(btf, data_sz); in btf__add_btf()
1673 if (!t) in btf__add_btf()
1687 memcpy(t, src_btf->types_data, data_sz); in btf__add_btf()
1690 sz = btf_type_size(t); in btf__add_btf()
1698 *off = t - btf->types_data; in btf__add_btf()
1701 err = btf_type_visit_str_offs(t, btf_rewrite_str, &p); in btf__add_btf()
1706 err = btf_type_visit_type_ids(t, btf_rewrite_type_ids, btf); in btf__add_btf()
1711 t += sz; in btf__add_btf()
1759 struct btf_type *t; in btf__add_int() local
1776 t = btf_add_type_mem(btf, sz); in btf__add_int()
1777 if (!t) in btf__add_int()
1788 t->name_off = name_off; in btf__add_int()
1789 t->info = btf_type_info(BTF_KIND_INT, 0, 0); in btf__add_int()
1790 t->size = byte_sz; in btf__add_int()
1792 *(__u32 *)(t + 1) = (encoding << 24) | (byte_sz * 8); in btf__add_int()
1807 struct btf_type *t; in btf__add_float() local
1823 t = btf_add_type_mem(btf, sz); in btf__add_float()
1824 if (!t) in btf__add_float()
1831 t->name_off = name_off; in btf__add_float()
1832 t->info = btf_type_info(BTF_KIND_FLOAT, 0, 0); in btf__add_float()
1833 t->size = byte_sz; in btf__add_float()
1852 struct btf_type *t; in btf_add_ref_kind() local
1862 t = btf_add_type_mem(btf, sz); in btf_add_ref_kind()
1863 if (!t) in btf_add_ref_kind()
1872 t->name_off = name_off; in btf_add_ref_kind()
1873 t->info = btf_type_info(kind, 0, 0); in btf_add_ref_kind()
1874 t->type = ref_type_id; in btf_add_ref_kind()
1902 struct btf_type *t; in btf__add_array() local
1913 t = btf_add_type_mem(btf, sz); in btf__add_array()
1914 if (!t) in btf__add_array()
1917 t->name_off = 0; in btf__add_array()
1918 t->info = btf_type_info(BTF_KIND_ARRAY, 0, 0); in btf__add_array()
1919 t->size = 0; in btf__add_array()
1921 a = btf_array(t); in btf__add_array()
1932 struct btf_type *t; in btf_add_composite() local
1939 t = btf_add_type_mem(btf, sz); in btf_add_composite()
1940 if (!t) in btf_add_composite()
1952 t->name_off = name_off; in btf_add_composite()
1953 t->info = btf_type_info(kind, 0, 0); in btf_add_composite()
1954 t->size = bytes_sz; in btf_add_composite()
2012 struct btf_type *t; in btf__add_field() local
2020 t = btf_last_type(btf); in btf__add_field()
2021 if (!btf_is_composite(t)) in btf__add_field()
2032 if (btf_is_union(t) && bit_offset) in btf__add_field()
2055 t = btf_last_type(btf); in btf__add_field()
2057 t->info = btf_type_info(btf_kind(t), btf_vlen(t) + 1, is_bitfield || btf_kflag(t)); in btf__add_field()
2067 struct btf_type *t; in btf_add_enum_common() local
2078 t = btf_add_type_mem(btf, sz); in btf_add_enum_common()
2079 if (!t) in btf_add_enum_common()
2089 t->name_off = name_off; in btf_add_enum_common()
2090 t->info = btf_type_info(kind, 0, is_signed); in btf_add_enum_common()
2091 t->size = byte_sz; in btf_add_enum_common()
2128 struct btf_type *t; in btf__add_enum_value() local
2135 t = btf_last_type(btf); in btf__add_enum_value()
2136 if (!btf_is_enum(t)) in btf__add_enum_value()
2162 t = btf_last_type(btf); in btf__add_enum_value()
2163 btf_type_inc_vlen(t); in btf__add_enum_value()
2167 t->info = btf_type_info(btf_kind(t), btf_vlen(t), true); in btf__add_enum_value()
2206 struct btf_type *t; in btf__add_enum64_value() local
2212 t = btf_last_type(btf); in btf__add_enum64_value()
2213 if (!btf_is_enum64(t)) in btf__add_enum64_value()
2238 t = btf_last_type(btf); in btf__add_enum64_value()
2239 btf_type_inc_vlen(t); in btf__add_enum64_value()
2263 struct btf_type *t; in btf__add_fwd() local
2269 t = btf_type_by_id(btf, id); in btf__add_fwd()
2270 t->info = btf_type_info(BTF_KIND_FWD, 0, fwd_kind == BTF_FWD_UNION); in btf__add_fwd()
2372 struct btf_type *t = btf_type_by_id(btf, id); in btf__add_func() local
2374 t->info = btf_type_info(BTF_KIND_FUNC, linkage, 0); in btf__add_func()
2393 struct btf_type *t; in btf__add_func_proto() local
2403 t = btf_add_type_mem(btf, sz); in btf__add_func_proto()
2404 if (!t) in btf__add_func_proto()
2410 t->name_off = 0; in btf__add_func_proto()
2411 t->info = btf_type_info(BTF_KIND_FUNC_PROTO, 0, 0); in btf__add_func_proto()
2412 t->type = ret_type_id; in btf__add_func_proto()
2427 struct btf_type *t; in btf__add_func_param() local
2437 t = btf_last_type(btf); in btf__add_func_param()
2438 if (!btf_is_func_proto(t)) in btf__add_func_param()
2460 t = btf_last_type(btf); in btf__add_func_param()
2461 btf_type_inc_vlen(t); in btf__add_func_param()
2480 struct btf_type *t; in btf__add_var() local
2498 t = btf_add_type_mem(btf, sz); in btf__add_var()
2499 if (!t) in btf__add_var()
2506 t->name_off = name_off; in btf__add_var()
2507 t->info = btf_type_info(BTF_KIND_VAR, 0, 0); in btf__add_var()
2508 t->type = type_id; in btf__add_var()
2510 v = btf_var(t); in btf__add_var()
2530 struct btf_type *t; in btf__add_datasec() local
2541 t = btf_add_type_mem(btf, sz); in btf__add_datasec()
2542 if (!t) in btf__add_datasec()
2550 t->name_off = name_off; in btf__add_datasec()
2551 t->info = btf_type_info(BTF_KIND_DATASEC, 0, 0); in btf__add_datasec()
2552 t->size = byte_sz; in btf__add_datasec()
2569 struct btf_type *t; in btf__add_datasec_var_info() local
2576 t = btf_last_type(btf); in btf__add_datasec_var_info()
2577 if (!btf_is_datasec(t)) in btf__add_datasec_var_info()
2597 t = btf_last_type(btf); in btf__add_datasec_var_info()
2598 btf_type_inc_vlen(t); in btf__add_datasec_var_info()
2618 struct btf_type *t; in btf__add_decl_tag() local
2631 t = btf_add_type_mem(btf, sz); in btf__add_decl_tag()
2632 if (!t) in btf__add_decl_tag()
2639 t->name_off = value_off; in btf__add_decl_tag()
2640 t->info = btf_type_info(BTF_KIND_DECL_TAG, 0, false); in btf__add_decl_tag()
2641 t->type = ref_type_id; in btf__add_decl_tag()
2642 btf_decl_tag(t)->component_idx = component_idx; in btf__add_decl_tag()
3246 struct btf_type *t = btf_type_by_id(d->btf, i); in btf_dedup_new() local
3249 if (btf_is_var(t) || btf_is_datasec(t)) in btf_dedup_new()
3281 struct btf_type *t = btf_type_by_id(d->btf, d->btf->start_id + i); in btf_for_each_str_off() local
3283 r = btf_type_visit_str_offs(t, fn, ctx); in btf_for_each_str_off()
3381 static long btf_hash_common(struct btf_type *t) in btf_hash_common() argument
3385 h = hash_combine(0, t->name_off); in btf_hash_common()
3386 h = hash_combine(h, t->info); in btf_hash_common()
3387 h = hash_combine(h, t->size); in btf_hash_common()
3399 static long btf_hash_int_decl_tag(struct btf_type *t) in btf_hash_int_decl_tag() argument
3401 __u32 info = *(__u32 *)(t + 1); in btf_hash_int_decl_tag()
3404 h = btf_hash_common(t); in btf_hash_int_decl_tag()
3422 static long btf_hash_enum(struct btf_type *t) in btf_hash_enum() argument
3427 h = hash_combine(0, t->name_off); in btf_hash_enum()
3481 static inline bool btf_is_enum_fwd(struct btf_type *t) in btf_is_enum_fwd() argument
3483 return btf_is_any_enum(t) && btf_vlen(t) == 0; in btf_is_enum_fwd()
3505 static long btf_hash_struct(struct btf_type *t) in btf_hash_struct() argument
3507 const struct btf_member *member = btf_members(t); in btf_hash_struct()
3508 __u32 vlen = btf_vlen(t); in btf_hash_struct()
3509 long h = btf_hash_common(t); in btf_hash_struct()
3552 static long btf_hash_array(struct btf_type *t) in btf_hash_array() argument
3554 const struct btf_array *info = btf_array(t); in btf_hash_array()
3555 long h = btf_hash_common(t); in btf_hash_array()
3602 static long btf_hash_fnproto(struct btf_type *t) in btf_hash_fnproto() argument
3604 const struct btf_param *member = btf_params(t); in btf_hash_fnproto()
3605 __u16 vlen = btf_vlen(t); in btf_hash_fnproto()
3606 long h = btf_hash_common(t); in btf_hash_fnproto()
3678 struct btf_type *t; in btf_dedup_prep() local
3686 t = btf_type_by_id(d->btf, type_id); in btf_dedup_prep()
3691 switch (btf_kind(t)) { in btf_dedup_prep()
3705 h = btf_hash_common(t); in btf_dedup_prep()
3709 h = btf_hash_int_decl_tag(t); in btf_dedup_prep()
3713 h = btf_hash_enum(t); in btf_dedup_prep()
3717 h = btf_hash_struct(t); in btf_dedup_prep()
3720 h = btf_hash_array(t); in btf_dedup_prep()
3723 h = btf_hash_fnproto(t); in btf_dedup_prep()
3726 pr_debug("unknown kind %d for type [%d]\n", btf_kind(t), type_id); in btf_dedup_prep()
3744 struct btf_type *t = btf_type_by_id(d->btf, type_id); in btf_dedup_prim_type() local
3752 switch (btf_kind(t)) { in btf_dedup_prim_type()
3770 h = btf_hash_int_decl_tag(t); in btf_dedup_prim_type()
3774 if (btf_equal_int_tag(t, cand)) { in btf_dedup_prim_type()
3783 h = btf_hash_enum(t); in btf_dedup_prim_type()
3787 if (btf_equal_enum(t, cand)) { in btf_dedup_prim_type()
3791 if (btf_compat_enum(t, cand)) { in btf_dedup_prim_type()
3792 if (btf_is_enum_fwd(t)) { in btf_dedup_prim_type()
3805 h = btf_hash_common(t); in btf_dedup_prim_type()
3809 if (btf_equal_common(t, cand)) { in btf_dedup_prim_type()
3880 static inline __u16 btf_fwd_kind(struct btf_type *t) in btf_fwd_kind() argument
3882 return btf_kflag(t) ? BTF_KIND_UNION : BTF_KIND_STRUCT; in btf_fwd_kind()
4291 struct btf_type *cand_type, *t; in btf_dedup_struct_type() local
4302 t = btf_type_by_id(d->btf, type_id); in btf_dedup_struct_type()
4303 kind = btf_kind(t); in btf_dedup_struct_type()
4308 h = btf_hash_struct(t); in btf_dedup_struct_type()
4324 if (!btf_shallow_equal_struct(t, cand_type)) in btf_dedup_struct_type()
4387 struct btf_type *t, *cand; in btf_dedup_ref_type() local
4397 t = btf_type_by_id(d->btf, type_id); in btf_dedup_ref_type()
4400 switch (btf_kind(t)) { in btf_dedup_ref_type()
4408 ref_type_id = btf_dedup_ref_type(d, t->type); in btf_dedup_ref_type()
4411 t->type = ref_type_id; in btf_dedup_ref_type()
4413 h = btf_hash_common(t); in btf_dedup_ref_type()
4417 if (btf_equal_common(t, cand)) { in btf_dedup_ref_type()
4425 ref_type_id = btf_dedup_ref_type(d, t->type); in btf_dedup_ref_type()
4428 t->type = ref_type_id; in btf_dedup_ref_type()
4430 h = btf_hash_int_decl_tag(t); in btf_dedup_ref_type()
4434 if (btf_equal_int_tag(t, cand)) { in btf_dedup_ref_type()
4442 struct btf_array *info = btf_array(t); in btf_dedup_ref_type()
4454 h = btf_hash_array(t); in btf_dedup_ref_type()
4458 if (btf_equal_array(t, cand)) { in btf_dedup_ref_type()
4471 ref_type_id = btf_dedup_ref_type(d, t->type); in btf_dedup_ref_type()
4474 t->type = ref_type_id; in btf_dedup_ref_type()
4476 vlen = btf_vlen(t); in btf_dedup_ref_type()
4477 param = btf_params(t); in btf_dedup_ref_type()
4486 h = btf_hash_fnproto(t); in btf_dedup_ref_type()
4490 if (btf_equal_fnproto(t, cand)) { in btf_dedup_ref_type()
4532 struct btf_type *t; in btf_dedup_fill_unique_names_map() local
4542 t = btf_type_by_id(d->btf, type_id); in btf_dedup_fill_unique_names_map()
4543 kind = btf_kind(t); in btf_dedup_fill_unique_names_map()
4552 err = hashmap__add(names_map, t->name_off, type_id); in btf_dedup_fill_unique_names_map()
4554 err = hashmap__set(names_map, t->name_off, 0, NULL, NULL); in btf_dedup_fill_unique_names_map()
4565 struct btf_type *t = btf_type_by_id(d->btf, type_id); in btf_dedup_resolve_fwd() local
4566 enum btf_fwd_kind fwd_kind = btf_kflag(t); in btf_dedup_resolve_fwd()
4567 __u16 cand_kind, kind = btf_kind(t); in btf_dedup_resolve_fwd()
4578 if (!hashmap__find(names_map, t->name_off, &cand_id)) in btf_dedup_resolve_fwd()
4667 const struct btf_type *t; in btf_dedup_compact_types() local
4685 t = btf__type_by_id(d->btf, id); in btf_dedup_compact_types()
4686 len = btf_type_size(t); in btf_dedup_compact_types()
4690 memmove(p, t, len); in btf_dedup_compact_types()
4746 struct btf_type *t = btf_type_by_id(d->btf, d->btf->start_id + i); in btf_dedup_remap_types() local
4748 r = btf_type_visit_type_ids(t, btf_dedup_remap_type_id, d); in btf_dedup_remap_types()
4817 int btf_type_visit_type_ids(struct btf_type *t, type_id_visit_fn visit, void *ctx) in btf_type_visit_type_ids() argument
4821 switch (btf_kind(t)) { in btf_type_visit_type_ids()
4838 return visit(&t->type, ctx); in btf_type_visit_type_ids()
4841 struct btf_array *a = btf_array(t); in btf_type_visit_type_ids()
4850 struct btf_member *m = btf_members(t); in btf_type_visit_type_ids()
4852 for (i = 0, n = btf_vlen(t); i < n; i++, m++) { in btf_type_visit_type_ids()
4861 struct btf_param *m = btf_params(t); in btf_type_visit_type_ids()
4863 err = visit(&t->type, ctx); in btf_type_visit_type_ids()
4866 for (i = 0, n = btf_vlen(t); i < n; i++, m++) { in btf_type_visit_type_ids()
4875 struct btf_var_secinfo *m = btf_var_secinfos(t); in btf_type_visit_type_ids()
4877 for (i = 0, n = btf_vlen(t); i < n; i++, m++) { in btf_type_visit_type_ids()
4890 int btf_type_visit_str_offs(struct btf_type *t, str_off_visit_fn visit, void *ctx) in btf_type_visit_str_offs() argument
4894 err = visit(&t->name_off, ctx); in btf_type_visit_str_offs()
4898 switch (btf_kind(t)) { in btf_type_visit_str_offs()
4901 struct btf_member *m = btf_members(t); in btf_type_visit_str_offs()
4903 for (i = 0, n = btf_vlen(t); i < n; i++, m++) { in btf_type_visit_str_offs()
4911 struct btf_enum *m = btf_enum(t); in btf_type_visit_str_offs()
4913 for (i = 0, n = btf_vlen(t); i < n; i++, m++) { in btf_type_visit_str_offs()
4921 struct btf_enum64 *m = btf_enum64(t); in btf_type_visit_str_offs()
4923 for (i = 0, n = btf_vlen(t); i < n; i++, m++) { in btf_type_visit_str_offs()
4931 struct btf_param *m = btf_params(t); in btf_type_visit_str_offs()
4933 for (i = 0, n = btf_vlen(t); i < n; i++, m++) { in btf_type_visit_str_offs()