Skip to content

Commit 41ced4c

Browse files
yonghong-songAlexei Starovoitov
authored andcommitted
btf: Change BTF_KIND_* macros to enums
Change BTF_KIND_* macros to enums so they are encoded in dwarf and appear in vmlinux.h. This will make it easier for bpf programs to use these constants without macro definitions. Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210914223009.245307-1-yhs@fb.com
1 parent 8987ede commit 41ced4c

2 files changed

Lines changed: 44 additions & 38 deletions

File tree

  • include/uapi/linux
  • tools/include/uapi/linux

‎include/uapi/linux/btf.h‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,28 @@ struct btf_type {
5656
#define BTF_INFO_VLEN(info) ((info) & 0xffff)
5757
#define BTF_INFO_KFLAG(info) ((info) >> 31)
5858

59-
#define BTF_KIND_UNKN 0 /* Unknown */
60-
#define BTF_KIND_INT 1 /* Integer */
61-
#define BTF_KIND_PTR 2 /* Pointer */
62-
#define BTF_KIND_ARRAY 3 /* Array */
63-
#define BTF_KIND_STRUCT 4 /* Struct */
64-
#define BTF_KIND_UNION 5 /* Union */
65-
#define BTF_KIND_ENUM 6 /* Enumeration */
66-
#define BTF_KIND_FWD 7 /* Forward */
67-
#define BTF_KIND_TYPEDEF 8 /* Typedef */
68-
#define BTF_KIND_VOLATILE 9 /* Volatile */
69-
#define BTF_KIND_CONST 10 /* Const */
70-
#define BTF_KIND_RESTRICT 11 /* Restrict */
71-
#define BTF_KIND_FUNC 12 /* Function */
72-
#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
73-
#define BTF_KIND_VAR 14 /* Variable */
74-
#define BTF_KIND_DATASEC 15 /* Section */
75-
#define BTF_KIND_FLOAT 16 /* Floating point */
76-
#define BTF_KIND_MAX BTF_KIND_FLOAT
77-
#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
59+
enum {
60+
BTF_KIND_UNKN = 0, /* Unknown */
61+
BTF_KIND_INT = 1, /* Integer */
62+
BTF_KIND_PTR = 2, /* Pointer */
63+
BTF_KIND_ARRAY = 3, /* Array */
64+
BTF_KIND_STRUCT = 4, /* Struct */
65+
BTF_KIND_UNION = 5, /* Union */
66+
BTF_KIND_ENUM = 6, /* Enumeration */
67+
BTF_KIND_FWD = 7, /* Forward */
68+
BTF_KIND_TYPEDEF = 8, /* Typedef */
69+
BTF_KIND_VOLATILE = 9, /* Volatile */
70+
BTF_KIND_CONST = 10, /* Const */
71+
BTF_KIND_RESTRICT = 11, /* Restrict */
72+
BTF_KIND_FUNC = 12, /* Function */
73+
BTF_KIND_FUNC_PROTO = 13, /* Function Proto */
74+
BTF_KIND_VAR = 14, /* Variable */
75+
BTF_KIND_DATASEC = 15, /* Section */
76+
BTF_KIND_FLOAT = 16, /* Floating point */
77+
78+
NR_BTF_KINDS,
79+
BTF_KIND_MAX = NR_BTF_KINDS - 1,
80+
};
7881

7982
/* For some specific BTF_KIND, "struct btf_type" is immediately
8083
* followed by extra data.

‎tools/include/uapi/linux/btf.h‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,28 @@ struct btf_type {
5656
#define BTF_INFO_VLEN(info) ((info) & 0xffff)
5757
#define BTF_INFO_KFLAG(info) ((info) >> 31)
5858

59-
#define BTF_KIND_UNKN 0 /* Unknown */
60-
#define BTF_KIND_INT 1 /* Integer */
61-
#define BTF_KIND_PTR 2 /* Pointer */
62-
#define BTF_KIND_ARRAY 3 /* Array */
63-
#define BTF_KIND_STRUCT 4 /* Struct */
64-
#define BTF_KIND_UNION 5 /* Union */
65-
#define BTF_KIND_ENUM 6 /* Enumeration */
66-
#define BTF_KIND_FWD 7 /* Forward */
67-
#define BTF_KIND_TYPEDEF 8 /* Typedef */
68-
#define BTF_KIND_VOLATILE 9 /* Volatile */
69-
#define BTF_KIND_CONST 10 /* Const */
70-
#define BTF_KIND_RESTRICT 11 /* Restrict */
71-
#define BTF_KIND_FUNC 12 /* Function */
72-
#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */
73-
#define BTF_KIND_VAR 14 /* Variable */
74-
#define BTF_KIND_DATASEC 15 /* Section */
75-
#define BTF_KIND_FLOAT 16 /* Floating point */
76-
#define BTF_KIND_MAX BTF_KIND_FLOAT
77-
#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
59+
enum {
60+
BTF_KIND_UNKN = 0, /* Unknown */
61+
BTF_KIND_INT = 1, /* Integer */
62+
BTF_KIND_PTR = 2, /* Pointer */
63+
BTF_KIND_ARRAY = 3, /* Array */
64+
BTF_KIND_STRUCT = 4, /* Struct */
65+
BTF_KIND_UNION = 5, /* Union */
66+
BTF_KIND_ENUM = 6, /* Enumeration */
67+
BTF_KIND_FWD = 7, /* Forward */
68+
BTF_KIND_TYPEDEF = 8, /* Typedef */
69+
BTF_KIND_VOLATILE = 9, /* Volatile */
70+
BTF_KIND_CONST = 10, /* Const */
71+
BTF_KIND_RESTRICT = 11, /* Restrict */
72+
BTF_KIND_FUNC = 12, /* Function */
73+
BTF_KIND_FUNC_PROTO = 13, /* Function Proto */
74+
BTF_KIND_VAR = 14, /* Variable */
75+
BTF_KIND_DATASEC = 15, /* Section */
76+
BTF_KIND_FLOAT = 16, /* Floating point */
77+
78+
NR_BTF_KINDS,
79+
BTF_KIND_MAX = NR_BTF_KINDS - 1,
80+
};
7881

7982
/* For some specific BTF_KIND, "struct btf_type" is immediately
8083
* followed by extra data.

0 commit comments

Comments
 (0)