add_definitions(-DHAVE_BUILTIN_CTZ)
endif()
#
-# check for __builtin_ctzl() support in the compiler
-#
-check_c_source_compiles(
- "int main(void)
- {
- unsigned int zero = 0;
- long test = __builtin_ctzl(zero);
- (void)test;
- return 0;
- }"
- HAVE_BUILTIN_CTZL
-)
-if(HAVE_BUILTIN_CTZL)
- add_definitions(-DHAVE_BUILTIN_CTZL)
-endif()
-#
# check for __builtin_ctzll() support in the compiler
#
check_c_source_compiles(
echo "Checking for __builtin_ctz ... No." | tee -a configure.log
fi
-# Check for __builtin_ctzl() support in compiler
-cat > $test.c << EOF
-int main(void) {
- unsigned int zero = 0;
- long test = __builtin_ctzl(zero);
- (void)test;
- return 0;
-}
-EOF
-if try ${CC} ${CFLAGS} $test.c $LDSHAREDLIBC; then
- echo "Checking for __builtin_ctzl ... Yes." | tee -a configure.log
- CFLAGS="$CFLAGS -DHAVE_BUILTIN_CTZL"
- SFLAGS="$SFLAGS -DHAVE_BUILTIN_CTZL"
-else
- echo "Checking for __builtin_ctzl ... No." | tee -a configure.log
-fi
-
# Check for __builtin_ctzll() support in compiler
cat > $test.c << EOF
int main(void) {
}
#define HAVE_BUILTIN_CTZ
-/* This is not a general purpose replacement for __builtin_ctzl. The function expects that value is != 0
- * Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward is not checked
- */
-static __forceinline unsigned long __builtin_ctzl(unsigned long value) {
-#ifdef X86_CPUID
- x86_check_features();
- if (x86_cpu_has_tzcnt)
- return _tzcnt_u32(value);
-#endif
- unsigned long trailing_zero;
- _BitScanForward(&trailing_zero, value);
- return trailing_zero;
-}
-
#ifdef _M_AMD64
/* This is not a general purpose replacement for __builtin_ctzll. The function expects that value is != 0
* Because of that assumption trailing_zero is not initialized and the return value of _BitScanForward64 is not checked
# define std2_longest_match
/* Only use std3_longest_match for little_endian systems, also avoid using it with
non-gcc compilers since the __builtin_ctzl() function might not be optimized. */
-# elif(defined(__GNUC__) && defined(HAVE_BUILTIN_CTZL) && ((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \
+# elif(defined(__GNUC__) && (defined(HAVE_BUILTIN_CTZ) || defined(HAVE_BUILTIN_CTZLL)) && ((__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \
|| defined(__LITTLE_ENDIAN__)))
# define std3_longest_match
# elif(defined(_MSC_VER) && defined(_WIN32))