1
2
3
4
5
6
7
8
9#ifndef __LIBBPF_LIBBPF_COMMON_H
10#define __LIBBPF_LIBBPF_COMMON_H
11
12#include <string.h>
13#include "libbpf_version.h"
14
15#ifndef LIBBPF_API
16#define LIBBPF_API __attribute__((visibility("default")))
17#endif
18
19#define LIBBPF_DEPRECATED(msg) __attribute__((deprecated(msg)))
20
21
22#define LIBBPF_DEPRECATED_SINCE(major, minor, msg) \
23 __LIBBPF_MARK_DEPRECATED_ ## major ## _ ## minor \
24 (LIBBPF_DEPRECATED("libbpf v" # major "." # minor "+: " msg))
25
26#define __LIBBPF_CURRENT_VERSION_GEQ(major, minor) \
27 (LIBBPF_MAJOR_VERSION > (major) || \
28 (LIBBPF_MAJOR_VERSION == (major) && LIBBPF_MINOR_VERSION >= (minor)))
29
30
31
32
33#if __LIBBPF_CURRENT_VERSION_GEQ(0, 6)
34#define __LIBBPF_MARK_DEPRECATED_0_6(X) X
35#else
36#define __LIBBPF_MARK_DEPRECATED_0_6(X)
37#endif
38#if __LIBBPF_CURRENT_VERSION_GEQ(0, 7)
39#define __LIBBPF_MARK_DEPRECATED_0_7(X) X
40#else
41#define __LIBBPF_MARK_DEPRECATED_0_7(X)
42#endif
43#if __LIBBPF_CURRENT_VERSION_GEQ(0, 8)
44#define __LIBBPF_MARK_DEPRECATED_0_8(X) X
45#else
46#define __LIBBPF_MARK_DEPRECATED_0_8(X)
47#endif
48
49
50
51
52
53
54
55#define ___libbpf_cat(A, B) A ## B
56#define ___libbpf_select(NAME, NUM) ___libbpf_cat(NAME, NUM)
57#define ___libbpf_nth(_1, _2, _3, _4, _5, _6, N, ...) N
58#define ___libbpf_cnt(...) ___libbpf_nth(__VA_ARGS__, 6, 5, 4, 3, 2, 1)
59#define ___libbpf_overload(NAME, ...) ___libbpf_select(NAME, ___libbpf_cnt(__VA_ARGS__))(__VA_ARGS__)
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74#define LIBBPF_OPTS(TYPE, NAME, ...) \
75 struct TYPE NAME = ({ \
76 memset(&NAME, 0, sizeof(struct TYPE)); \
77 (struct TYPE) { \
78 .sz = sizeof(struct TYPE), \
79 __VA_ARGS__ \
80 }; \
81 })
82
83#endif
84