29
29
#include "zend_enum.h"
30
30
#include "zend_property_hooks.h"
31
31
#include "zend_lazy_objects.h"
32
+ #include "zend_bitset.h"
32
33
33
34
#ifdef ZEND_INTRIN_SSE4_2_NATIVE
34
35
# include <nmmintrin.h>
@@ -500,7 +501,7 @@ zend_result php_json_escape_string(
500
501
501
502
int input_range_mask = _mm_movemask_epi8 (input_range );
502
503
if (input_range_mask != 0 ) {
503
- max_shift = __builtin_ctz (input_range_mask );
504
+ max_shift = zend_ulong_ntz (input_range_mask );
504
505
}
505
506
506
507
#ifdef ZEND_INTRIN_SSE4_2_NATIVE /* TODO: resolver support */
@@ -527,16 +528,16 @@ zend_result php_json_escape_string(
527
528
#endif
528
529
if (mask != 0 ) {
529
530
if (max_shift < 16 ) {
530
- int shift = __builtin_ctz (mask ); /* first offending character */
531
+ int shift = zend_ulong_ntz (mask ); /* first offending character */
531
532
pos += MIN (max_shift , shift );
532
533
len -= MIN (max_shift , shift );
533
534
break ;
534
535
}
535
- int shift = __builtin_clz (mask ) - 16 ; /* skips over everything */
536
+ int shift = zend_ulong_nlz (mask ) - 16 - ( SIZEOF_ZEND_LONG == 8 ? 32 : 0 ) ; /* skips over everything */
536
537
do {
537
538
/* Note that we shift the input forward, so we have to shift the mask as well,
538
539
* beyond the to-be-escaped character */
539
- int len = __builtin_ctz (mask );
540
+ int len = zend_ulong_ntz (mask );
540
541
mask >>= len + 1 ;
541
542
542
543
smart_str_appendl (buf , s , len + pos );
0 commit comments