21#ifndef ZEND_PORTABILITY_H
22#define ZEND_PORTABILITY_H
25#define BEGIN_EXTERN_C() extern "C" {
26#define END_EXTERN_C() }
28#define BEGIN_EXTERN_C()
38# define ZEND_PATHS_SEPARATOR ';'
39#elif defined(__riscos__)
40# include <zend_config.h>
41# define ZEND_PATHS_SEPARATOR ';'
43# include <zend_config.h>
44# define ZEND_PATHS_SEPARATOR ':'
47#include "../TSRM/TSRM.h"
66#if defined(ZEND_WIN32) && !defined(__clang__)
74# define ZEND_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
76# define ZEND_GCC_VERSION 0
80#ifndef __has_attribute
81# define __has_attribute(x) 0
84# define __has_builtin(x) 0
87# define __has_feature(x) 0
90#if defined(ZEND_WIN32) && !defined(__clang__)
91# define ZEND_ASSUME(c) __assume(c)
92#elif defined(__clang__) && __has_builtin(__builtin_assume)
93# pragma clang diagnostic ignored "-Wassume"
94# define ZEND_ASSUME(c) __builtin_assume(c)
95#elif defined(PHP_HAVE_BUILTIN_UNREACHABLE) && defined(PHP_HAVE_BUILTIN_EXPECT)
96# define ZEND_ASSUME(c) do { \
97 if (__builtin_expect(!(c), 0)) __builtin_unreachable(); \
100# define ZEND_ASSUME(c)
104# define ZEND_ASSERT(c) assert(c)
106# define ZEND_ASSERT(c) ZEND_ASSUME(c)
109#ifdef PHP_HAVE_BUILTIN_UNREACHABLE
110# define _ZEND_UNREACHABLE() __builtin_unreachable()
112# define _ZEND_UNREACHABLE() ZEND_ASSUME(0)
116# define ZEND_UNREACHABLE() do {ZEND_ASSERT(0); _ZEND_UNREACHABLE();} while (0)
118# define ZEND_UNREACHABLE() _ZEND_UNREACHABLE()
122#if defined(__GNUC__) && __GNUC__ >= 7
123# define ZEND_FALLTHROUGH __attribute__((__fallthrough__))
125# define ZEND_FALLTHROUGH ((void)0)
130#define EMPTY_SWITCH_DEFAULT_CASE() default: ZEND_UNREACHABLE(); break;
132#if defined(__GNUC__) && __GNUC__ >= 4
133# define ZEND_IGNORE_VALUE(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
135# define ZEND_IGNORE_VALUE(x) ((void) (x))
138#define zend_quiet_write(...) ZEND_IGNORE_VALUE(write(__VA_ARGS__))
142#if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)
144# if __has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
145# define __SANITIZE_ADDRESS__
153# define RTLD_GLOBAL 0
156# ifdef PHP_USE_RTLD_NOW
157# define PHP_RTLD_MODE RTLD_NOW
159# define PHP_RTLD_MODE RTLD_LAZY
162# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
163# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
164# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer)
165# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
167# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
169# define DL_UNLOAD dlclose
170# if defined(DLSYM_NEEDS_UNDERSCORE)
171# define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
173# define DL_FETCH_SYMBOL dlsym
175# define DL_ERROR dlerror
176# define DL_HANDLE void *
177# define ZEND_EXTENSIONS_SUPPORT 1
178#elif defined(ZEND_WIN32)
179# define DL_LOAD(libname) LoadLibrary(libname)
180# define DL_FETCH_SYMBOL GetProcAddress
181# define DL_UNLOAD FreeLibrary
182# define DL_HANDLE HMODULE
183# define ZEND_EXTENSIONS_SUPPORT 1
185# define DL_HANDLE void *
186# define ZEND_EXTENSIONS_SUPPORT 0
189#if defined(HAVE_ALLOCA_H) && !defined(_ALLOCA_H)
194# ifndef HAVE_ALLOCA_H
205#if !ZEND_DEBUG && (defined(HAVE_ALLOCA) || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(HPUX)) && !defined(__APPLE__)
206# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
207# define ALLOCA_FLAG(name) \
209# define SET_ALLOCA_FLAG(name) \
211# define do_alloca_ex(size, limit, use_heap) \
212 ((use_heap = (UNEXPECTED((size) > (limit)))) ? emalloc(size) : alloca(size))
213# define do_alloca(size, use_heap) \
214 do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap)
215# define free_alloca(p, use_heap) \
216 do { if (UNEXPECTED(use_heap)) efree(p); } while (0)
218# define ALLOCA_FLAG(name)
219# define SET_ALLOCA_FLAG(name)
220# define do_alloca(p, use_heap) emalloc(p)
221# define free_alloca(p, use_heap) efree(p)
224#if ZEND_GCC_VERSION >= 2096 || __has_attribute(__malloc__)
225# define ZEND_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
226#elif defined(ZEND_WIN32)
227# define ZEND_ATTRIBUTE_MALLOC __declspec(allocator) __declspec(restrict)
229# define ZEND_ATTRIBUTE_MALLOC
232#if ZEND_GCC_VERSION >= 4003 || __has_attribute(alloc_size)
233# define ZEND_ATTRIBUTE_ALLOC_SIZE(X) __attribute__ ((alloc_size(X)))
234# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y) __attribute__ ((alloc_size(X,Y)))
236# define ZEND_ATTRIBUTE_ALLOC_SIZE(X)
237# define ZEND_ATTRIBUTE_ALLOC_SIZE2(X,Y)
240#if ZEND_GCC_VERSION >= 3000
241# define ZEND_ATTRIBUTE_CONST __attribute__((const))
243# define ZEND_ATTRIBUTE_CONST
246#if ZEND_GCC_VERSION >= 2007 || __has_attribute(format)
247# define ZEND_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
249# define ZEND_ATTRIBUTE_FORMAT(type, idx, first)
252#if (ZEND_GCC_VERSION >= 3001 && !defined(__INTEL_COMPILER)) || __has_attribute(format)
253# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
255# define ZEND_ATTRIBUTE_PTR_FORMAT(type, idx, first)
258#if ZEND_GCC_VERSION >= 3001 || __has_attribute(deprecated)
259# define ZEND_ATTRIBUTE_DEPRECATED __attribute__((deprecated))
260#elif defined(ZEND_WIN32)
261# define ZEND_ATTRIBUTE_DEPRECATED __declspec(deprecated)
263# define ZEND_ATTRIBUTE_DEPRECATED
266#if ZEND_GCC_VERSION >= 4003 || __has_attribute(unused)
267# define ZEND_ATTRIBUTE_UNUSED __attribute__((unused))
269# define ZEND_ATTRIBUTE_UNUSED
272#if ZEND_GCC_VERSION >= 3003 || __has_attribute(nonnull)
274# define ZEND_ATTRIBUTE_NONNULL __attribute__((nonnull))
276# define ZEND_ATTRIBUTE_NONNULL_ARGS(...) __attribute__((nonnull(__VA_ARGS__)))
278# define ZEND_ATTRIBUTE_NONNULL
279# define ZEND_ATTRIBUTE_NONNULL_ARGS(...)
282#if defined(__GNUC__) && ZEND_GCC_VERSION >= 4003
283# define ZEND_COLD __attribute__((cold))
285# define ZEND_OPT_SIZE __attribute__((optimize("Os")))
286# define ZEND_OPT_SPEED __attribute__((optimize("Ofast")))
288# define ZEND_OPT_SIZE
289# define ZEND_OPT_SPEED
293# define ZEND_OPT_SIZE
294# define ZEND_OPT_SPEED
297#if defined(__GNUC__) && ZEND_GCC_VERSION >= 5000
298# define ZEND_ATTRIBUTE_UNUSED_LABEL __attribute__((unused));
299# define ZEND_ATTRIBUTE_COLD_LABEL __attribute__((cold));
301# define ZEND_ATTRIBUTE_UNUSED_LABEL
302# define ZEND_ATTRIBUTE_COLD_LABEL
305#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004 && defined(__i386__)
306# define ZEND_FASTCALL __attribute__((fastcall))
307#elif defined(_MSC_VER) && defined(_M_IX86) && _MSC_VER == 1700
308# define ZEND_FASTCALL __fastcall
309#elif defined(_MSC_VER) && _MSC_VER >= 1800
310# define ZEND_FASTCALL __vectorcall
312# define ZEND_FASTCALL
315#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(__APPLE__) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn)
316# define HAVE_NORETURN
317# define ZEND_NORETURN __attribute__((noreturn))
318#elif defined(ZEND_WIN32)
319# define HAVE_NORETURN
320# define ZEND_NORETURN __declspec(noreturn)
322# define ZEND_NORETURN
325#if __has_attribute(force_align_arg_pointer)
326# define ZEND_STACK_ALIGNED __attribute__((force_align_arg_pointer))
328# define ZEND_STACK_ALIGNED
331#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(__APPLE__) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__))
332# define HAVE_NORETURN_ALIAS
333# define HAVE_ATTRIBUTE_WEAK
336#if ZEND_GCC_VERSION >= 3001 || __has_builtin(__builtin_constant_p)
337# define HAVE_BUILTIN_CONSTANT_P
340#if __has_attribute(element_count)
341#define ZEND_ELEMENT_COUNT(m) __attribute__((element_count(m)))
342#elif __has_attribute(counted_by)
343#define ZEND_ELEMENT_COUNT(m) __attribute__((counted_by(m)))
345#define ZEND_ELEMENT_COUNT(m)
348#ifdef HAVE_BUILTIN_CONSTANT_P
349# define ZEND_CONST_COND(_condition, _default) \
350 (__builtin_constant_p(_condition) ? (_condition) : (_default))
352# define ZEND_CONST_COND(_condition, _default) \
356#if ZEND_DEBUG || defined(ZEND_WIN32_NEVER_INLINE)
357# define zend_always_inline inline
358# define zend_never_inline
360# if defined(__GNUC__)
362# define zend_always_inline inline __attribute__((always_inline))
363# define zend_never_inline __attribute__((noinline))
365# define zend_always_inline inline
366# define zend_never_inline
368# elif defined(_MSC_VER)
369# define zend_always_inline __forceinline
370# define zend_never_inline __declspec(noinline)
372# if __has_attribute(always_inline)
373# define zend_always_inline inline __attribute__((always_inline))
375# define zend_always_inline inline
377# if __has_attribute(noinline)
378# define zend_never_inline __attribute__((noinline))
380# define zend_never_inline
385#ifdef PHP_HAVE_BUILTIN_EXPECT
386# define EXPECTED(condition) __builtin_expect(!!(condition), 1)
387# define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
389# define EXPECTED(condition) (condition)
390# define UNEXPECTED(condition) (condition)
394# define XtOffsetOf(s_type, field) offsetof(s_type, field)
398# define SETJMP(a) sigsetjmp(a, 0)
399# define LONGJMP(a,b) siglongjmp(a, b)
400# define JMP_BUF sigjmp_buf
402# define SETJMP(a) setjmp(a)
403# define LONGJMP(a,b) longjmp(a, b)
404# define JMP_BUF jmp_buf
408# define ZEND_FILE_LINE_D const char *__zend_filename, const uint32_t __zend_lineno
409# define ZEND_FILE_LINE_DC , ZEND_FILE_LINE_D
410# define ZEND_FILE_LINE_ORIG_D const char *__zend_orig_filename, const uint32_t __zend_orig_lineno
411# define ZEND_FILE_LINE_ORIG_DC , ZEND_FILE_LINE_ORIG_D
412# define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
413# define ZEND_FILE_LINE_RELAY_CC , ZEND_FILE_LINE_RELAY_C
414# define ZEND_FILE_LINE_C __FILE__, __LINE__
415# define ZEND_FILE_LINE_CC , ZEND_FILE_LINE_C
416# define ZEND_FILE_LINE_EMPTY_C NULL, 0
417# define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C
418# define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno
419# define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C
421# define ZEND_FILE_LINE_D void
422# define ZEND_FILE_LINE_DC
423# define ZEND_FILE_LINE_ORIG_D void
424# define ZEND_FILE_LINE_ORIG_DC
425# define ZEND_FILE_LINE_RELAY_C
426# define ZEND_FILE_LINE_RELAY_CC
427# define ZEND_FILE_LINE_C
428# define ZEND_FILE_LINE_CC
429# define ZEND_FILE_LINE_EMPTY_C
430# define ZEND_FILE_LINE_EMPTY_CC
431# define ZEND_FILE_LINE_ORIG_RELAY_C
432# define ZEND_FILE_LINE_ORIG_RELAY_CC
436# define Z_DBG(expr) (expr)
448# define LONG_MAX 2147483647L
452# define LONG_MIN (- LONG_MAX - 1)
455#define MAX_LENGTH_OF_DOUBLE 32
459#define MAX(a, b) (((a)>(b))?(a):(b))
460#define MIN(a, b) (((a)<(b))?(a):(b))
462#define ZEND_BIT_TEST(bits, bit) \
463 (((bits)[(bit) / (sizeof((bits)[0])*8)] >> ((bit) & (sizeof((bits)[0])*8-1))) & 1)
465#define ZEND_INFINITY INFINITY
469#if defined(__cplusplus) && __cplusplus >= 201103L
473# define zend_isnan std::isnan
474# define zend_isinf std::isinf
475# define zend_finite std::isfinite
478# define zend_isnan(a) isnan(a)
479# define zend_isinf(a) isinf(a)
480# define zend_finite(a) isfinite(a)
483#define ZEND_STRL(str) (str), (sizeof(str)-1)
484#define ZEND_STRS(str) (str), (sizeof(str))
485#define ZEND_NORMALIZE_BOOL(n) \
486 ((n) ? (((n)<0) ? -1 : 1) : 0)
487#define ZEND_TRUTH(x) ((x) ? 1 : 0)
488#define ZEND_LOG_XOR(a, b) (ZEND_TRUTH(a) ^ ZEND_TRUTH(b))
494#define ZEND_THREEWAY_COMPARE(a, b) ((a) == (b) ? 0 : ((a) < (b) ? -1 : 1))
496#define ZEND_MAX_RESERVED_RESOURCES 6
502#define ZEND_SECURE_ZERO(var, size) RtlSecureZeroMemory((var), (size))
504#define ZEND_SECURE_ZERO(var, size) explicit_bzero((var), (size))
509#define ZEND_VALID_SOCKET(sock) (INVALID_SOCKET != (sock))
511#define ZEND_VALID_SOCKET(sock) ((sock) >= 0)
518#if __has_feature(memory_sanitizer) || __has_feature(thread_sanitizer) || \
519 __has_feature(dataflow_sanitizer)
520# undef HAVE_FUNC_ATTRIBUTE_IFUNC
525#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) && \
526 defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && defined(PHP_HAVE_BUILTIN_CPU_INIT)
527# define ZEND_INTRIN_HAVE_IFUNC_TARGET 1
530#if (defined(__i386__) || defined(__x86_64__))
531# if defined(HAVE_TMMINTRIN_H)
532# define PHP_HAVE_SSSE3
535# if defined(HAVE_NMMINTRIN_H)
536# define PHP_HAVE_SSE4_2
539# if defined(HAVE_WMMINTRIN_H)
540# define PHP_HAVE_PCLMUL
547# if defined(HAVE_IMMINTRIN_H) && \
548 (defined(__llvm__) || defined(__clang__) || (defined(__GNUC__) && ZEND_GCC_VERSION >= 4009))
549# define PHP_HAVE_AVX2
555# define ZEND_INTRIN_SSSE3_NATIVE 1
556#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_SSSE3)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
558# define ZEND_INTRIN_SSSE3_RESOLVER 1
562#if defined(ZEND_INTRIN_SSSE3_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
563# define ZEND_INTRIN_SSSE3_FUNC_PROTO 1
564#elif defined(ZEND_INTRIN_SSSE3_RESOLVER)
565# define ZEND_INTRIN_SSSE3_FUNC_PTR 1
568#ifdef ZEND_INTRIN_SSSE3_RESOLVER
569# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
570# define ZEND_INTRIN_SSSE3_FUNC_DECL(func) ZEND_API func __attribute__((target("ssse3")))
572# define ZEND_INTRIN_SSSE3_FUNC_DECL(func) func
575# define ZEND_INTRIN_SSSE3_FUNC_DECL(func)
580# define ZEND_INTRIN_SSE4_2_NATIVE 1
581#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_SSE4_2)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
583# define ZEND_INTRIN_SSE4_2_RESOLVER 1
587#if defined(ZEND_INTRIN_SSE4_2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
588# define ZEND_INTRIN_SSE4_2_FUNC_PROTO 1
589#elif defined(ZEND_INTRIN_SSE4_2_RESOLVER)
590# define ZEND_INTRIN_SSE4_2_FUNC_PTR 1
593#ifdef ZEND_INTRIN_SSE4_2_RESOLVER
594# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
595# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) ZEND_API func __attribute__((target("sse4.2")))
597# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func) func
600# define ZEND_INTRIN_SSE4_2_FUNC_DECL(func)
605# define ZEND_INTRIN_PCLMUL_NATIVE 1
606#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_PCLMUL)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
608# define ZEND_INTRIN_PCLMUL_RESOLVER 1
612#if defined(ZEND_INTRIN_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
614# define ZEND_INTRIN_PCLMUL_FUNC_PROTO 1
615#elif defined(ZEND_INTRIN_PCLMUL_RESOLVER)
616# define ZEND_INTRIN_PCLMUL_FUNC_PTR 1
619#ifdef ZEND_INTRIN_PCLMUL_RESOLVER
620# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
621# define ZEND_INTRIN_PCLMUL_FUNC_DECL(func) ZEND_API func __attribute__((target("pclmul")))
623# define ZEND_INTRIN_PCLMUL_FUNC_DECL(func) func
626# define ZEND_INTRIN_PCLMUL_FUNC_DECL(func)
629#if defined(ZEND_INTRIN_SSE4_2_NATIVE) && defined(ZEND_INTRIN_PCLMUL_NATIVE)
631# define ZEND_INTRIN_SSE4_2_PCLMUL_NATIVE 1
632#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_SSE4_2) && defined(PHP_HAVE_PCLMUL)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
634# define ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER 1
638#if defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET) && (!defined(__GNUC__) || (ZEND_GCC_VERSION >= 9000))
640# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PROTO 1
641#elif defined(ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER)
642# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_PTR 1
645#ifdef ZEND_INTRIN_SSE4_2_PCLMUL_RESOLVER
646# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
647# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_DECL(func) ZEND_API func __attribute__((target("sse4.2,pclmul")))
649# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_DECL(func) func
652# define ZEND_INTRIN_SSE4_2_PCLMUL_FUNC_DECL(func)
656# define ZEND_INTRIN_AVX2_NATIVE 1
657#elif (defined(HAVE_FUNC_ATTRIBUTE_TARGET) && defined(PHP_HAVE_AVX2)) || (defined(ZEND_WIN32) && (!defined(_M_ARM64)))
658# define ZEND_INTRIN_AVX2_RESOLVER 1
662#if defined(ZEND_INTRIN_AVX2_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
663# define ZEND_INTRIN_AVX2_FUNC_PROTO 1
664#elif defined(ZEND_INTRIN_AVX2_RESOLVER)
665# define ZEND_INTRIN_AVX2_FUNC_PTR 1
668#ifdef ZEND_INTRIN_AVX2_RESOLVER
669# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
670# define ZEND_INTRIN_AVX2_FUNC_DECL(func) ZEND_API func __attribute__((target("avx2")))
672# define ZEND_INTRIN_AVX2_FUNC_DECL(func) func
675# define ZEND_INTRIN_AVX2_FUNC_DECL(func)
678#if defined(PHP_HAVE_AVX512_SUPPORTS) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) || defined(ZEND_WIN32)
679#define ZEND_INTRIN_AVX512_RESOLVER 1
682#if defined(ZEND_INTRIN_AVX512_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
683# define ZEND_INTRIN_AVX512_FUNC_PROTO 1
684#elif defined(ZEND_INTRIN_AVX512_RESOLVER)
685# define ZEND_INTRIN_AVX512_FUNC_PTR 1
688#ifdef ZEND_INTRIN_AVX512_RESOLVER
689# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
690# define ZEND_INTRIN_AVX512_FUNC_DECL(func) ZEND_API func __attribute__((target("avx512f,avx512cd,avx512vl,avx512dq,avx512bw")))
692# define ZEND_INTRIN_AVX512_FUNC_DECL(func) func
695# define ZEND_INTRIN_AVX512_FUNC_DECL(func)
698#if defined(PHP_HAVE_AVX512_VBMI_SUPPORTS) && defined(HAVE_FUNC_ATTRIBUTE_TARGET)
699#define ZEND_INTRIN_AVX512_VBMI_RESOLVER 1
702#if defined(ZEND_INTRIN_AVX512_VBMI_RESOLVER) && defined(ZEND_INTRIN_HAVE_IFUNC_TARGET)
703# define ZEND_INTRIN_AVX512_VBMI_FUNC_PROTO 1
704#elif defined(ZEND_INTRIN_AVX512_VBMI_RESOLVER)
705# define ZEND_INTRIN_AVX512_VBMI_FUNC_PTR 1
708#ifdef ZEND_INTRIN_AVX512_VBMI_RESOLVER
709# ifdef HAVE_FUNC_ATTRIBUTE_TARGET
710# define ZEND_INTRIN_AVX512_VBMI_FUNC_DECL(func) ZEND_API func __attribute__((target("avx512f,avx512cd,avx512vl,avx512dq,avx512bw,avx512vbmi")))
712# define ZEND_INTRIN_AVX512_VBMI_FUNC_DECL(func) func
715# define ZEND_INTRIN_AVX512_VBMI_FUNC_DECL(func)
721# define ZEND_SET_ALIGNED(alignment, decl) __declspec(align(alignment)) decl
722#elif defined(HAVE_ATTRIBUTE_ALIGNED)
723# define ZEND_SET_ALIGNED(alignment, decl) decl __attribute__ ((__aligned__ (alignment)))
725# define ZEND_SET_ALIGNED(alignment, decl) decl
728#define ZEND_SLIDE_TO_ALIGNED(alignment, ptr) (((uintptr_t)(ptr) + ((alignment)-1)) & ~((alignment)-1))
729#define ZEND_SLIDE_TO_ALIGNED16(ptr) ZEND_SLIDE_TO_ALIGNED(Z_UL(16), ptr)
732# define _ZEND_EXPAND_VA(a) a
733# define ZEND_EXPAND_VA(code) _ZEND_EXPAND_VA(code)
735# define ZEND_EXPAND_VA(code) code
739#if defined(__i386__) || (defined(_WIN32) && !defined(_WIN64))
740# define ZEND_PREFER_RELOAD
743#if defined(ZEND_WIN32) && defined(_DEBUG)
744# define ZEND_IGNORE_LEAKS_BEGIN() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~_CRTDBG_ALLOC_MEM_DF)
745# define ZEND_IGNORE_LEAKS_END() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF)
747# define ZEND_IGNORE_LEAKS_BEGIN()
748# define ZEND_IGNORE_LEAKS_END()
753# define ZEND_VOIDP(ptr) ((void *) ptr)
755# define ZEND_VOIDP(ptr) (ptr)
758#if __has_attribute(__indirect_return__)
759# define ZEND_INDIRECT_RETURN __attribute__((__indirect_return__))
761# define ZEND_INDIRECT_RETURN
764#define __ZEND_DO_PRAGMA(x) _Pragma(#x)
765#define _ZEND_DO_PRAGMA(x) __ZEND_DO_PRAGMA(x)
766#if defined(__clang__)
767# define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
768 _Pragma("clang diagnostic push") \
769 _ZEND_DO_PRAGMA(clang diagnostic ignored warning)
770# define ZEND_DIAGNOSTIC_IGNORED_END \
771 _Pragma("clang diagnostic pop")
772#elif defined(__GNUC__)
773# define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
774 _Pragma("GCC diagnostic push") \
775 _ZEND_DO_PRAGMA(GCC diagnostic ignored warning)
776# define ZEND_DIAGNOSTIC_IGNORED_END \
777 _Pragma("GCC diagnostic pop")
779# define ZEND_DIAGNOSTIC_IGNORED_START(warning)
780# define ZEND_DIAGNOSTIC_IGNORED_END
784#define ZEND_CGG_DIAGNOSTIC_IGNORED_START ZEND_DIAGNOSTIC_IGNORED_START
786#define ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
788#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
789# define ZEND_STATIC_ASSERT(c, m) _Static_assert((c), m)
791# define ZEND_STATIC_ASSERT(c, m)
794#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
796#elif (defined(__cplusplus) && __cplusplus >= 201103L)
821# define ZEND_BYTES_SWAP32(u) _byteswap_ulong(u)
822# define ZEND_BYTES_SWAP64(u) _byteswap_uint64(u)
823#elif defined(HAVE_BYTESWAP_H)
824# include <byteswap.h>
825# define ZEND_BYTES_SWAP32(u) bswap_32(u)
826# define ZEND_BYTES_SWAP64(u) bswap_64(u)
827#elif defined(HAVE_SYS_BSWAP_H)
828# include <sys/bswap.h>
829# define ZEND_BYTES_SWAP32(u) bswap32(u)
830# define ZEND_BYTES_SWAP64(u) bswap64(u)
831#elif defined(__GNUC__)
832# define ZEND_BYTES_SWAP32(u) __builtin_bswap32(u)
833# define ZEND_BYTES_SWAP64(u) __builtin_bswap64(u)
834#elif defined(__has_builtin)
835# if __has_builtin(__builtin_bswap32)
836# define ZEND_BYTES_SWAP32(u) __builtin_bswap32(u)
838# if __has_builtin(__builtin_bswap64)
839# define ZEND_BYTES_SWAP64(u) __builtin_bswap64(u)
843#ifndef ZEND_BYTES_SWAP32
846 return (((
u & 0xff000000) >> 24)
847 | ((
u & 0x00ff0000) >> 8)
848 | ((
u & 0x0000ff00) << 8)
849 | ((
u & 0x000000ff) << 24));
852#ifndef ZEND_BYTES_SWAP64
855 return (((
u & 0xff00000000000000ULL) >> 56)
856 | ((
u & 0x00ff000000000000ULL) >> 40)
857 | ((
u & 0x0000ff0000000000ULL) >> 24)
858 | ((
u & 0x000000ff00000000ULL) >> 8)
859 | ((
u & 0x00000000ff000000ULL) << 8)
860 | ((
u & 0x0000000000ff0000ULL) << 24)
861 | ((
u & 0x000000000000ff00ULL) << 40)
862 | ((
u & 0x00000000000000ffULL) << 56));
870# define ZEND_OPCACHE_SHM_REATTACHMENT 1
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
#define zend_always_inline