@@ -428,26 +428,40 @@ fi])# PGAC_C_VA_ARGS
428428
429429
430430
431- # PGAC_PROG_CC_CFLAGS_OPT
431+ # PGAC_PROG_VARCC_VARFLAGS_OPT
432432# -----------------------
433- # Given a string, check if the compiler supports the string as a
434- # command-line option. If it does, add the string to CFLAGS.
435- AC_DEFUN ( [ PGAC_PROG_CC_CFLAGS_OPT] ,
436- [ define ( [ Ac_cachevar] , [ AS_TR_SH ( [ pgac_cv_prog_cc_cflags_$1 ] ) ] ) dnl
437- AC_CACHE_CHECK ( [ whether $CC supports $1 ] , [ Ac_cachevar] ,
433+ # Given a compiler, variable name and a string, check if the compiler
434+ # supports the string as a command-line option. If it does, add the
435+ # string to the given variable.
436+ AC_DEFUN ( [ PGAC_PROG_VARCC_VARFLAGS_OPT] ,
437+ [ define ( [ Ac_cachevar] , [ AS_TR_SH ( [ pgac_cv_prog_$1 _cflags_$3 ] ) ] ) dnl
438+ AC_CACHE_CHECK ( [ whether ${$1 } supports $3 , for $2 ] , [ Ac_cachevar] ,
438439[ pgac_save_CFLAGS=$CFLAGS
439- CFLAGS="$pgac_save_CFLAGS $1 "
440+ pgac_save_CC=$CC
441+ CC=${$1 }
442+ CFLAGS="${$2 } $3 "
440443ac_save_c_werror_flag=$ac_c_werror_flag
441444ac_c_werror_flag=yes
442445_AC_COMPILE_IFELSE([ AC_LANG_PROGRAM ( ) ] ,
443446 [ Ac_cachevar=yes] ,
444447 [ Ac_cachevar=no] )
445448ac_c_werror_flag=$ac_save_c_werror_flag
446- CFLAGS="$pgac_save_CFLAGS"] )
449+ CFLAGS="$pgac_save_CFLAGS"
450+ CC="$pgac_save_CC"] )
447451if test x"$Ac_cachevar" = x"yes"; then
448- CFLAGS ="$CFLAGS $1 "
452+ $2 ="${ $2 } $3 "
449453fi
450454undefine ( [ Ac_cachevar] ) dnl
455+ ] ) # PGAC_PROG_VARCC_VARFLAGS_OPT
456+
457+
458+
459+ # PGAC_PROG_CC_CFLAGS_OPT
460+ # -----------------------
461+ # Given a string, check if the compiler supports the string as a
462+ # command-line option. If it does, add the string to CFLAGS.
463+ AC_DEFUN ( [ PGAC_PROG_CC_CFLAGS_OPT] , [
464+ PGAC_PROG_VARCC_VARFLAGS_OPT(CC, CFLAGS, $1 )
451465] ) # PGAC_PROG_CC_CFLAGS_OPT
452466
453467
@@ -458,22 +472,48 @@ undefine([Ac_cachevar])dnl
458472# the string as a command-line option. If it does, add the string to
459473# the given variable.
460474AC_DEFUN ( [ PGAC_PROG_CC_VAR_OPT] ,
461- [ define ( [ Ac_cachevar] , [ AS_TR_SH ( [ pgac_cv_prog_cc_cflags_$2 ] ) ] ) dnl
462- AC_CACHE_CHECK ( [ whether $CC supports $2 ] , [ Ac_cachevar] ,
463- [ pgac_save_CFLAGS=$CFLAGS
464- CFLAGS="$pgac_save_CFLAGS $2 "
465- ac_save_c_werror_flag=$ac_c_werror_flag
466- ac_c_werror_flag=yes
475+ [ PGAC_PROG_VARCC_VARFLAGS_OPT(CC, $1 , $2 )
476+ ] ) # PGAC_PROG_CC_VAR_OPT
477+
478+
479+
480+ # PGAC_PROG_VARCXX_VARFLAGS_OPT
481+ # -----------------------
482+ # Given a compiler, variable name and a string, check if the compiler
483+ # supports the string as a command-line option. If it does, add the
484+ # string to the given variable.
485+ AC_DEFUN ( [ PGAC_PROG_VARCXX_VARFLAGS_OPT] ,
486+ [ define ( [ Ac_cachevar] , [ AS_TR_SH ( [ pgac_cv_prog_$1 _cxxflags_$3 ] ) ] ) dnl
487+ AC_CACHE_CHECK ( [ whether ${$1 } supports $3 , for $2 ] , [ Ac_cachevar] ,
488+ [ pgac_save_CXXFLAGS=$CXXFLAGS
489+ pgac_save_CXX=$CXX
490+ CXX=${$1 }
491+ CXXFLAGS="${$2 } $3 "
492+ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
493+ ac_cxx_werror_flag=yes
494+ AC_LANG_PUSH ( C++ )
467495_AC_COMPILE_IFELSE([ AC_LANG_PROGRAM ( ) ] ,
468496 [ Ac_cachevar=yes] ,
469497 [ Ac_cachevar=no] )
470- ac_c_werror_flag=$ac_save_c_werror_flag
471- CFLAGS="$pgac_save_CFLAGS"] )
498+ AC_LANG_POP ( [ ] )
499+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
500+ CXXFLAGS="$pgac_save_CXXFLAGS"
501+ CXX="$pgac_save_CXX"] )
472502if test x"$Ac_cachevar" = x"yes"; then
473- $1 ="${$1 } $2 "
503+ $2 ="${$2 } $3 "
474504fi
475505undefine ( [ Ac_cachevar] ) dnl
476- ] ) # PGAC_PROG_CC_VAR_OPT
506+ ] ) # PGAC_PROG_VARCXX_VARFLAGS_OPT
507+
508+
509+
510+ # PGAC_PROG_CXX_CFLAGS_OPT
511+ # -----------------------
512+ # Given a string, check if the compiler supports the string as a
513+ # command-line option. If it does, add the string to CXXFLAGS.
514+ AC_DEFUN ( [ PGAC_PROG_CXX_CFLAGS_OPT] ,
515+ [ PGAC_PROG_VARCXX_VARFLAGS_OPT(CXX, CXXFLAGS, $1 )
516+ ] ) # PGAC_PROG_CXX_VAR_OPT
477517
478518
479519
@@ -627,3 +667,37 @@ if test x"$Ac_cachevar" = x"yes"; then
627667fi
628668undefine ( [ Ac_cachevar] ) dnl
629669] ) # PGAC_SSE42_CRC32_INTRINSICS
670+
671+
672+ # PGAC_ARMV8_CRC32C_INTRINSICS
673+ # -----------------------
674+ # Check if the compiler supports the CRC32C instructions using the __crc32cb,
675+ # __crc32ch, __crc32cw, and __crc32cd intrinsic functions. These instructions
676+ # were first introduced in ARMv8 in the optional CRC Extension, and became
677+ # mandatory in ARMv8.1.
678+ #
679+ # An optional compiler flag can be passed as argument (e.g.
680+ # -march=armv8-a+crc). If the intrinsics are supported, sets
681+ # pgac_armv8_crc32c_intrinsics, and CFLAGS_ARMV8_CRC32C.
682+ AC_DEFUN ( [ PGAC_ARMV8_CRC32C_INTRINSICS] ,
683+ [ define ( [ Ac_cachevar] , [ AS_TR_SH ( [ pgac_cv_armv8_crc32c_intrinsics_$1 ] ) ] ) dnl
684+ AC_CACHE_CHECK ( [ for __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS=$1 ] , [ Ac_cachevar] ,
685+ [ pgac_save_CFLAGS=$CFLAGS
686+ CFLAGS="$pgac_save_CFLAGS $1 "
687+ AC_LINK_IFELSE ( [ AC_LANG_PROGRAM ( [ #include <arm_acle.h>] ,
688+ [ unsigned int crc = 0;
689+ crc = __crc32cb(crc, 0);
690+ crc = __crc32ch(crc, 0);
691+ crc = __crc32cw(crc, 0);
692+ crc = __crc32cd(crc, 0);
693+ /* return computed value, to prevent the above being optimized away */
694+ return crc == 0;] ) ] ,
695+ [ Ac_cachevar=yes] ,
696+ [ Ac_cachevar=no] )
697+ CFLAGS="$pgac_save_CFLAGS"] )
698+ if test x"$Ac_cachevar" = x"yes"; then
699+ CFLAGS_ARMV8_CRC32C="$1 "
700+ pgac_armv8_crc32c_intrinsics=yes
701+ fi
702+ undefine ( [ Ac_cachevar] ) dnl
703+ ] ) # PGAC_ARMV8_CRC32C_INTRINSICS
0 commit comments