17#ifdef ZEND_MAX_EXECUTION_TIMERS
24#include <sys/syscall.h>
27# include <pthread_np.h>
34#if __has_feature(memory_sanitizer)
35# include <sanitizer/msan_interface.h>
40# ifndef sigev_notify_thread_id
41# define sigev_notify_thread_id _sigev_un._tid
46# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_MONOTONIC
48# define ZEND_MAX_EXECUTION_TIMERS_CLOCK CLOCK_BOOTTIME
60 sev.sigev_notify = SIGEV_THREAD_ID;
61 sev.sigev_value.sival_ptr = &
EG(max_execution_timer_timer);
64 sev.sigev_notify_thread_id = pthread_getthreadid_np();
66 sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid);
69#if __has_feature(memory_sanitizer)
71 __msan_unpoison(&
EG(max_execution_timer_timer),
72 sizeof(
EG(max_execution_timer_timer)));
76 if (timer_create(ZEND_MAX_EXECUTION_TIMERS_CLOCK, &sev, &
EG(max_execution_timer_timer)) != 0) {
82# ifdef MAX_EXECUTION_TIMERS_DEBUG
83 fprintf(stderr,
"Timer %#jx created on thread %d\n", (uintmax_t)
EG(max_execution_timer_timer), sev.sigev_notify_thread_id);
86 sigaction(sev.sigev_signo,
NULL, &
EG(oldact));
97 timer_t timer =
EG(max_execution_timer_timer);
100 if (seconds < 0 || seconds > 999999999) {
104 struct itimerspec its;
105 its.it_value.tv_sec = seconds;
106 its.it_value.tv_nsec = its.it_interval.tv_sec = its.it_interval.tv_nsec = 0;
108# ifdef MAX_EXECUTION_TIMERS_DEBUG
109 fprintf(stderr,
"Setting timer %#jx on thread %d (%ld seconds)...\n", (uintmax_t) timer, (pid_t) syscall(SYS_gettid), seconds);
112 if (timer_settime(timer, 0, &its,
NULL) != 0) {
121 if (
EG(pid) != getpid()) {
127 timer_t timer =
EG(max_execution_timer_timer);
129# ifdef MAX_EXECUTION_TIMERS_DEBUG
130 fprintf(stderr,
"Deleting timer %#jx on thread %d...\n", (uintmax_t) timer, (pid_t) syscall(SYS_gettid));
133 int err = timer_delete(timer);
fprintf($stream, string $format, mixed ... $values)
ZEND_API ZEND_COLD ZEND_NORETURN void zend_strerror_noreturn(int type, int errn, const char *message)
#define zend_max_execution_timer_shutdown()
#define zend_max_execution_timer_settime(seconds)
#define zend_max_execution_timer_init()