@@ -325,12 +325,12 @@ static zend_always_inline int php_base64_decode_impl(const unsigned char *in, si
325
325
326
326
/* {{{ php_base64_encode */
327
327
328
- #if ZEND_INTRIN_AVX2_NATIVE
328
+ #ifdef ZEND_INTRIN_AVX2_NATIVE
329
329
# undef ZEND_INTRIN_SSSE3_NATIVE
330
330
# undef ZEND_INTRIN_SSSE3_RESOLVER
331
331
# undef ZEND_INTRIN_SSSE3_FUNC_PROTO
332
332
# undef ZEND_INTRIN_SSSE3_FUNC_PTR
333
- #elif ZEND_INTRIN_AVX2_FUNC_PROTO && ZEND_INTRIN_SSSE3_NATIVE
333
+ #elif defined( ZEND_INTRIN_AVX2_FUNC_PROTO ) && defined( ZEND_INTRIN_SSSE3_NATIVE )
334
334
# undef ZEND_INTRIN_SSSE3_NATIVE
335
335
# undef ZEND_INTRIN_SSSE3_RESOLVER
336
336
# define ZEND_INTRIN_SSSE3_RESOLVER 1
@@ -341,7 +341,7 @@ static zend_always_inline int php_base64_decode_impl(const unsigned char *in, si
341
341
# else
342
342
# define ZEND_INTRIN_SSSE3_FUNC_DECL (func ) ZEND_API func
343
343
# endif
344
- #elif ZEND_INTRIN_AVX2_FUNC_PTR && ZEND_INTRIN_SSSE3_NATIVE
344
+ #elif defined( ZEND_INTRIN_AVX2_FUNC_PTR ) && defined( ZEND_INTRIN_SSSE3_NATIVE )
345
345
# undef ZEND_INTRIN_SSSE3_NATIVE
346
346
# undef ZEND_INTRIN_SSSE3_RESOLVER
347
347
# define ZEND_INTRIN_SSSE3_RESOLVER 1
@@ -354,32 +354,32 @@ static zend_always_inline int php_base64_decode_impl(const unsigned char *in, si
354
354
# endif
355
355
#endif
356
356
357
- #if ZEND_INTRIN_AVX2_NATIVE
357
+ #ifdef ZEND_INTRIN_AVX2_NATIVE
358
358
# include <immintrin.h>
359
- #elif ZEND_INTRIN_SSSE3_NATIVE
359
+ #elif defined( ZEND_INTRIN_SSSE3_NATIVE )
360
360
# include <tmmintrin.h>
361
- #elif (ZEND_INTRIN_SSSE3_RESOLVER || ZEND_INTRIN_AVX2_RESOLVER )
362
- # if ZEND_INTRIN_AVX2_RESOLVER
361
+ #elif (defined( ZEND_INTRIN_SSSE3_RESOLVER ) || defined( ZEND_INTRIN_AVX2_RESOLVER ) )
362
+ # ifdef ZEND_INTRIN_AVX2_RESOLVER
363
363
# include <immintrin.h>
364
364
# else
365
365
# include <tmmintrin.h>
366
366
# endif /* (ZEND_INTRIN_SSSE3_RESOLVER || ZEND_INTRIN_AVX2_RESOLVER) */
367
367
# include "Zend/zend_cpuinfo.h"
368
368
369
- # if ZEND_INTRIN_AVX2_RESOLVER
369
+ # ifdef ZEND_INTRIN_AVX2_RESOLVER
370
370
ZEND_INTRIN_AVX2_FUNC_DECL (zend_string * php_base64_encode_avx2 (const unsigned char * str , size_t length ));
371
371
ZEND_INTRIN_AVX2_FUNC_DECL (zend_string * php_base64_decode_ex_avx2 (const unsigned char * str , size_t length , zend_bool strict ));
372
372
# endif
373
373
374
- # if ZEND_INTRIN_SSSE3_RESOLVER
374
+ # ifdef ZEND_INTRIN_SSSE3_RESOLVER
375
375
ZEND_INTRIN_SSSE3_FUNC_DECL (zend_string * php_base64_encode_ssse3 (const unsigned char * str , size_t length ));
376
376
ZEND_INTRIN_SSSE3_FUNC_DECL (zend_string * php_base64_decode_ex_ssse3 (const unsigned char * str , size_t length , zend_bool strict ));
377
377
# endif
378
378
379
379
zend_string * php_base64_encode_default (const unsigned char * str , size_t length );
380
380
zend_string * php_base64_decode_ex_default (const unsigned char * str , size_t length , zend_bool strict );
381
381
382
- # if (ZEND_INTRIN_AVX2_FUNC_PROTO || ZEND_INTRIN_SSSE3_FUNC_PROTO )
382
+ # if (defined( ZEND_INTRIN_AVX2_FUNC_PROTO ) || defined( ZEND_INTRIN_SSSE3_FUNC_PROTO ) )
383
383
PHPAPI zend_string * php_base64_encode (const unsigned char * str , size_t length ) __attribute__((ifunc ("resolve_base64_encode" )));
384
384
PHPAPI zend_string * php_base64_decode_ex (const unsigned char * str , size_t length , zend_bool strict ) __attribute__((ifunc ("resolve_base64_decode" )));
385
385
@@ -389,12 +389,12 @@ typedef zend_string *(*base64_decode_func_t)(const unsigned char *, size_t, zend
389
389
ZEND_NO_SANITIZE_ADDRESS
390
390
ZEND_ATTRIBUTE_UNUSED /* clang mistakenly warns about this */
391
391
static base64_encode_func_t resolve_base64_encode () {
392
- # if ZEND_INTRIN_AVX2_FUNC_PROTO
392
+ # ifdef ZEND_INTRIN_AVX2_FUNC_PROTO
393
393
if (zend_cpu_supports_avx2 ()) {
394
394
return php_base64_encode_avx2 ;
395
395
} else
396
396
# endif
397
- #if ZEND_INTRIN_SSSE3_FUNC_PROTO
397
+ #ifdef ZEND_INTRIN_SSSE3_FUNC_PROTO
398
398
if (zend_cpu_supports_ssse3 ()) {
399
399
return php_base64_encode_ssse3 ;
400
400
}
@@ -405,12 +405,12 @@ static base64_encode_func_t resolve_base64_encode() {
405
405
ZEND_NO_SANITIZE_ADDRESS
406
406
ZEND_ATTRIBUTE_UNUSED /* clang mistakenly warns about this */
407
407
static base64_decode_func_t resolve_base64_decode () {
408
- # if ZEND_INTRIN_AVX2_FUNC_PROTO
408
+ # ifdef ZEND_INTRIN_AVX2_FUNC_PROTO
409
409
if (zend_cpu_supports_avx2 ()) {
410
410
return php_base64_decode_ex_avx2 ;
411
411
} else
412
412
# endif
413
- #if ZEND_INTRIN_SSSE3_FUNC_PROTO
413
+ #ifdef ZEND_INTRIN_SSSE3_FUNC_PROTO
414
414
if (zend_cpu_supports_ssse3 ()) {
415
415
return php_base64_decode_ex_ssse3 ;
416
416
}
@@ -431,13 +431,13 @@ PHPAPI zend_string *php_base64_decode_ex(const unsigned char *str, size_t length
431
431
432
432
PHP_MINIT_FUNCTION (base64_intrin )
433
433
{
434
- # if ZEND_INTRIN_AVX2_FUNC_PTR
434
+ # ifdef ZEND_INTRIN_AVX2_FUNC_PTR
435
435
if (zend_cpu_supports_avx2 ()) {
436
436
php_base64_encode_ptr = php_base64_encode_avx2 ;
437
437
php_base64_decode_ex_ptr = php_base64_decode_ex_avx2 ;
438
438
} else
439
439
# endif
440
- #if ZEND_INTRIN_SSSE3_FUNC_PTR
440
+ #ifdef ZEND_INTRIN_SSSE3_FUNC_PTR
441
441
if (zend_cpu_supports_ssse3 ()) {
442
442
php_base64_encode_ptr = php_base64_encode_ssse3 ;
443
443
php_base64_decode_ex_ptr = php_base64_decode_ex_ssse3 ;
@@ -452,8 +452,8 @@ PHP_MINIT_FUNCTION(base64_intrin)
452
452
# endif /* (ZEND_INTRIN_AVX2_FUNC_PROTO || ZEND_INTRIN_SSSE3_FUNC_PROTO) */
453
453
#endif /* ZEND_INTRIN_AVX2_NATIVE */
454
454
455
- #if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_AVX2_RESOLVER
456
- # if ZEND_INTRIN_AVX2_RESOLVER && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
455
+ #if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_AVX2_RESOLVER )
456
+ # if defined( ZEND_INTRIN_AVX2_RESOLVER ) && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
457
457
static __m256i php_base64_encode_avx2_reshuffle (__m256i in ) __attribute__((target ("avx2" )));
458
458
static __m256i php_base64_encode_avx2_translate (__m256i in ) __attribute__((target ("avx2" )));
459
459
# endif
@@ -517,9 +517,9 @@ static __m256i php_base64_encode_avx2_translate(__m256i in)
517
517
}
518
518
#endif /* ZEND_INTRIN_AVX2_NATIVE || (ZEND_INTRIN_AVX2_RESOLVER && !ZEND_INTRIN_SSSE3_NATIVE) */
519
519
520
- #if ZEND_INTRIN_SSSE3_NATIVE || ZEND_INTRIN_SSSE3_RESOLVER
520
+ #if defined( ZEND_INTRIN_SSSE3_NATIVE ) || defined( ZEND_INTRIN_SSSE3_RESOLVER )
521
521
522
- # if ZEND_INTRIN_SSSE3_RESOLVER && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
522
+ # if defined( ZEND_INTRIN_SSSE3_RESOLVER ) && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
523
523
static __m128i php_base64_encode_ssse3_reshuffle (__m128i in ) __attribute__((target ("ssse3" )));
524
524
static __m128i php_base64_encode_ssse3_translate (__m128i in ) __attribute__((target ("ssse3" )));
525
525
# endif
@@ -600,10 +600,10 @@ static __m128i php_base64_encode_ssse3_translate(__m128i in)
600
600
601
601
#endif /* ZEND_INTRIN_SSSE3_NATIVE || (ZEND_INTRIN_SSSE3_RESOLVER && !ZEND_INTRIN_AVX2_NATIVE) */
602
602
603
- #if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_AVX2_RESOLVER || ZEND_INTRIN_SSSE3_NATIVE || ZEND_INTRIN_SSSE3_RESOLVER
604
- # if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_SSSE3_NATIVE
603
+ #if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_AVX2_RESOLVER ) || defined( ZEND_INTRIN_SSSE3_NATIVE ) || defined( ZEND_INTRIN_SSSE3_RESOLVER )
604
+ # if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_SSSE3_NATIVE )
605
605
PHPAPI zend_string * php_base64_encode (const unsigned char * str , size_t length )
606
- # elif ZEND_INTRIN_AVX2_RESOLVER
606
+ # elif defined( ZEND_INTRIN_AVX2_RESOLVER )
607
607
zend_string * php_base64_encode_avx2 (const unsigned char * str , size_t length )
608
608
# else /* ZEND_INTRIN_SSSE3_RESOLVER */
609
609
zend_string * php_base64_encode_ssse3 (const unsigned char * str , size_t length )
@@ -615,7 +615,7 @@ zend_string *php_base64_encode_ssse3(const unsigned char *str, size_t length)
615
615
616
616
result = zend_string_safe_alloc (((length + 2 ) / 3 ), 4 * sizeof (char ), 0 , 0 );
617
617
o = (unsigned char * )ZSTR_VAL (result );
618
- # if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_AVX2_RESOLVER
618
+ # if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_AVX2_RESOLVER )
619
619
if (length > 31 ) {
620
620
__m256i s = _mm256_loadu_si256 ((__m256i * )c );
621
621
@@ -647,7 +647,7 @@ zend_string *php_base64_encode_ssse3(const unsigned char *str, size_t length)
647
647
return result ;
648
648
}
649
649
650
- # if ZEND_INTRIN_SSSE3_RESOLVER && ZEND_INTRIN_AVX2_RESOLVER
650
+ # if defined( ZEND_INTRIN_SSSE3_RESOLVER ) && defined( ZEND_INTRIN_AVX2_RESOLVER )
651
651
zend_string * php_base64_encode_ssse3 (const unsigned char * str , size_t length )
652
652
{
653
653
const unsigned char * c = str ;
@@ -670,8 +670,8 @@ zend_string *php_base64_encode_ssse3(const unsigned char *str, size_t length)
670
670
671
671
/* }}} */
672
672
673
- #if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_AVX2_RESOLVER
674
- # if ZEND_INTRIN_AVX2_RESOLVER && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
673
+ #if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_AVX2_RESOLVER )
674
+ # if defined( ZEND_INTRIN_AVX2_RESOLVER ) && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
675
675
static __m256i php_base64_decode_avx2_reshuffle (__m256i in ) __attribute__((target ("avx2" )));
676
676
# endif
677
677
@@ -691,8 +691,8 @@ static __m256i php_base64_decode_avx2_reshuffle(__m256i in)
691
691
}
692
692
#endif
693
693
694
- #if ZEND_INTRIN_SSSE3_NATIVE || ZEND_INTRIN_SSSE3_RESOLVER
695
- # if ZEND_INTRIN_SSSE3_RESOLVER && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
694
+ #if defined( ZEND_INTRIN_SSSE3_NATIVE ) || defined( ZEND_INTRIN_SSSE3_RESOLVER )
695
+ # if defined( ZEND_INTRIN_SSSE3_RESOLVER ) && defined(HAVE_FUNC_ATTRIBUTE_TARGET )
696
696
static __m128i php_base64_decode_ssse3_reshuffle (__m128i in ) __attribute__((target ("ssse3" )));
697
697
# endif
698
698
@@ -773,10 +773,10 @@ static __m128i php_base64_decode_ssse3_reshuffle(__m128i in)
773
773
774
774
#endif
775
775
776
- #if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_AVX2_RESOLVER || ZEND_INTRIN_SSSE3_NATIVE || ZEND_INTRIN_SSSE3_RESOLVER
777
- # if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_SSSE3_NATIVE
776
+ #if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_AVX2_RESOLVER ) || defined( ZEND_INTRIN_SSSE3_NATIVE ) || defined( ZEND_INTRIN_SSSE3_RESOLVER )
777
+ # if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_SSSE3_NATIVE )
778
778
PHPAPI zend_string * php_base64_decode_ex (const unsigned char * str , size_t length , zend_bool strict )
779
- # elif ZEND_INTRIN_AVX2_RESOLVER
779
+ # elif defined( ZEND_INTRIN_AVX2_RESOLVER )
780
780
zend_string * php_base64_decode_ex_avx2 (const unsigned char * str , size_t length , zend_bool strict )
781
781
# else
782
782
zend_string * php_base64_decode_ex_ssse3 (const unsigned char * str , size_t length , zend_bool strict )
@@ -792,7 +792,7 @@ zend_string *php_base64_decode_ex_ssse3(const unsigned char *str, size_t length,
792
792
793
793
/* See: "Faster Base64 Encoding and Decoding using AVX2 Instructions"
794
794
* https://arxiv.org/pdf/1704.00605.pdf */
795
- # if ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_AVX2_RESOLVER
795
+ # if defined( ZEND_INTRIN_AVX2_NATIVE ) || defined( ZEND_INTRIN_AVX2_RESOLVER )
796
796
while (length > 31 + 11 + 2 ) {
797
797
__m256i lut_lo , lut_hi , lut_roll ;
798
798
__m256i hi_nibbles , lo_nibbles , hi , lo ;
@@ -880,12 +880,12 @@ zend_string *php_base64_decode_ex_ssse3(const unsigned char *str, size_t length,
880
880
# endif
881
881
#endif /* ZEND_INTRIN_AVX2_NATIVE || ZEND_INTRIN_AVX2_RESOLVER || ZEND_INTRIN_SSSE3_NATIVE || ZEND_INTRIN_SSSE3_RESOLVER */
882
882
883
- #if !ZEND_INTRIN_AVX2_NATIVE && !ZEND_INTRIN_SSSE3_NATIVE
884
- #if ZEND_INTRIN_AVX2_RESOLVER || ZEND_INTRIN_SSSE3_RESOLVER
883
+ #if !defined( ZEND_INTRIN_AVX2_NATIVE ) && !defined( ZEND_INTRIN_SSSE3_NATIVE )
884
+ # if defined( ZEND_INTRIN_AVX2_RESOLVER ) || defined( ZEND_INTRIN_SSSE3_RESOLVER )
885
885
zend_string * php_base64_encode_default (const unsigned char * str , size_t length )
886
- #else
886
+ # else
887
887
PHPAPI zend_string * php_base64_encode (const unsigned char * str , size_t length )
888
- #endif
888
+ # endif
889
889
{
890
890
unsigned char * p ;
891
891
zend_string * result ;
@@ -901,12 +901,12 @@ PHPAPI zend_string *php_base64_encode(const unsigned char *str, size_t length)
901
901
}
902
902
#endif
903
903
904
- #if !ZEND_INTRIN_AVX2_NATIVE && !ZEND_INTRIN_SSSE3_NATIVE
905
- #if ZEND_INTRIN_AVX2_RESOLVER || ZEND_INTRIN_SSSE3_RESOLVER
904
+ #if !defined( ZEND_INTRIN_AVX2_NATIVE ) && !defined( ZEND_INTRIN_SSSE3_NATIVE )
905
+ # if defined( ZEND_INTRIN_AVX2_RESOLVER ) || defined( ZEND_INTRIN_SSSE3_RESOLVER )
906
906
zend_string * php_base64_decode_ex_default (const unsigned char * str , size_t length , zend_bool strict )
907
- #else
907
+ # else
908
908
PHPAPI zend_string * php_base64_decode_ex (const unsigned char * str , size_t length , zend_bool strict )
909
- #endif
909
+ # endif
910
910
{
911
911
zend_string * result ;
912
912
size_t outl = 0 ;
0 commit comments