Build for Tizen platform 90/268390/3 submit/tizen/20211223.065804
authorNiraj Kumar Goit <niraj.g@samsung.com>
Wed, 22 Dec 2021 06:34:46 +0000 (12:04 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Thu, 23 Dec 2021 04:57:00 +0000 (10:27 +0530)
Change-Id: Ie240fa38ebcd8b2f9ece7d91f5d3202bb821247e
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
LICENSE.LGPL-2.1 [moved from LICENSE.LPGL-2.1 with 100% similarity]
libbpf.manifest [new file with mode: 0755]
packaging/libbpf.spec [new file with mode: 0755]
src/Makefile
src/bpf.c
src/libbpf.c

similarity index 100%
rename from LICENSE.LPGL-2.1
rename to LICENSE.LGPL-2.1
diff --git a/libbpf.manifest b/libbpf.manifest
new file mode 100755 (executable)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/packaging/libbpf.spec b/packaging/libbpf.spec
new file mode 100755 (executable)
index 0000000..9f0013a
--- /dev/null
@@ -0,0 +1,71 @@
+Name:          libbpf
+Summary:       Libbpf library
+Version:       0.2.0
+Release:       1
+Group:         System/Network
+License:       LGPL-2.1+ or BSD-2-Clause
+Source0:       %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(libelf)
+BuildRequires: cmake
+
+# This package supersedes libbpf from kernel-tools,
+# which has default Epoch: 0. By having Epoch: > 0
+# this libbpf will take over smoothly
+Epoch:          2
+
+Requires(post):                /sbin/ldconfig
+Requires(postun):      /sbin/ldconfig
+
+%description
+A mirror of bpf-next linux tree bpf-next/tools/lib/bpf directory plus its
+supporting header files. The version of the package reflects the version of
+ABI.
+
+%package devel
+Summary:        Development files for %{name}
+Requires:       %{name} = 2:%{version}-%{release}
+Requires:       kernel-headers >= 5.14.0
+Requires:       zlib
+
+%description devel
+The %{name}-devel package contains libraries header files for
+developing applications that use %{name}
+
+%package static
+Summary: Static library for libbpf development
+Requires: %{name}-devel = 2:%{version}-%{release}
+
+%description static
+The %{name}-static package contains static library for
+developing applications that use %{name}
+
+%prep
+%setup -q
+
+%build
+%ifarch aarch64
+make -C ./src __aarch64__=1
+%else
+make -C ./src __arm__=1
+%endif
+
+%install
+make -C ./src install DESTDIR=%{buildroot} INSTALL_DIR=%{buildroot}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%license LICENSE LICENSE.BSD-2-Clause LICENSE.LGPL-2.1
+%{_libdir}/libbpf.so.%{version}
+%{_libdir}/libbpf.so.0
+
+%files devel
+%{_libdir}/libbpf.so
+%{_includedir}/bpf/
+%{_libdir}/pkgconfig/libbpf.pc
+
+%files static
+%{_libdir}/libbpf.a
index e81523e..2ad4276 100644 (file)
@@ -10,7 +10,7 @@ endif
 
 LIBBPF_VERSION := $(shell \
        grep -oE '^LIBBPF_([0-9.]+)' libbpf.map | \
-       sort -rV | head -n1 | cut -d'_' -f2)
+       sort -r | head -n1 | cut -d'_' -f2)
 LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION)))
 
 TOPDIR = ..
@@ -60,7 +60,7 @@ INSTALL = install
 
 DESTDIR ?=
 
-ifeq ($(shell uname -m),x86_64)
+ifeq ($(shell uname -m),aarch64)
        LIBSUBDIR := lib64
 else
        LIBSUBDIR := lib
index d27e341..e55b897 100644 (file)
--- a/src/bpf.c
+++ b/src/bpf.c
 #  define __NR_bpf 351
 # elif defined(__arc__)
 #  define __NR_bpf 280
+# elif defined(__arm__)
+#  define __NR_BPF_OABI_SYSCALL_BASE    0x900000
+#  if defined(__thumb__) || defined(__ARM_EABI__)
+#   define __NR_BPF_SYSCALL_BASE       0
+#  else
+#   define __NR_BPF_SYSCALL_BASE       __NR_BPF_OABI_SYSCALL_BASE
+#  endif
+#  define __NR_bpf                     (__NR_BPF_SYSCALL_BASE+386)
 # else
 #  error __NR_bpf not defined. libbpf does not support your arch.
 # endif
index 3130341..830bf11 100644 (file)
 
 #define __printf(a, b) __attribute__((format(printf, a, b)))
 
+#ifndef PERF_EVENT_IOC_SET_BPF
+# define PERF_EVENT_IOC_SET_BPF                _IOW('$', 8, __u32)
+#endif
+
+#ifndef PERF_FLAG_FD_CLOEXEC
+# define PERF_FLAG_FD_CLOEXEC          (1UL << 3) /* O_CLOEXEC */
+#endif
+
+#ifndef PERF_COUNT_SW_BPF_OUTPUT
+# define PERF_COUNT_SW_BPF_OUTPUT      10
+#endif
+
 static struct bpf_map *bpf_object__add_map(struct bpf_object *obj);
 static const struct btf_type *
 skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);