diff mbox series

[bpf-next,v3,01/11] btf: change BTF_KIND_* macros to enums

Message ID 20210914223009.245307-1-yhs@fb.com (mailing list archive)
State Accepted
Commit 41ced4cd88020c9d4b71ff7c50d020f081efa4a0
Delegated to: BPF
Headers show
Series bpf: add support for new btf kind BTF_KIND_TAG | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 6 maintainers not CCed: kpsingh@kernel.org john.fastabend@gmail.com iii@linux.ibm.com songliubraving@fb.com netdev@vger.kernel.org kafai@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 153 this patch: 153
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 94 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 153 this patch: 153
netdev/header_inline success Link
bpf/vmtest-bpf-next success VM_Test

Commit Message

Yonghong Song Sept. 14, 2021, 10:30 p.m. UTC
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>
---
 include/uapi/linux/btf.h       | 41 ++++++++++++++++++----------------
 tools/include/uapi/linux/btf.h | 41 ++++++++++++++++++----------------
 2 files changed, 44 insertions(+), 38 deletions(-)

Comments

Andrii Nakryiko Sept. 15, 2021, 12:13 a.m. UTC | #1
On Tue, Sep 14, 2021 at 3:30 PM Yonghong Song <yhs@fb.com> wrote:
>
> 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>
> ---

