Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/leds/uledmon.c
int main(int argc, char const *argv[]) { struct uleds_user_dev uleds_dev; int fd, ret; int brightness; struct timespec ts; if (argc != 2) { fprintf(stderr, "Requires <device-name> argument\n"); return 1; } strncpy(uleds_dev.name, argv[1], LED_MAX_NAME_SIZE); uleds_dev.max_brightness = 100; ...
[ 1, 0 ]
Linux Kernel
tools/lib/api/debug.c
static int __base_pr(const char *format, ...) { va_list args; int err; va_start(args, format); err = vfprintf(stderr, format, args); va_end(args); return err; }
[ 0, 0 ]
Linux Kernel
tools/lib/api/fd/array.c
int fdarray__grow(struct fdarray *fda, int nr) { struct priv *priv; int nr_alloc = fda->nr_alloc + nr; size_t psize = sizeof(fda->priv[0]) * nr_alloc; size_t size = sizeof(struct pollfd) * nr_alloc; struct pollfd *entries = realloc(fda->entries, size); if (entries == NULL) return -ENOMEM; priv = re...
[ 1, 0 ]
Linux Kernel
tools/lib/api/fd/array.c
int fdarray__dup_entry_from(struct fdarray *fda, int pos, struct fdarray *from) { struct pollfd *entry; int npos; if (pos >= from->nr) return -EINVAL; entry = &from->entries[pos]; npos = fdarray__add(fda, entry->fd, entry->events, from->priv[pos].flags); if (npos >= 0) ...
[ 0, 0 ]
Linux Kernel
tools/lib/api/fd/array.c
int fdarray__poll(struct fdarray *fda, int timeout) { return poll(fda->entries, fda->nr, timeout); }
[ 0, 0 ]
Linux Kernel
tools/lib/api/fs/cgroup.c
int cgroupfs_find_mountpoint(char *buf, size_t maxlen, const char *subsys) { FILE *fp; char *line = NULL; size_t len = 0; char *p, *path; char mountpoint[PATH_MAX]; if (!strcmp(cached.subsys, subsys)) { if (strlen(cached.mountpoint) < maxlen) { strcpy(buf, cached.mountpoint); return 0; ...
[ 1, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
static const char *mount_overload(struct fs *fs) { size_t name_len = strlen(fs->name); char upper_name[5 + name_len + 12 + 1]; snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name); mem_toupper(upper_name, name_len); return getenv(upper_name) ?: *fs->mounts; }
[ 0, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
static const char *fs__mount(int idx) { struct fs *fs = &fs__entries[idx]; const char *mountpoint; if (fs__mountpoint(idx)) return (const char *)fs->path; mountpoint = mount_overload(fs); if (mount(NULL, mountpoint, fs->name, 0, NULL) < 0) return NULL; return fs__check_mounts(fs) ? fs->path : N...
[ 0, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
int filename__read_int(const char *filename, int *value) { char line[64]; int fd = open(filename, O_RDONLY), err = -1; if (fd < 0) return -1; if (read(fd, line, sizeof(line)) > 0) { *value = atoi(line); err = 0; } close(fd); return err; }
[ 1, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
static int filename__read_ull_base(const char *filename, unsigned long long *value, int base) { char line[64]; int fd = open(filename, O_RDONLY), err = -1; if (fd < 0) return -1; if (read(fd, line, sizeof(line)) > 0) { *value = strtoull(line, NULL, base); if (*v...
[ 1, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
int filename__read_ull(const char *filename, unsigned long long *value) { return filename__read_ull_base(filename, value, 0); }
[ 0, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
int sysfs__read_str(const char *entry, char **buf, size_t *sizep) { char path[PATH_MAX]; const char *sysfs = sysfs__mountpoint(); if (!sysfs) return -1; snprintf(path, sizeof(path), "%s/%s", sysfs, entry); return filename__read_str(path, buf, sizep); }
[ 1, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
int sysfs__read_bool(const char *entry, bool *value) { char *buf; size_t size; int ret; ret = sysfs__read_str(entry, &buf, &size); if (ret < 0) return ret; switch (buf[0]) { case '1': case 'y': case 'Y': *value = true; break; case '0': case 'n': case 'N': *value = false; b...
[ 1, 0 ]
Linux Kernel
tools/lib/api/fs/fs.c
int sysctl__read_int(const char *sysctl, int *value) { char path[PATH_MAX]; const char *procfs = procfs__mountpoint(); if (!procfs) return -1; snprintf(path, sizeof(path), "%s/sys/%s", procfs, sysctl); return filename__read_int(path, value); }
[ 1, 0 ]
Linux Kernel
tools/lib/api/io.h
static inline int io__get_char(struct io *io) { char *ptr = io->data; if (io->eof) return -1; if (ptr == io->end) { ssize_t n = read(io->fd, io->buf, io->buf_len); if (n <= 0) { io->eof = true; return -1; } ptr = &io->buf[0]; io->end = &io->buf[n]; } io->data = ptr + 1; ...
[ 0, 0 ]
Linux Kernel
tools/lib/api/io.h
static inline int io__get_dec(struct io *io, __u64 *dec) { bool first_read = true; *dec = 0; while (true) { int ch = io__get_char(io); if (ch < 0) return ch; if (ch >= '0' && ch <= '9') *dec = (*dec * 10) + ch - '0'; else if (first_read) return -2; else return ch; ...
[ 0, 0 ]
Linux Kernel
tools/lib/argv_split.c
char **argv_split(const char *str, int *argcp) { int argc = count_argc(str); char **argv = calloc(argc + 1, sizeof(*argv)); char **argvp; if (argv == NULL) goto out; if (argcp) *argcp = argc; argvp = argv; while (*str) { str = skip_spaces(str); if (*str) { const char *p = str; ...
[ 1, 0 ]
Linux Kernel
tools/lib/bitmap.c
bool __bitmap_equal(const unsigned long *bitmap1, const unsigned long *bitmap2, unsigned int bits) { unsigned int k, lim = bits / BITS_PER_LONG; for (k = 0; k < lim; ++k) if (bitmap1[k] != bitmap2[k]) return false; if (bits % BITS_PER_LONG) if ((bitmap1[k] ^ bitmap2[k]) & BITMA...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
static inline int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, unsigned int size) { return syscall(__NR_bpf, cmd, attr, size); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int probe_memcg_account(void) { const size_t attr_sz = offsetofend(union bpf_attr, attach_btf_obj_fd); struct bpf_insn insns[] = { BPF_EMIT_CALL(BPF_FUNC_ktime_get_coarse_ns), BPF_EXIT_INSN(), }; size_t insn_cnt = ARRAY_SIZE(insns); union bpf_attr attr; int prog_fd; memset(&attr, 0, attr_sz);...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bump_rlimit_memlock(void) { struct rlimit rlim; if (memlock_bumped || kernel_supports(NULL, FEAT_MEMCG_ACCOUNT)) return 0; memlock_bumped = true; /* zero memlock_rlim_max disables auto-bumping RLIMIT_MEMLOCK */ if (memlock_rlim == 0) return 0; rlim.rlim_cur = rlim.rlim_max = memlock_rlim; ...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_map_update_elem(int fd, const void *key, const void *value, __u64 flags) { const size_t attr_sz = offsetofend(union bpf_attr, flags); union bpf_attr attr; int ret; memset(&attr, 0, attr_sz); attr.map_fd = fd; attr.key = ptr_to_u64(key); attr.value = ptr_to_u64(value); a...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_map_lookup_and_delete_elem_flags(int fd, const void *key, void *value, __u64 flags) { const size_t attr_sz = offsetofend(union bpf_attr, flags); union bpf_attr attr; int ret; memset(&attr, 0, attr_sz); attr.map_fd = fd; attr.key = ptr_to_u64(key); attr.va...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_map_get_next_key(int fd, const void *key, void *next_key) { const size_t attr_sz = offsetofend(union bpf_attr, next_key); union bpf_attr attr; int ret; memset(&attr, 0, attr_sz); attr.map_fd = fd; attr.key = ptr_to_u64(key); attr.next_key = ptr_to_u64(next_key); ret = sys_bpf(BPF_MAP_GET_NEXT...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
static int bpf_map_batch_common(int cmd, int fd, void *in_batch, void *out_batch, void *keys, void *values, __u32 *count, const struct bpf_map_batch_opts *opts) { const size_t attr_sz = offsetofend(union bpf_attr, batch);...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_obj_pin(int fd, const char *pathname) { const size_t attr_sz = offsetofend(union bpf_attr, file_flags); union bpf_attr attr; int ret; memset(&attr, 0, attr_sz); attr.pathname = ptr_to_u64((void *)pathname); attr.bpf_fd = fd; ret = sys_bpf(BPF_OBJ_PIN, &attr, attr_sz); return libbpf_err_errno(...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_obj_get(const char *pathname) { return bpf_obj_get_opts(pathname, NULL); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
static int bpf_obj_get_next_id(__u32 start_id, __u32 *next_id, int cmd) { const size_t attr_sz = offsetofend(union bpf_attr, open_flags); union bpf_attr attr; int err; memset(&attr, 0, attr_sz); attr.start_id = start_id; err = sys_bpf(cmd, &attr, attr_sz); if (!err) *next_id = attr.next_id; retu...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id) { return bpf_obj_get_next_id(start_id, next_id, BPF_PROG_GET_NEXT_ID); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_btf_get_fd_by_id(__u32 id) { return bpf_btf_get_fd_by_id_opts(id, NULL); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_link_get_fd_by_id_opts(__u32 id, const struct bpf_get_fd_by_id_opts *opts) { const size_t attr_sz = offsetofend(union bpf_attr, open_flags); union bpf_attr attr; int fd; if (!OPTS_VALID(opts, bpf_get_fd_by_id_opts)) return libbpf_err(-EINVAL); memset(&attr, 0, att...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len) { const size_t attr_sz = offsetofend(union bpf_attr, info); union bpf_attr attr; int err; memset(&attr, 0, attr_sz); attr.info.bpf_fd = bpf_fd; attr.info.info_len = *info_len; attr.info.info = ptr_to_u64(info); err = sys_bpf(BPF_OBJ_...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_raw_tracepoint_open(const char *name, int prog_fd) { const size_t attr_sz = offsetofend(union bpf_attr, raw_tracepoint); union bpf_attr attr; int fd; memset(&attr, 0, attr_sz); attr.raw_tracepoint.name = ptr_to_u64(name); attr.raw_tracepoint.prog_fd = prog_fd; fd = sys_bpf_fd(BPF_RAW_TRACEPOINT...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf.c
int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf, __u32 *buf_len, __u32 *prog_id, __u32 *fd_type, __u64 *probe_offset, __u64 *probe_addr) { const size_t attr_sz = offsetofend(union bpf_attr, task_fd_query); union bpf_attr attr; int err; memset(&attr, 0,...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/bpf_helpers.h
static __always_inline void bpf_tail_call_static(void *ctx, const void *map, const __u32 slot) { if (!__builtin_constant_p(slot)) __bpf_unreachable(); asm volatile("r1 = %[ctx]\n\t" "r2 = %[map]\n\t" "r3 = %[slot]\n\t" ...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/bpf_prog_linfo.c
const struct bpf_line_info * bpf_prog_linfo__lfind(const struct bpf_prog_linfo *prog_linfo, __u32 insn_off, __u32 nr_skip) { const struct bpf_line_info *linfo; __u32 rec_size, nr_linfo, i; const void *raw_linfo; nr_linfo = prog_linfo->nr_linfo; if (nr_skip >= nr_linfo) return errno...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static bool is_host_big_endian(void) { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ return false; #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ return true; #else #error "Unrecognized __BYTE_ORDER__" #endif }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
enum btf_endianness btf__endianness(const struct btf *btf) { if (is_host_big_endian()) return btf->swapped_endian ? BTF_LITTLE_ENDIAN : BTF_BIG_ENDIAN; else return btf->swapped_endian ? BTF_BIG_ENDIAN : BTF_LITTLE_ENDIAN; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__set_endianness(struct btf *btf, enum btf_endianness endian) { if (endian != BTF_LITTLE_ENDIAN && endian != BTF_BIG_ENDIAN) return libbpf_err(-EINVAL); btf->swapped_endian = is_host_big_endian() != (endian == BTF_BIG_ENDIAN); if (!btf->swapped_endian) { free(btf->raw_data_swapped); btf->raw_...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
__s64 btf__resolve_size(const struct btf *btf, __u32 type_id) { const struct btf_array *array; const struct btf_type *t; __u32 nelems = 1; __s64 size = -1; int i; t = btf__type_by_id(btf, type_id); for (i = 0; i < MAX_RESOLVE_DEPTH && !btf_type_is_void_or_null(t); i++) { switch (btf_kind(t)) { c...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
__s32 btf__find_by_name_kind_own(const struct btf *btf, const char *type_name, __u32 kind) { return btf_find_by_name_kind(btf, btf->start_id, type_name, kind); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
void btf__free(struct btf *btf) { if (IS_ERR_OR_NULL(btf)) return; if (btf->fd >= 0) close(btf->fd); if (btf_is_modifiable(btf)) { free(btf->hdr); free(btf->types_data); strset__free(btf->strs_set); } free(btf->raw_data); free(btf->raw_data_swapped); free(btf->type_offs); free(btf...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf *btf__new_empty_split(struct btf *base_btf) { return libbpf_ptr(btf_new_empty(base_btf)); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static struct btf *btf_new(const void *data, __u32 size, struct btf *base_btf) { struct btf *btf; int err; btf = calloc(1, sizeof(struct btf)); if (!btf) return ERR_PTR(-ENOMEM); btf->nr_types = 0; btf->start_id = 1; btf->start_str_off = 0; btf->fd = -1; if (base_btf) { btf->base_btf = bas...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf *btf__new(const void *data, __u32 size) { return libbpf_ptr(btf_new(data, size, NULL)); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext) { return libbpf_ptr(btf_parse_elf(path, NULL, btf_ext)); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf *btf__parse(const char *path, struct btf_ext **btf_ext) { return libbpf_ptr(btf_parse(path, NULL, btf_ext)); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
const void *btf__raw_data(const struct btf *btf_ro, __u32 *size) { struct btf *btf = (struct btf *)btf_ro; __u32 data_sz; void *data; data = btf_get_raw_data(btf, &data_sz, btf->swapped_endian); if (!data) return errno = ENOMEM, NULL; btf->raw_size = data_sz; if (btf->swapped_endian) btf->raw_d...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf *btf_get_from_fd(int btf_fd, struct btf *base_btf) { struct bpf_btf_info btf_info; __u32 len = sizeof(btf_info); __u32 last_size; struct btf *btf; void *ptr; int err; last_size = 4096; ptr = malloc(last_size); if (!ptr) return ERR_PTR(-ENOMEM); memset(&btf_info, 0, sizeof(btf_info))...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf *btf__load_from_kernel_by_id(__u32 id) { return btf__load_from_kernel_by_id_split(id, NULL); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static void btf_invalidate_raw_data(struct btf *btf) { if (btf->raw_data) { free(btf->raw_data); btf->raw_data = NULL; } if (btf->raw_data_swapped) { free(btf->raw_data_swapped); btf->raw_data_swapped = NULL; } }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static int btf_ensure_modifiable(struct btf *btf) { void *hdr, *types; struct strset *set = NULL; int err = -ENOMEM; if (btf_is_modifiable(btf)) { btf_invalidate_raw_data(btf); return 0; } /* split raw data into three memory regions */ hdr = malloc(btf->hdr->hdr_len); types = malloc(btf->hdr-...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_str(struct btf *btf, const char *s) { int off; if (btf->base_btf) { off = btf__find_str(btf->base_btf, s); if (off != -ENOENT) return off; } if (btf_ensure_modifiable(btf)) return libbpf_err(-ENOMEM); off = strset__add_str(btf->strs_set, s); if (off < 0) return libbpf_e...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_type(struct btf *btf, const struct btf *src_btf, const struct btf_type *src_type) { struct btf_pipe p = {.src = src_btf, .dst = btf}; struct btf_type *t; int sz, err; sz = btf_type_size(src_type); if (sz < 0) return libbpf_err(sz); if (btf_ensure_modifiable(btf)) ret...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static int btf_rewrite_type_ids(__u32 *type_id, void *ctx) { struct btf *btf = ctx; if (!*type_id) return 0; /* we haven't updated btf's type count yet, so * btf->start_id + btf->nr_types - 1 is the type ID offset we should * add to all newly added BTF types */ *type_id += btf->start_id + btf->nr...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_float(struct btf *btf, const char *name, size_t byte_sz) { struct btf_type *t; int sz, name_off; if (!name || !name[0]) return libbpf_err(-EINVAL); /* byte_sz must be one of the explicitly allowed values */ if (byte_sz != 2 && byte_sz != 4 && byte_sz != 8 && byte_sz != 12 && byte_sz !...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_ptr(struct btf *btf, int ref_type_id) { return btf_add_ref_kind(btf, BTF_KIND_PTR, NULL, ref_type_id); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_array(struct btf *btf, int index_type_id, int elem_type_id, __u32 nr_elems) { struct btf_type *t; struct btf_array *a; int sz; if (validate_type_id(index_type_id) || validate_type_id(elem_type_id)) return libbpf_err(-EINVAL); if (btf_ensure_modifiable(btf)) return lib...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_field(struct btf *btf, const char *name, int type_id, __u32 bit_offset, __u32 bit_size) { struct btf_type *t; struct btf_member *m; bool is_bitfield; int sz, name_off = 0; if (btf->nr_types == 0) return libbpf_err(-EINVAL); t = btf_last_type(btf); if (!btf_is_composite...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_enum_value(struct btf *btf, const char *name, __s64 value) { struct btf_type *t; struct btf_enum *v; int sz, name_off; if (btf->nr_types == 0) return libbpf_err(-EINVAL); t = btf_last_type(btf); if (!btf_is_enum(t)) return libbpf_err(-EINVAL); /* non-empty name */ if (!name || !na...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_enum64(struct btf *btf, const char *name, __u32 byte_sz, bool is_signed) { return btf_add_enum_common(btf, name, byte_sz, is_signed, BTF_KIND_ENUM64); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_enum64_value(struct btf *btf, const char *name, __u64 value) { struct btf_enum64 *v; struct btf_type *t; int sz, name_off; if (btf->nr_types == 0) return libbpf_err(-EINVAL); t = btf_last_type(btf); if (!btf_is_enum64(t)) return libbpf_err(-EINVAL); /* non-empty name */ if (!name ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_fwd(struct btf *btf, const char *name, enum btf_fwd_kind fwd_kind) { if (!name || !name[0]) return libbpf_err(-EINVAL); switch (fwd_kind) { case BTF_FWD_STRUCT: case BTF_FWD_UNION: { struct btf_type *t; int id; id = btf_add_ref_kind(btf, BTF_KIND_FWD, name, 0); ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
int btf__add_decl_tag(struct btf *btf, const char *value, int ref_type_id, int component_idx) { struct btf_type *t; int sz, value_off; if (!value || !value[0] || component_idx < -1) return libbpf_err(-EINVAL); if (validate_type_id(ref_type_id)) return libbpf_err(-EINVAL); if (...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf_ext *btf_ext__new(const __u8 *data, __u32 size) { struct btf_ext *btf_ext; int err; btf_ext = calloc(1, sizeof(struct btf_ext)); if (!btf_ext) return libbpf_err_ptr(-ENOMEM); btf_ext->data_size = size; btf_ext->data = malloc(size); if (!btf_ext->data) { err = -ENOMEM; goto done; ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static int btf_dedup_table_add(struct btf_dedup *d, long hash, __u32 type_id) { return hashmap__append(d->dedup_table, hash, type_id); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static int btf_dedup_hypot_map_add(struct btf_dedup *d, __u32 from_id, __u32 to_id) { if (d->hypot_cnt == d->hypot_cap) { __u32 *new_list; d->hypot_cap += max((size_t)16, d->hypot_cap / 2); new_list = libbpf_reallocarray(d->hypot_list, d->hypot_cap, sizeof(__u32)); ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static size_t btf_dedup_collision_hash_fn(long key, void *ctx) { return 0; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static bool btf_dedup_equal_fn(long k1, long k2, void *ctx) { return k1 == k2; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static int btf_for_each_str_off(struct btf_dedup *d, str_off_visit_fn fn, void *ctx) { int i, r; for (i = 0; i < d->btf->nr_types; i++) { struct btf_type *t = btf_type_by_id(d->btf, d->btf->start_id + i); r = btf_type_visit_str_offs(t, fn, ctx); if (r) return r; ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static int btf_dedup_strings(struct btf_dedup *d) { int err; if (d->btf->strs_deduped) return 0; d->strs_set = strset__new(BTF_MAX_STR_OFFSET, NULL, 0); if (IS_ERR(d->strs_set)) { err = PTR_ERR(d->strs_set); goto err_out; } if (!d->btf->base_btf) { err = strset__add_str(d->strs_set, "");...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static bool btf_equal_common(struct btf_type *t1, struct btf_type *t2) { return t1->name_off == t2->name_off && t1->info == t2->info && t1->size == t2->size; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static bool btf_equal_enum_members(struct btf_type *t1, struct btf_type *t2) { const struct btf_enum *m1, *m2; __u16 vlen; int i; vlen = btf_vlen(t1); m1 = btf_enum(t1); m2 = btf_enum(t2); for (i = 0; i < vlen; i++) { if (m1->name_off != m2->name_off || m1->val != m2->val) return false; m1...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static inline bool btf_is_enum_fwd(struct btf_type *t) { return btf_is_any_enum(t) && btf_vlen(t) == 0; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static bool btf_compat_enum(struct btf_type *t1, struct btf_type *t2) { if (!btf_is_enum_fwd(t1) && !btf_is_enum_fwd(t2)) return btf_equal_enum(t1, t2); return t1->name_off == t2->name_off && btf_is_any_enum(t1) && btf_is_any_enum(t2); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static long btf_hash_array(struct btf_type *t) { const struct btf_array *info = btf_array(t); long h = btf_hash_common(t); h = hash_combine(h, info->type); h = hash_combine(h, info->index_type); h = hash_combine(h, info->nelems); return h; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static bool btf_compat_array(struct btf_type *t1, struct btf_type *t2) { if (!btf_equal_common(t1, t2)) return false; return btf_array(t1)->nelems == btf_array(t2)->nelems; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static inline __u16 btf_fwd_kind(struct btf_type *t) { return btf_kflag(t) ? BTF_KIND_UNION : BTF_KIND_STRUCT; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
static int btf_dedup_resolve_fwds(struct btf_dedup *d) { int i, err; struct hashmap *names_map; names_map = hashmap__new(btf_dedup_identity_hash_fn, btf_dedup_equal_fn, NULL); if (IS_ERR(names_map)) return PTR_ERR(names_map); err = btf_dedup_fill_unique_names_map(d, names_map); if (err < 0) ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf.c
struct btf *btf__load_module_btf(const char *module_name, struct btf *vmlinux_btf) { char path[80]; snprintf(path, sizeof(path), "/sys/kernel/btf/%s", module_name); return btf__parse_split(path, vmlinux_btf); }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static const char *pfx(int lvl) { return lvl >= PREFIX_CNT ? PREFIXES : &PREFIXES[PREFIX_CNT - lvl]; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static int btf_dump_resize(struct btf_dump *d) { int err, last_id = btf__type_cnt(d->btf) - 1; if (last_id <= d->last_id) return 0; if (libbpf_ensure_mem((void **)&d->type_states, &d->type_states_cap, sizeof(*d->type_states), last_id + 1)) return -ENOMEM; if (libbpf_ensure_mem(...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static bool btf_is_struct_packed(const struct btf *btf, __u32 id, const struct btf_type *t) { const struct btf_member *m; int align, i, bit_sz; __u16 vlen; align = btf__align_of(btf, id); if (align && t->size % align) return true; m = btf_members(t); vlen = btf_vlen...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static void btf_dump_emit_struct_fwd(struct btf_dump *d, __u32 id, const struct btf_type *t) { btf_dump_printf(d, "%s%s%s", btf_is_struct(t) ? "struct" : "union", t->name_off ? " " : "", btf_dump_type_name(d, id)); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static void btf_dump_emit_enum64_val(struct btf_dump *d, const struct btf_type *t, int lvl, __u16 vlen) { const struct btf_enum64 *v = btf_enum64(t); bool is_signed = btf_kflag(t); const char *fmt_str; const char *name; size_t dup_cnt;...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
int btf_dump__emit_type_decl(struct btf_dump *d, __u32 id, const struct btf_dump_emit_type_decl_opts *opts) { const char *fname; int lvl, err; if (!OPTS_VALID(opts, btf_dump_emit_type_decl_opts)) return libbpf_err(-EINVAL); err = btf_dump_resize(d); if (err) return libbp...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static const char *btf_dump_data_delim(struct btf_dump *d) { return d->typed_dump->depth == 0 ? "" : ","; }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static void btf_dump_data_pfx(struct btf_dump *d) { int i, lvl = d->typed_dump->indent_lvl + d->typed_dump->depth; if (d->typed_dump->compact) return; for (i = 0; i < lvl; i++) btf_dump_printf(d, "%s", d->typed_dump->indent_str); } #define btf_dump_type_values(d, fmt, ...) ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static int btf_dump_unsupported_data(struct btf_dump *d, const struct btf_type *t, __u32 id) { btf_dump_printf(d, "<unsupported kind:%u>", btf_kind(t)); return -ENOTSUP; }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static int btf_dump_get_bitfield_value(struct btf_dump *d, const struct btf_type *t, const void *data, __u8 bits_offset, __u8 bit_sz, __u64 *value) { __u16 left_shift_bits, right_shift_bits; const __...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static int btf_dump_bitfield_data(struct btf_dump *d, const struct btf_type *t, const void *data, __u8 bits_offset, __u8 bit_sz) { __u64 print_num; int err; err = btf_dump_get_bitfield_value(d, t, data, bits_offset, bit_sz, &print_num); ...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static int btf_dump_base_type_check_zero(struct btf_dump *d, const struct btf_type *t, __u32 id, const void *data) { static __u8 bytecmp[16] = {}; int nr_bytes; if (btf_kind(t) == BTF_KIND_PTR) nr_bytes = d->ptr_sz; else ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static int btf_dump_array_data(struct btf_dump *d, const struct btf_type *t, __u32 id, const void *data) { const struct btf_array *array = btf_array(t); const struct btf_type *elem_type; __u32 i, elem_type_id; __s64 elem_size; bool is_array_member; elem_type_id = array->type;...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
static int btf_dump_type_data_check_overflow(struct btf_dump *d, const struct btf_type *t, __u32 id, const void *data, __u8 bits_offset) { __s64 size = btf__resolve_size(d->btf, id); ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/btf_dump.c
int btf_dump__dump_type_data(struct btf_dump *d, __u32 id, const void *data, size_t data_sz, const struct btf_dump_type_data_opts *opts) { struct btf_dump_data typed_dump = {}; const struct btf_type *t; int ret; if (!OPTS_VALID(opts, btf_dump_type_data_...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/gen_loader.c
static int blob_fd_array_off(struct bpf_gen *gen, int index) { return gen->fd_array + index * sizeof(int); }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/gen_loader.c
static int realloc_data_buf(struct bpf_gen *gen, __u32 size) { size_t off = gen->data_cur - gen->data_start; void *data_start; if (gen->error) return gen->error; if (size > INT32_MAX || off + size > INT32_MAX) { gen->error = -ERANGE; return -ERANGE; } data_start = realloc(gen->data_start, off ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/gen_loader.c
static void emit2(struct bpf_gen *gen, struct bpf_insn insn1, struct bpf_insn insn2) { emit(gen, insn1); emit(gen, insn2); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/gen_loader.c
static int add_data(struct bpf_gen *gen, const void *data, __u32 size) { __u32 size8 = roundup(size, 8); __u64 zero = 0; void *prev; if (realloc_data_buf(gen, size8)) return 0; prev = gen->data_cur; if (data) { memcpy(gen->data_cur, data, size); memcpy(gen->data_cur + size, &zero, size8 - size...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/gen_loader.c
static int add_kfunc_btf_fd(struct bpf_gen *gen) { int cur; if (gen->nr_fd_array == MAX_KFUNC_DESCS) { cur = add_data(gen, NULL, sizeof(int)); return (cur - gen->fd_array) / sizeof(int); } return MAX_USED_MAPS + gen->nr_fd_array++; }
[ 1, 0 ]