提交 ab7af015 编写于 作者: A Andrii Nakryiko 提交者: Zheng Zengkai

libbpf: Rename DECLARE_LIBBPF_OPTS into LIBBPF_OPTS

mainline inclusion
from mainline-5.17-rc1
commit be80e9cd
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=be80e9cdbca8ac66d09e0e24e0bd41d992362a0b

-------------------------------------------------

It's confusing that libbpf-provided helper macro doesn't start with
LIBBPF. Also "declare" vs "define" is confusing terminology, I can never
remember and always have to look up previous examples.

Bypass both issues by renaming DECLARE_LIBBPF_OPTS into a short and
clean LIBBPF_OPTS. To avoid breaking existing code, provide:

  #define DECLARE_LIBBPF_OPTS LIBBPF_OPTS

in libbpf_legacy.h. We can decide later if we ever want to remove it or
we'll keep it forever because it doesn't add any maintainability burden.
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
Acked-by: NDave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/bpf/20211103220845.2676888-2-andrii@kernel.org
(cherry picked from commit be80e9cd)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 f378bb55
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <stdint.h> #include <stdint.h>
#include "libbpf_common.h" #include "libbpf_common.h"
#include "libbpf_legacy.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
* including any extra padding, it with memset() and then assigns initial * including any extra padding, it with memset() and then assigns initial
* values provided by users in struct initializer-syntax as varargs. * values provided by users in struct initializer-syntax as varargs.
*/ */
#define DECLARE_LIBBPF_OPTS(TYPE, NAME, ...) \ #define LIBBPF_OPTS(TYPE, NAME, ...) \
struct TYPE NAME = ({ \ struct TYPE NAME = ({ \
memset(&NAME, 0, sizeof(struct TYPE)); \ memset(&NAME, 0, sizeof(struct TYPE)); \
(struct TYPE) { \ (struct TYPE) { \
......
...@@ -51,6 +51,7 @@ enum libbpf_strict_mode { ...@@ -51,6 +51,7 @@ enum libbpf_strict_mode {
LIBBPF_API int libbpf_set_strict_mode(enum libbpf_strict_mode mode); LIBBPF_API int libbpf_set_strict_mode(enum libbpf_strict_mode mode);
#define DECLARE_LIBBPF_OPTS LIBBPF_OPTS
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册