Skip to content

Commit afafa6c

Browse files
committed
use the syscall instead of gettid()
1 parent 6b45ead commit afafa6c

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

Zend/zend_execute_API.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@
4545
#endif
4646
#if defined(ZTS) && defined(HAVE_TIMER_CREATE)
4747
#include <time.h>
48+
#include <sys/syscall.h>
4849
// Musl Libc defines this macro, glibc does not
4950
// According to "man 2 timer_create" this field should always be available, but it's not
5051
# ifndef sigev_notify_thread_id
5152
# define sigev_notify_thread_id _sigev_un._tid
5253
# 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
5854
#endif
5955

6056
ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data);
@@ -189,12 +185,12 @@ void init_executor(void) /* {{{ */
189185
sev.sigev_notify = SIGEV_THREAD_ID;
190186
sev.sigev_value.sival_ptr = &EG(timer);
191187
sev.sigev_signo = SIGIO;
192-
sev.sigev_notify_thread_id = gettid();
188+
sev.sigev_notify_thread_id = syscall(SYS_gettid);
193189

194190
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));
196192
# 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));
198194
# endif
199195
#endif
200196

@@ -425,9 +421,9 @@ void shutdown_executor(void) /* {{{ */
425421

426422
#if defined(ZTS) && defined(HAVE_TIMER_CREATE)
427423
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));
429425
# 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));
431427
# endif
432428
#endif
433429

@@ -1353,7 +1349,7 @@ ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */
13531349
static void zend_timeout_handler(int dummy, siginfo_t *si, void *uc) /* {{{ */
13541350
{
13551351
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));
13571353

13581354
return;
13591355
}
@@ -1470,12 +1466,12 @@ static void zend_set_timeout_ex(zend_long seconds, bool reset_signals) /* {{{ */
14701466
its.it_interval.tv_nsec = 0;
14711467

14721468
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));
14741470

14751471
return;
14761472
}
14771473
# 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);
14791475
# endif
14801476

14811477
if (reset_signals) {

0 commit comments

Comments
 (0)