|
45 | 45 | #endif
|
46 | 46 | #if defined(ZTS) && defined(HAVE_TIMER_CREATE)
|
47 | 47 | #include <time.h>
|
| 48 | +#include <sys/syscall.h> |
48 | 49 | // Musl Libc defines this macro, glibc does not
|
49 | 50 | // According to "man 2 timer_create" this field should always be available, but it's not
|
50 | 51 | # ifndef sigev_notify_thread_id
|
51 | 52 | # define sigev_notify_thread_id _sigev_un._tid
|
52 | 53 | # endif
|
53 |
| -// Old versions of glibc miss gettid() |
54 |
| -# if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30 |
55 |
| -# include <sys/syscall.h> |
56 |
| -# define gettid() syscall(SYS_gettid) |
57 |
| -# endif |
58 | 54 | #endif
|
59 | 55 |
|
60 | 56 | ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
|
@@ -189,12 +185,12 @@ void init_executor(void) /* {{{ */
|
189 | 185 | sev.sigev_notify = SIGEV_THREAD_ID;
|
190 | 186 | sev.sigev_value.sival_ptr = &EG(timer);
|
191 | 187 | sev.sigev_signo = SIGIO;
|
192 |
| - sev.sigev_notify_thread_id = gettid(); |
| 188 | + sev.sigev_notify_thread_id = syscall(SYS_gettid); |
193 | 189 |
|
194 | 190 | if (timer_create(CLOCK_THREAD_CPUTIME_ID, &sev, &EG(timer)) != 0)
|
195 |
| - fprintf(stderr, "error %d while creating timer on thread %d\n", errno, gettid()); |
| 191 | + fprintf(stderr, "error %d while creating timer on thread %d\n", errno, syscall(SYS_gettid)); |
196 | 192 | # ifdef TIMER_DEBUG
|
197 |
| - else fprintf(stderr, "timer created on thread %d\n", gettid()); |
| 193 | + else fprintf(stderr, "timer created on thread %d\n", syscall(SYS_gettid)); |
198 | 194 | # endif
|
199 | 195 | #endif
|
200 | 196 |
|
@@ -425,9 +421,9 @@ void shutdown_executor(void) /* {{{ */
|
425 | 421 |
|
426 | 422 | #if defined(ZTS) && defined(HAVE_TIMER_CREATE)
|
427 | 423 | if (timer_delete(EG(timer)) != 0)
|
428 |
| - fprintf(stderr, "error %d while deleting timer on thread %d\n", errno, gettid()); |
| 424 | + fprintf(stderr, "error %d while deleting timer on thread %d\n", errno, syscall(SYS_gettid)); |
429 | 425 | # ifdef TIMER_DEBUG
|
430 |
| - else fprintf(stderr, "timer deleted on thread %d\n", gettid()); |
| 426 | + else fprintf(stderr, "timer deleted on thread %d\n", syscall(SYS_gettid)); |
431 | 427 | # endif
|
432 | 428 | #endif
|
433 | 429 |
|
@@ -1353,7 +1349,7 @@ ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */
|
1353 | 1349 | static void zend_timeout_handler(int dummy, siginfo_t *si, void *uc) /* {{{ */
|
1354 | 1350 | {
|
1355 | 1351 | if (si->si_value.sival_ptr != &EG(timer)) {
|
1356 |
| - fprintf(stderr, "ignoring timeout signal SIGIO received on thread %d\n", gettid()); |
| 1352 | + fprintf(stderr, "ignoring timeout signal SIGIO received on thread %d\n", syscall(SYS_gettid)); |
1357 | 1353 |
|
1358 | 1354 | return;
|
1359 | 1355 | }
|
@@ -1470,12 +1466,12 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
|
1470 | 1466 | its.it_interval.tv_nsec = 0;
|
1471 | 1467 |
|
1472 | 1468 | if (timer_settime(timer, 0, &its, NULL) != 0) {
|
1473 |
| - fprintf(stderr, "unable to set timer on thread %d\n", gettid()); |
| 1469 | + fprintf(stderr, "unable to set timer on thread %d\n", syscall(SYS_gettid)); |
1474 | 1470 |
|
1475 | 1471 | return;
|
1476 | 1472 | }
|
1477 | 1473 | # ifdef TIMER_DEBUG
|
1478 |
| - else fprintf(stderr, "timer set on thread %d (%ld seconds)\n", gettid(), seconds); |
| 1474 | + else fprintf(stderr, "timer set on thread %d (%ld seconds)\n", syscall(SYS_gettid), seconds); |
1479 | 1475 | # endif
|
1480 | 1476 |
|
1481 | 1477 | if (reset_signals) {
|
|
0 commit comments