mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 09:59:42 +00:00
Cleanup use of BMI intrinsics under GCC and compatibles
This commit is contained in:
parent
55fe79e5ee
commit
24a19b7a18
35
misc.h
35
misc.h
@ -1,4 +1,3 @@
|
||||
|
||||
// misc.h - originally written and placed in the public domain by Wei Dai
|
||||
|
||||
//! \file misc.h
|
||||
@ -67,27 +66,11 @@
|
||||
#include <byteswap.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__BMI__)
|
||||
# include <immintrin.h>
|
||||
# if defined(__clang__)
|
||||
# ifndef _tzcnt_u32
|
||||
# define _tzcnt_u32(x) __tzcnt_u32(x)
|
||||
# endif
|
||||
# ifndef _blsr_u32
|
||||
# define _blsr_u32(x) __blsr_u32(x)
|
||||
# endif
|
||||
# ifdef __x86_64__
|
||||
# ifndef _tzcnt_u64
|
||||
# define _tzcnt_u64(x) __tzcnt_u64(x)
|
||||
# endif
|
||||
# ifndef _blsr_u64
|
||||
# define _blsr_u64(x) __blsr_u64(x)
|
||||
# endif
|
||||
# endif // x86_64
|
||||
# endif // Clang
|
||||
#endif // GNUC and BMI
|
||||
#if defined(__BMI__)
|
||||
# include <x86intrin.h>
|
||||
#endif // GCC and BMI
|
||||
|
||||
#endif // CRYPTOPP_DOXYGEN_PROCESSING
|
||||
#endif // CRYPTOPP_DOXYGEN_PROCESSING
|
||||
|
||||
#if CRYPTOPP_DOXYGEN_PROCESSING
|
||||
//! \brief The maximum value of a machine word
|
||||
@ -730,7 +713,7 @@ inline unsigned int TrailingZeros(word32 v)
|
||||
// We don't enable for Microsoft because it requires a runtime check.
|
||||
// http://msdn.microsoft.com/en-us/library/hh977023%28v=vs.110%29.aspx
|
||||
CRYPTOPP_ASSERT(v != 0);
|
||||
#if defined(__GNUC__) && defined(__BMI__)
|
||||
#if defined(__BMI__)
|
||||
return (unsigned int)_tzcnt_u32(v);
|
||||
#elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400)
|
||||
return (unsigned int)__builtin_ctz(v);
|
||||
@ -761,7 +744,7 @@ inline unsigned int TrailingZeros(word64 v)
|
||||
// We don't enable for Microsoft because it requires a runtime check.
|
||||
// http://msdn.microsoft.com/en-us/library/hh977023%28v=vs.110%29.aspx
|
||||
CRYPTOPP_ASSERT(v != 0);
|
||||
#if defined(__GNUC__) && defined(__BMI__) && defined(__x86_64__)
|
||||
#if defined(__BMI__) && defined(__x86_64__)
|
||||
return (unsigned int)_tzcnt_u64(v);
|
||||
#elif defined(__GNUC__) && (CRYPTOPP_GCC_VERSION >= 30400)
|
||||
return (unsigned int)__builtin_ctzll(v);
|
||||
@ -869,7 +852,7 @@ inline bool IsPowerOf2(const T &value)
|
||||
return value > 0 && (value & (value-1)) == 0;
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && defined(__BMI__)
|
||||
#if defined(__BMI__)
|
||||
template <>
|
||||
inline bool IsPowerOf2<word32>(const word32 &value)
|
||||
{
|
||||
@ -882,8 +865,8 @@ inline bool IsPowerOf2<word64>(const word64 &value)
|
||||
{
|
||||
return value > 0 && _blsr_u64(value) == 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
# endif // __x86_64__
|
||||
#endif // __BMI__
|
||||
|
||||
//! \brief Performs a saturating subtract clamped at 0
|
||||
//! \tparam T1 class or type
|
||||
|
Loading…
Reference in New Issue
Block a user