com php-src: Determine thread ID on macos: ext/opcache/jit/zend _jit_perf_dump.c
| From: | Nikita Popov | Date: | Thu, 13 Jun 2019 07:59:42 +0000 |
| Subject: | com php-src: Determine thread ID on macos: ext/opcache/jit/zend _jit_perf_dump.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106752@lists.php.net to get a copy of this message | ||
Commit: 39034dbc67f2d74cc3e846189e7a440e771256c3
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 13 Jun 2019 09:55:09 +0200
Parents: af10245034e73b90105c2fb9652e34d938b81e14
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=39034dbc67f2d74cc3e846189e7a440e771256c3
Log:
Determine thread ID on macos
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.
Changed paths:
M ext/opcache/jit/zend_jit_perf_dump.c
Diff:
diff --git a/ext/opcache/jit/zend_jit_perf_dump.c b/ext/opcache/jit/zend_jit_perf_dump.c
index d46c5b0..d99c85a 100644
--- a/ext/opcache/jit/zend_jit_perf_dump.c
+++ b/ext/opcache/jit/zend_jit_perf_dump.c
@@ -24,10 +24,12 @@
#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);