Awesome, thanks!

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  include/uapi/linux/btf.h       | 41 ++++++++++++++++++----------------
>  tools/include/uapi/linux/btf.h | 41 ++++++++++++++++++----------------
>  2 files changed, 44 insertions(+), 38 deletions(-)
>
> diff --git a/include/uapi/linux/btf.h b/include/uapi/linux/btf.h
> index d27b1708efe9..10e401073dd1 100644
> --- a/include/uapi/linux/btf.h
> +++ b/include/uapi/linux/btf.h
> @@ -56,25 +56,28 @@ struct btf_type {
>  #define BTF_INFO_VLEN(info)    ((info) & 0xffff)
>  #define BTF_INFO_KFLAG(info)   ((info) >> 31)
>
> -#define BTF_KIND_UNKN          0       /* Unknown      */
> -#define BTF_KIND_INT           1       /* Integer      */
> -#define BTF_KIND_PTR           2       /* Pointer      */
> -#define BTF_KIND_ARRAY         3       /* Array        */
> -#define BTF_KIND_STRUCT                4       /* Struct       */
> -#define BTF_KIND_UNION         5       /* Union        */
> -#define BTF_KIND_ENUM          6       /* Enumeration  */
> -#define BTF_KIND_FWD           7       /* Forward      */
> -#define BTF_KIND_TYPEDEF       8       /* Typedef      */
> -#define BTF_KIND_VOLATILE      9       /* Volatile     */
> -#define BTF_KIND_CONST         10      /* Const        */
> -#define BTF_KIND_RESTRICT      11      /* Restrict     */
> -#define BTF_KIND_FUNC          12      /* Function     */
> -#define BTF_KIND_FUNC_PROTO    13      /* Function Proto       */
> -#define BTF_KIND_VAR           14      /* Variable     */
> -#define BTF_KIND_DATASEC       15      /* Section      */
> -#define BTF_KIND_FLOAT         16      /* Floating point       */
> -#define BTF_KIND_MAX           BTF_KIND_FLOAT
> -#define NR_BTF_KINDS           (BTF_KIND_MAX + 1)
> +enum {
> +       BTF_KIND_UNKN           = 0,    /* Unknown      */
> +       BTF_KIND_INT            = 1,    /* Integer      */
> +       BTF_KIND_PTR            = 2,    /* Pointer      */
> +       BTF_KIND_ARRAY          = 3,    /* Array        */
> +       BTF_KIND_STRUCT         = 4,    /* Struct       */
> +       BTF_KIND_UNION          = 5,    /* Union        */
> +       BTF_KIND_ENUM           = 6,    /* Enumeration  */
> +       BTF_KIND_FWD            = 7,    /* Forward      */
> +       BTF_KIND_TYPEDEF        = 8,    /* Typedef      */
> +       BTF_KIND_VOLATILE       = 9,    /* Volatile     */
> +       BTF_KIND_CONST          = 10,   /* Const        */
> +       BTF_KIND_RESTRICT       = 11,   /* Restrict     */
> +       BTF_KIND_FUNC           = 12,   /* Function     */
> +       BTF_KIND_FUNC_PROTO     = 13,   /* Function Proto       */
> +       BTF_KIND_VAR            = 14,   /* Variable     */
> +       BTF_KIND_DATASEC        = 15,   /* Section      */
> +       BTF_KIND_FLOAT          = 16,   /* Floating point       */
> +
> +       NR_BTF_KINDS,
> +       BTF_KIND_MAX            = NR_BTF_KINDS - 1,
> +};
>
>  /* For some specific BTF_KIND, "struct btf_type" is immediately
>   * followed by extra data.

[...]
diff mbox series

Patch

diff --git a/include/uapi/linux/btf.h b/include/uapi/linux/btf.h
index d27b1708efe9..10e401073dd1 100644
--- a/include/uapi/linux/btf.h
+++ b/include/uapi/linux/btf.h
@@ -56,25 +56,28 @@  struct btf_type {
 #define BTF_INFO_VLEN(info)	((info) & 0xffff)
 #define BTF_INFO_KFLAG(info)	((info) >> 31)
 
-#define BTF_KIND_UNKN		0	/* Unknown	*/
-#define BTF_KIND_INT		1	/* Integer	*/
-#define BTF_KIND_PTR		2	/* Pointer	*/
-#define BTF_KIND_ARRAY		3	/* Array	*/
-#define BTF_KIND_STRUCT		4	/* Struct	*/
-#define BTF_KIND_UNION		5	/* Union	*/
-#define BTF_KIND_ENUM		6	/* Enumeration	*/
-#define BTF_KIND_FWD		7	/* Forward	*/
-#define BTF_KIND_TYPEDEF	8	/* Typedef	*/
-#define BTF_KIND_VOLATILE	9	/* Volatile	*/
-#define BTF_KIND_CONST		10	/* Const	*/
-#define BTF_KIND_RESTRICT	11	/* Restrict	*/
-#define BTF_KIND_FUNC		12	/* Function	*/
-#define BTF_KIND_FUNC_PROTO	13	/* Function Proto	*/
-#define BTF_KIND_VAR		14	/* Variable	*/
-#define BTF_KIND_DATASEC	15	/* Section	*/
-#define BTF_KIND_FLOAT		16	/* Floating point	*/
-#define BTF_KIND_MAX		BTF_KIND_FLOAT
-#define NR_BTF_KINDS		(BTF_KIND_MAX + 1)
+enum {
+	BTF_KIND_UNKN		= 0,	/* Unknown	*/
+	BTF_KIND_INT		= 1,	/* Integer	*/
+	BTF_KIND_PTR		= 2,	/* Pointer	*/
+	BTF_KIND_ARRAY		= 3,	/* Array	*/
+	BTF_KIND_STRUCT		= 4,	/* Struct	*/
+	BTF_KIND_UNION		= 5,	/* Union	*/
+	BTF_KIND_ENUM		= 6,	/* Enumeration	*/
+	BTF_KIND_FWD		= 7,	/* Forward	*/
+	BTF_KIND_TYPEDEF	= 8,	/* Typedef	*/
+	BTF_KIND_VOLATILE	= 9,	/* Volatile	*/
+	BTF_KIND_CONST		= 10,	/* Const	*/
+	BTF_KIND_RESTRICT	= 11,	/* Restrict	*/
+	BTF_KIND_FUNC		= 12,	/* Function	*/
+	BTF_KIND_FUNC_PROTO	= 13,	/* Function Proto	*/
+	BTF_KIND_VAR		= 14,	/* Variable	*/
+	BTF_KIND_DATASEC	= 15,	/* Section	*/
+	BTF_KIND_FLOAT		= 16,	/* Floating point	*/
+
+	NR_BTF_KINDS,
+	BTF_KIND_MAX		= NR_BTF_KINDS - 1,
+};
 
 /* For some specific BTF_KIND, "struct btf_type" is immediately
  * followed by extra data.
diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h
index d27b1708efe9..10e401073dd1 100644
--- a/tools/include/uapi/linux/btf.h
+++ b/tools/include/uapi/linux/btf.h
@@ -56,25 +56,28 @@  struct btf_type {
 #define BTF_INFO_VLEN(info)	((info) & 0xffff)
 #define BTF_INFO_KFLAG(info)	((info) >> 31)
 
-#define BTF_KIND_UNKN		0	/* Unknown	*/
-#define BTF_KIND_INT		1	/* Integer	*/
-#define BTF_KIND_PTR		2	/* Pointer	*/
-#define BTF_KIND_ARRAY		3	/* Array	*/
-#define BTF_KIND_STRUCT		4	/* Struct	*/
-#define BTF_KIND_UNION		5	/* Union	*/
-#define BTF_KIND_ENUM		6	/* Enumeration	*/
-#define BTF_KIND_FWD		7	/* Forward	*/
-#define BTF_KIND_TYPEDEF	8	/* Typedef	*/
-#define BTF_KIND_VOLATILE	9	/* Volatile	*/
-#define BTF_KIND_CONST		10	/* Const	*/
-#define BTF_KIND_RESTRICT	11	/* Restrict	*/
-#define BTF_KIND_FUNC		12	/* Function	*/
-#define BTF_KIND_FUNC_PROTO	13	/* Function Proto	*/
-#define BTF_KIND_VAR		14	/* Variable	*/
-#define BTF_KIND_DATASEC	15	/* Section	*/
-#define BTF_KIND_FLOAT		16	/* Floating point	*/
-#define BTF_KIND_MAX		BTF_KIND_FLOAT
-#define NR_BTF_KINDS		(BTF_KIND_MAX + 1)
+enum {
+	BTF_KIND_UNKN		= 0,	/* Unknown	*/
+	BTF_KIND_INT		= 1,	/* Integer	*/
+	BTF_KIND_PTR		= 2,	/* Pointer	*/
+	BTF_KIND_ARRAY		= 3,	/* Array	*/
+	BTF_KIND_STRUCT		= 4,	/* Struct	*/
+	BTF_KIND_UNION		= 5,	/* Union	*/
+	BTF_KIND_ENUM		= 6,	/* Enumeration	*/
+	BTF_KIND_FWD		= 7,	/* Forward	*/
+	BTF_KIND_TYPEDEF	= 8,	/* Typedef	*/
+	BTF_KIND_VOLATILE	= 9,	/* Volatile	*/
+	BTF_KIND_CONST		= 10,	/* Const	*/
+	BTF_KIND_RESTRICT	= 11,	/* Restrict	*/
+	BTF_KIND_FUNC		= 12,	/* Function	*/
+	BTF_KIND_FUNC_PROTO	= 13,	/* Function Proto	*/
+	BTF_KIND_VAR		= 14,	/* Variable	*/
+	BTF_KIND_DATASEC	= 15,	/* Section	*/
+	BTF_KIND_FLOAT		= 16,	/* Floating point	*/
+
+	NR_BTF_KINDS,
+	BTF_KIND_MAX		= NR_BTF_KINDS - 1,
+};
 
 /* For some specific BTF_KIND, "struct btf_type" is immediately
  * followed by extra data.