Merge "Allow multiple processes' threads tracked at the same time"
diff --git a/libbpf_android/include/bpf/BpfUtils.h b/libbpf_android/include/bpf/BpfUtils.h
index 428606a..046d80f 100644
--- a/libbpf_android/include/bpf/BpfUtils.h
+++ b/libbpf_android/include/bpf/BpfUtils.h
@@ -29,11 +29,11 @@
 
 #ifdef BPF_FD_JUST_USE_INT
   #define BPF_FD_TYPE int
-  #define BPF_FD_TO_INT(x) (x)
+  #define BPF_FD_TO_U32(x) static_cast<__u32>(x)
 #else
   #include <android-base/unique_fd.h>
   #define BPF_FD_TYPE base::unique_fd&
-  #define BPF_FD_TO_INT(x) static_cast<__u32>((x).get())
+  #define BPF_FD_TO_U32(x) static_cast<__u32>((x).get())
 #endif
 
 #define ptr_to_u64(x) ((uint64_t)(uintptr_t)(x))
@@ -84,7 +84,7 @@
 inline int writeToMapEntry(const BPF_FD_TYPE map_fd, const void* key, const void* value,
                            uint64_t flags) {
     return bpf(BPF_MAP_UPDATE_ELEM, {
-                                            .map_fd = BPF_FD_TO_INT(map_fd),
+                                            .map_fd = BPF_FD_TO_U32(map_fd),
                                             .key = ptr_to_u64(key),
                                             .value = ptr_to_u64(value),
                                             .flags = flags,
@@ -93,7 +93,7 @@
 
 inline int findMapEntry(const BPF_FD_TYPE map_fd, const void* key, void* value) {
     return bpf(BPF_MAP_LOOKUP_ELEM, {
-                                            .map_fd = BPF_FD_TO_INT(map_fd),
+                                            .map_fd = BPF_FD_TO_U32(map_fd),
                                             .key = ptr_to_u64(key),
                                             .value = ptr_to_u64(value),
                                     });
@@ -101,14 +101,14 @@
 
 inline int deleteMapEntry(const BPF_FD_TYPE map_fd, const void* key) {
     return bpf(BPF_MAP_DELETE_ELEM, {
-                                            .map_fd = BPF_FD_TO_INT(map_fd),
+                                            .map_fd = BPF_FD_TO_U32(map_fd),
                                             .key = ptr_to_u64(key),
                                     });
 }
 
 inline int getNextMapKey(const BPF_FD_TYPE map_fd, const void* key, void* next_key) {
     return bpf(BPF_MAP_GET_NEXT_KEY, {
-                                             .map_fd = BPF_FD_TO_INT(map_fd),
+                                             .map_fd = BPF_FD_TO_U32(map_fd),
                                              .key = ptr_to_u64(key),
                                              .next_key = ptr_to_u64(next_key),
                                      });
@@ -121,7 +121,7 @@
 inline int bpfFdPin(const BPF_FD_TYPE map_fd, const char* pathname) {
     return bpf(BPF_OBJ_PIN, {
                                     .pathname = ptr_to_u64(pathname),
-                                    .bpf_fd = BPF_FD_TO_INT(map_fd),
+                                    .bpf_fd = BPF_FD_TO_U32(map_fd),
                             });
 }
 
@@ -155,15 +155,15 @@
 inline int attachProgram(bpf_attach_type type, const BPF_FD_TYPE prog_fd,
                          const BPF_FD_TYPE cg_fd) {
     return bpf(BPF_PROG_ATTACH, {
-                                        .target_fd = BPF_FD_TO_INT(cg_fd),
-                                        .attach_bpf_fd = BPF_FD_TO_INT(prog_fd),
+                                        .target_fd = BPF_FD_TO_U32(cg_fd),
+                                        .attach_bpf_fd = BPF_FD_TO_U32(prog_fd),
                                         .attach_type = type,
                                 });
 }
 
 inline int detachProgram(bpf_attach_type type, const BPF_FD_TYPE cg_fd) {
     return bpf(BPF_PROG_DETACH, {
-                                        .target_fd = BPF_FD_TO_INT(cg_fd),
+                                        .target_fd = BPF_FD_TO_U32(cg_fd),
                                         .attach_type = type,
                                 });
 }