21#ifndef ZEND_OPERATORS_H
22#define ZEND_OPERATORS_H
38# if __has_feature(undefined_behavior_sanitizer) && defined(__FreeBSD__) && defined(__clang__)
39# pragma clang attribute push (__attribute__((no_sanitize("undefined"))), apply_to=function)
42# if __has_feature(undefined_behavior_sanitizer) && defined(__FreeBSD__) && defined(__clang__)
43# pragma clang attribute pop
52#define LONG_SIGN_MASK ZEND_LONG_MIN
106 double *
dval,
bool allow_errors,
int *oflow_info,
bool *trailing_data);
111#if SIZEOF_ZEND_LONG == 4
112# define ZEND_DOUBLE_FITS_LONG(d) (!((d) > (double)ZEND_LONG_MAX || (d) < (double)ZEND_LONG_MIN))
115# define ZEND_DOUBLE_FITS_LONG(d) (!((d) >= (double)ZEND_LONG_MAX || (d) < (double)ZEND_LONG_MIN))
143 return (
double)l == d;
152 if (!zend_is_long_compatible(d, l)) {
158#define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
159#define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
162 double *
dval,
bool allow_errors,
int *oflow_info,
bool *trailing_data)
171 return is_numeric_string_ex(str, length, lval,
dval, allow_errors,
NULL,
NULL);
177zend_memnstr(
const char *haystack,
const char *needle,
size_t needle_len,
const char *
end)
179 const char *
p = haystack;
184 if (needle_len == 1) {
185 return (
const char *)memchr(
p, *needle, (
end-
p));
190 off_s = (size_t)(
end -
p);
192 if (needle_len > off_s) {
196 if (
EXPECTED(off_s < 1024 || needle_len < 9)) {
197 const char ne = needle[needle_len-1];
201 if ((
p = (
const char *)memchr(
p, *needle, (
end-
p+1)))) {
202 if (ne ==
p[needle_len-1] && !memcmp(needle+1,
p+1, needle_len-2)) {
219#if defined(HAVE_MEMRCHR) && !defined(i386)
221 return (
const void*)memrchr(
s, c,
n);
223 const unsigned char *e;
228 for (e = (
const unsigned char *)
s +
n - 1; e >= (
const unsigned char *)
s; e--) {
229 if (*e == (
unsigned char)c) {
230 return (
const void *)e;
239zend_memnrstr(
const char *haystack,
const char *needle,
size_t needle_len,
const char *
end)
245 if (needle_len == 0) {
249 if (needle_len == 1) {
250 return (
const char *)zend_memrchr(haystack, *needle, (
p - haystack));
253 off_p =
end - haystack;
254 off_s = (off_p > 0) ? (
size_t)off_p : 0;
256 if (needle_len > off_s) {
260 if (
EXPECTED(off_s < 1024 || needle_len < 3)) {
261 const char ne = needle[needle_len-1];
265 p = (
const char *)zend_memrchr(haystack, *needle, (
p - haystack) + 1);
269 if (ne ==
p[needle_len-1] && !memcmp(needle + 1,
p + 1, needle_len - 2)) {
272 }
while (
p-- >= haystack);
282#if defined(HAVE_STRNLEN)
285 const char *
p = (
const char *)memchr(
s,
'\0',
maxlen);
292#if defined(HAVE_MEMPCPY)
293 return mempcpy(dest, src,
n);
295 return (
char *)
memcpy(dest, src,
n) +
n;
378#define _zval_get_long(op) zval_get_long(op)
379#define _zval_get_double(op) zval_get_double(op)
380#define _zval_get_string(op) zval_get_string(op)
381#define _zval_get_long_func(op) zval_get_long_func(op)
382#define _zval_get_double_func(op) zval_get_double_func(op)
383#define _zval_get_string_func(op) zval_get_string_func(op)
385#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); }
391#define zval_is_true(op) \
449#define ZEND_UNCOMPARABLE 1
464#define zend_tolower_ascii(c) (zend_tolower_map[(unsigned char)(c)])
465#define zend_toupper_ascii(c) (zend_toupper_map[(unsigned char)(c)])
506#define convert_to_null_ex(zv) convert_to_null(zv)
507#define convert_to_boolean_ex(zv) convert_to_boolean(zv)
508#define convert_to_long_ex(zv) convert_to_long(zv)
509#define convert_to_double_ex(zv) convert_to_double(zv)
510#define convert_to_string_ex(zv) convert_to_string(zv)
511#define convert_to_array_ex(zv) convert_to_array(zv)
512#define convert_to_object_ex(zv) convert_to_object(zv)
513#define convert_scalar_to_number_ex(zv) convert_scalar_to_number(zv)
520#define ZVAL_OFFSETOF_TYPE \
521 (offsetof(zval, u1.type_info) - offsetof(zval, value))
523#if defined(HAVE_ASM_GOTO) && !__has_feature(memory_sanitizer)
524# define ZEND_USE_ASM_ARITHMETIC 1
526# define ZEND_USE_ASM_ARITHMETIC 0
531#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
542#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
553#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
561 :
"x5",
"cc",
"memory"
566#elif defined(PHP_HAVE_BUILTIN_SADDL_OVERFLOW) && SIZEOF_LONG == SIZEOF_ZEND_LONG
574#elif defined(PHP_HAVE_BUILTIN_SADDLL_OVERFLOW) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
594#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
605#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
616#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
624 :
"x5",
"cc",
"memory"
629#elif defined(PHP_HAVE_BUILTIN_SSUBL_OVERFLOW) && SIZEOF_LONG == SIZEOF_ZEND_LONG
637#elif defined(PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
657#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
659 "movl (%1), %%eax\n\t"
660 "addl (%2), %%eax\n\t"
662 "movl %%eax, (%0)\n\t"
670 :
"eax",
"cc",
"memory"
675#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
677 "movq (%1), %%rax\n\t"
678 "addq (%2), %%rax\n\t"
680 "movq %%rax, (%0)\n\t"
688 :
"rax",
"cc",
"memory"
693#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
697 "adds x5, x5, x6\n\t"
701 "str w6, [%0, %c4]\n"
708 :
"x5",
"x6",
"cc",
"memory"
713#elif defined(PHP_HAVE_BUILTIN_SADDL_OVERFLOW) && SIZEOF_LONG == SIZEOF_ZEND_LONG
720#elif defined(PHP_HAVE_BUILTIN_SADDLL_OVERFLOW) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
747#if ZEND_USE_ASM_ARITHMETIC && defined(__i386__) && !(4 == __GNUC__ && 8 == __GNUC_MINOR__)
749 "movl (%1), %%eax\n\t"
750 "subl (%2), %%eax\n\t"
752 "movl %%eax, (%0)\n\t"
760 :
"eax",
"cc",
"memory"
765#elif ZEND_USE_ASM_ARITHMETIC && defined(__x86_64__)
767 "movq (%1), %%rax\n\t"
768 "subq (%2), %%rax\n\t"
770 "movq %%rax, (%0)\n\t"
778 :
"rax",
"cc",
"memory"
783#elif ZEND_USE_ASM_ARITHMETIC && defined(__aarch64__)
787 "subs x5, x5, x6\n\t"
791 "str w6, [%0, %c4]\n"
798 :
"x5",
"x6",
"cc",
"memory"
803#elif defined(PHP_HAVE_BUILTIN_SSUBL_OVERFLOW) && SIZEOF_LONG == SIZEOF_ZEND_LONG
810#elif defined(PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
840 return zend_string_equal_content(s1, s2);
908 *--
buf = (char) (num % 10) +
'0';
921 return zend_print_ulong_to_buf(
buf, num);
954zend_memnistr(
const char *haystack,
const char *needle,
size_t needle_len,
const char *
end)
968 const char *p_lower = (
const char *)memchr(haystack, first_lower,
end - haystack);
969 const char *p_upper =
NULL;
970 if (first_lower != first_upper) {
972 size_t upper_search_length = needle_len == 1 && p_lower !=
NULL ? p_lower - haystack :
end - haystack;
973 p_upper = (
const char *)memchr(haystack, first_upper, upper_search_length);
975 const char *
p = !p_upper || (p_lower && p_lower < p_upper) ? p_lower : p_upper;
977 if (needle_len == 1) {
985 while (
p &&
p <=
end) {
986 if (needle_end_lower ==
p[needle_len - 1] || needle_end_upper ==
p[needle_len - 1]) {
987 if (zend_strnieq(needle + 1,
p + 1, needle_len - 2)) {
992 p_lower = (
const char *)memchr(p_lower + 1, first_lower,
end - p_lower);
995 p_upper = (
const char *)memchr(p_upper + 1, first_upper,
end - p_upper);
997 p = !p_upper || (p_lower && p_lower < p_upper) ? p_lower : p_upper;
zend_ffi_ctype_name_buf buf
unsigned const char * end
zend_string_release_ex(func->internal_function.function_name, 0)
struct _zend_string zend_string
ZEND_API zend_result zend_std_cast_object_tostring(zend_object *readobj, zval *writeobj, int type)
ZEND_API const unsigned char zend_tolower_map[256]
ZEND_API bool ZEND_FASTCALL zend_is_identical(const zval *op1, const zval *op2)
ZEND_API const unsigned char zend_toupper_map[256]
ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1)
ZEND_API zend_result ZEND_FASTCALL is_not_identical_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL bitwise_not_function(zval *result, zval *op1)
ZEND_API zend_result ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL is_equal_function(zval *result, zval *op1, zval *op2)
ZEND_API bool ZEND_FASTCALL instanceof_function_slow(const zend_class_entry *instance_ce, const zend_class_entry *ce)
ZEND_API zend_result ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(const zval *op, bool is_strict)
ZEND_API zend_result ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2)
ZEND_API double ZEND_FASTCALL zval_get_double_func(const zval *op)
ZEND_API zend_string *ZEND_FASTCALL zval_get_string_func(zval *op)
ZEND_API zend_result ZEND_FASTCALL is_identical_function(zval *result, zval *op1, zval *op2)
ZEND_API bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce)
ZEND_API zend_result ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2)
ZEND_API zend_result ZEND_FASTCALL decrement_function(zval *op2)
ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2)
ZEND_API int ZEND_FASTCALL numeric_compare_function(zval *op1, zval *op2)
#define zend_toupper_ascii(c)
ZEND_API void zend_incompatible_string_to_long_error(const zend_string *s)
ZEND_API zend_result ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2)
ZEND_API bool ZEND_FASTCALL zend_is_identical(const zval *op1, const zval *op2)
ZEND_API int ZEND_FASTCALL string_locale_compare_function(zval *op1, zval *op2)
ZEND_API int ZEND_FASTCALL string_compare_function_ex(zval *op1, zval *op2, bool case_insensitive)
ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp(const char *s1, size_t len1, const char *s2, size_t len2)
ZEND_API zend_string *ZEND_FASTCALL zend_long_to_str(zend_long num)
ZEND_ATTRIBUTE_DEPRECATED ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, size_t str_len)
ZEND_API const char *ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end)
#define ZVAL_OFFSETOF_TYPE
ZEND_API char *ZEND_FASTCALL zend_str_toupper_dup_ex(const char *source, size_t length)
ZEND_API bool ZEND_FASTCALL zend_object_is_true(const zval *op)
ZEND_API int ZEND_FASTCALL zend_binary_strncmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length)
ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op)
ZEND_API void ZEND_FASTCALL _convert_to_string(zval *op)
ZEND_API void ZEND_FASTCALL zend_str_toupper(char *str, size_t length)
ZEND_API int ZEND_FASTCALL zend_binary_strcmp(const char *s1, size_t len1, const char *s2, size_t len2)
ZEND_API bool zend_string_only_has_ascii_alphanumeric(const zend_string *str)
ZEND_API void ZEND_FASTCALL convert_to_array(zval *op)
ZEND_API char *ZEND_FASTCALL zend_str_tolower_copy(char *dest, const char *source, size_t length)
ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2)
ZEND_API zend_string *ZEND_FASTCALL zval_try_get_string_func(zval *op)
ZEND_API bool ZEND_FASTCALL _try_convert_to_string(zval *op)
ZEND_API bool ZEND_FASTCALL instanceof_function_slow(const zend_class_entry *instance_ce, const zend_class_entry *ce)
ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d)
ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2)
ZEND_API zend_string *ZEND_FASTCALL zend_u64_to_str(uint64_t num)
ZEND_API int ZEND_FASTCALL zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3)
ZEND_API char *ZEND_FASTCALL zend_str_tolower_dup_ex(const char *source, size_t length)
ZEND_API zend_string *ZEND_FASTCALL zend_string_tolower_ex(zend_string *str, bool persistent)
ZEND_API zend_string *ZEND_FASTCALL zend_i64_to_str(int64_t num)
ZEND_API zend_long ZEND_FASTCALL zval_get_long_func(const zval *op, bool is_strict)
ZEND_API const char *ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end)
ZEND_API uint8_t ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, bool allow_errors, int *oflow_info, bool *trailing_data)
ZEND_API void ZEND_FASTCALL convert_to_double(zval *op)
ZEND_API bool ZEND_FASTCALL zendi_smart_streq(zend_string *s1, zend_string *s2)
ZEND_ATTRIBUTE_DEPRECATED ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, size_t str_len)
#define zend_tolower_ascii(c)
ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op)
ZEND_API void zend_incompatible_double_to_long_error(double d)
ZEND_API void ZEND_FASTCALL convert_to_object(zval *op)
ZEND_API zend_result ZEND_FASTCALL increment_function(zval *op1)
ZEND_API char *ZEND_FASTCALL zend_str_tolower_dup(const char *source, size_t length)
ZEND_API int ZEND_FASTCALL zend_compare_symbol_tables(HashTable *ht1, HashTable *ht2)
ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length)
ZEND_API int ZEND_FASTCALL zend_binary_zval_strcmp(zval *s1, zval *s2)
ZEND_API uint8_t ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval)
ZEND_API char *ZEND_FASTCALL zend_str_toupper_copy(char *dest, const char *source, size_t length)
ZEND_API void zend_reset_lc_ctype_locale(void)
ZEND_API int ZEND_FASTCALL string_compare_function(zval *op1, zval *op2)
ZEND_API int ZEND_FASTCALL string_case_compare_function(zval *op1, zval *op2)
ZEND_API zend_long ZEND_FASTCALL zval_try_get_long(const zval *op, bool *failed)
ZEND_API void zend_update_current_locale(void)
ZEND_API void ZEND_FASTCALL zend_str_tolower(char *str, size_t length)
ZEND_API double ZEND_FASTCALL zval_get_double_func(const zval *op)
ZEND_API zend_string *ZEND_FASTCALL zval_get_string_func(zval *op)
ZEND_API void ZEND_FASTCALL convert_to_null(zval *op)
#define ZEND_DOUBLE_FITS_LONG(d)
ZEND_API void ZEND_FASTCALL convert_scalar_to_number(zval *op)
ZEND_API zend_string *ZEND_FASTCALL zend_ulong_to_str(zend_ulong num)
ZEND_API zend_string *ZEND_FASTCALL zend_string_toupper_ex(zend_string *str, bool persistent)
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op)
ZEND_API int ZEND_FASTCALL zend_compare_objects(zval *o1, zval *o2)
ZEND_API zend_string *ZEND_FASTCALL zend_double_to_str(double num)
ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length)
ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2)
ZEND_API char *ZEND_FASTCALL zend_str_toupper_dup(const char *source, size_t length)
#define ZEND_ATTRIBUTE_DEPRECATED
#define EXPECTED(condition)
#define zend_always_inline
#define ZEND_ATTRIBUTE_COLD_LABEL
#define UNEXPECTED(condition)
struct _zend_class_entry zend_class_entry
#define Z_REFVAL_P(zval_p)
#define Z_STRVAL_P(zval_p)
#define Z_ARRVAL_P(zval_p)
struct _zend_array HashTable
#define Z_OBJ_HT_P(zval_p)
#define Z_STRLEN_P(zval_p)
#define Z_RES_HANDLE_P(zval_p)
#define ZVAL_DOUBLE(z, d)
ZEND_RESULT_CODE zend_result