]> granicus.if.org Git - php/commitdiff
Determine thread ID on macos
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 13 Jun 2019 07:55:09 +0000 (09:55 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 13 Jun 2019 07:59:42 +0000 (09:59 +0200)
Also initialize the variable to 0 -- I don't think we really care
if this is not determine on some platform, but it should at least
not be uninitialized.

ext/opcache/jit/zend_jit_perf_dump.c

index d46c5b0091077cec111764cfd5e1eca9ffbc5264..d99c85a9a0fe6d623f394f96af86e1dece0444bc 100644 (file)
 #include <sys/mman.h>
 #include <sys/syscall.h>
 
-#if defined(__FreeBSD__)
-#include <sys/thr.h>
+#if defined(__darwin__)
+# include <pthread.h>
+#elif defined(__FreeBSD__)
+# include <sys/thr.h>
 #elif defined(__NetBSD__)
-#include <lwp.h>
+# include <lwp.h>
 #endif
 
 #include "zend_elf.h"
@@ -177,9 +179,13 @@ static void zend_jit_perf_jitdump_register(const char *name, void *start, size_t
                static uint64_t id = 1;
                zend_perf_jitdump_load_record rec;
                size_t len = strlen(name);
-               uint32_t thread_id;
+               uint32_t thread_id = 0;
 #if defined(__linux__)
                thread_id = syscall(SYS_gettid);
+#elif defined(__darwin__)
+               uint64_t thread_id_u64;
+               pthread_threadid_np(NULL, &thread_id_u64);
+               thread_id = (uint32_t) thread_id_u64;
 #elif defined(__FreeBSD__)
                long tid;
                thr_self(&tid);