time_in_state: Use common BPF helper

The BPF helper is moved into system/bpf/include/ and is available
to all BPF programs in the include search path. Make use of it.

Only minor refactor, no functional change.

Bug: 122665156
Change-Id: I21db3e9fd7063ae2b10833693f74857472217611
Signed-off-by: Joel Fernandes <joelaf@google.com>
diff --git a/helpers.h b/helpers.h
deleted file mode 100644
index e68408a..0000000
--- a/helpers.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <linux/bpf.h>
-#include <stdbool.h>
-#include <stdint.h>
-
-/* place things in different elf sections */
-#define SEC(NAME) __attribute__((section(NAME), used))
-
-/* helper functions */
-static void* (*bpf_map_lookup_elem)(void* map, void* key) = (void*) BPF_FUNC_map_lookup_elem;
-static int (*bpf_map_update_elem)(void* map, void* key, void* value,
-                                  unsigned long long flags) = (void*) BPF_FUNC_map_update_elem;
-static int (*bpf_map_delete_elem)(void* map, void* key) = (void*) BPF_FUNC_map_delete_elem;
-static int (*bpf_probe_read)(void* dst, int size, void* unsafe_ptr) = (void*) BPF_FUNC_probe_read;
-static unsigned long long (*bpf_ktime_get_ns)(void) = (void*) BPF_FUNC_ktime_get_ns;
-static int (*bpf_trace_printk)(const char* fmt, int fmt_size, ...) = (void*) BPF_FUNC_trace_printk;
-static unsigned long long (*bpf_get_current_pid_tgid)(void) = (void*) BPF_FUNC_get_current_pid_tgid;
-static unsigned long long (*bpf_get_current_uid_gid)(void) = (void*) BPF_FUNC_get_current_uid_gid;
-static unsigned long long (*bpf_get_smp_processor_id)(void) = (void*) BPF_FUNC_get_smp_processor_id;
-
-/* loader usage */
-struct bpf_map_def {
-    unsigned int type;
-    unsigned int key_size;
-    unsigned int value_size;
-    unsigned int max_entries;
-    unsigned int map_flags;
-    unsigned int pad1;
-    unsigned int pad2;
-};
diff --git a/test/bpf_load_tp_prog.c b/test/bpf_load_tp_prog.c
index 37bd516..a8b4860 100644
--- a/test/bpf_load_tp_prog.c
+++ b/test/bpf_load_tp_prog.c
@@ -17,7 +17,7 @@
 #include <linux/bpf.h>
 #include <stdbool.h>
 #include <stdint.h>
-#include "../helpers.h"
+#include <bpf_helpers.h>
 
 struct bpf_map_def SEC("maps") cpu_pid = {
         .type = BPF_MAP_TYPE_ARRAY,
diff --git a/time_in_state.c b/time_in_state.c
index d61d279..ddf8900 100644
--- a/time_in_state.c
+++ b/time_in_state.c
@@ -14,7 +14,7 @@
  *
  */
 
-#include "helpers.h"
+#include <bpf_helpers.h>
 
 struct time_key {
     uint32_t uid;