File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 26
26
27
27
#include "zend.h"
28
28
#include "zend_globals.h"
29
+ #include "zend_portability.h"
29
30
30
31
// Musl Libc defines this macro, glibc does not
31
32
// According to "man 2 timer_create" this field should always be available, but it's not: https://sourceware.org/bugzilla/show_bug.cgi?id=27417
32
33
# ifndef sigev_notify_thread_id
33
34
# define sigev_notify_thread_id _sigev_un._tid
34
35
# endif
35
36
36
- _Thread_local int is_handler_set = 0 ; // whether we have set up a timer in this thread
37
+ ZEND_THREAD_LOCAL bool is_handler_set = false ; // whether we have set up a timer in this thread
37
38
38
39
ZEND_API void zend_max_execution_timer_init (void ) /* {{{ */
39
40
{
Original file line number Diff line number Diff line change @@ -307,6 +307,25 @@ char *alloca();
307
307
# define ZEND_NORETURN
308
308
#endif
309
309
310
+ #if !defined(__STDC_NO_THREADS__)
311
+ # if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9))
312
+ /* GCC supported _Thread_local keyword since version 4.8.0 */
313
+ # define ZEND_THREAD_LOCAL
314
+ # else
315
+ # define ZEND_THREAD_LOCAL _Thread_local
316
+ # endif
317
+ #else
318
+ # if defined(_MSC_VER) && _MSC_VER >= 1900
319
+ # define ZEND_THREAD_LOCAL __declspec (thread)
320
+ # elif defined(__GNUC__) || defined(__clang__)
321
+ # define ZEND_THREAD_LOCAL __thread
322
+ # else
323
+ /* TODO: add support for more compilers */
324
+ # define ZEND_THREAD_LOCAL
325
+ # error "Define thread local storage for your compiler"
326
+ # endif
327
+ #endif
328
+
310
329
#if __has_attribute(force_align_arg_pointer)
311
330
# define ZEND_STACK_ALIGNED __attribute__ ((force_align_arg_pointer))
312
331
#else
You can’t perform that action at this time.
0 commit comments