libbpf: Rename DECLARE_LIBBPF_OPTS into LIBBPF_OPTS
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 3 Nov 2021 22:08:34 +0000 (15:08 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 7 Nov 2021 16:34:22 +0000 (08:34 -0800)
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: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/bpf/20211103220845.2676888-2-andrii@kernel.org
tools/lib/bpf/bpf.h
tools/lib/bpf/libbpf_common.h
tools/lib/bpf/libbpf_legacy.h

index 6fffb3cdf39b9996a1975a1ba5c9b9eadcc82185..f35146c1d9a9876bba4f8e4b6ef23931200eb94e 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdint.h>
 
 #include "libbpf_common.h"
+#include "libbpf_legacy.h"
 
 #ifdef __cplusplus
 extern "C" {
index aaa1efbf6f5109dd80988e7396c00dd524b19c21..0967112b933a7ce590131f91cbb651c364e2c3bf 100644 (file)
@@ -54,7 +54,7 @@
  * including any extra padding, it with memset() and then assigns initial
  * values provided by users in struct initializer-syntax as varargs.
  */
-#define DECLARE_LIBBPF_OPTS(TYPE, NAME, ...)                               \
+#define LIBBPF_OPTS(TYPE, NAME, ...)                                       \
        struct TYPE NAME = ({                                               \
                memset(&NAME, 0, sizeof(struct TYPE));                      \
                (struct TYPE) {                                             \
index 5ba5c9beccfa929c0ca8b8afb9d1904c45f4cbae..bb03c568af7b783e7cb73ce08d177482ca155920 100644 (file)
@@ -69,6 +69,7 @@ enum libbpf_strict_mode {
 
 LIBBPF_API int libbpf_set_strict_mode(enum libbpf_strict_mode mode);
 
+#define DECLARE_LIBBPF_OPTS LIBBPF_OPTS
 
 #ifdef __cplusplus
 } /* extern "C" */