forked from fmtlib/fmt
Don't define the MSVC clz functions unless __builtin_clzll is unavailable.
This is mainly just to avoid including intrin.h unnecessarily.
This commit is contained in:
15
format.h
15
format.h
@@ -225,16 +225,15 @@ typedef __int64 intmax_t;
|
|||||||
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
|
# define FMT_BUILTIN_CLZLL(n) __builtin_clzll(n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
# include <intrin.h> // _BitScanReverse, _BitScanReverse64
|
|
||||||
|
|
||||||
namespace fmt {
|
|
||||||
namespace internal {
|
|
||||||
// Some compilers masquerade as both MSVC and GCC-likes or
|
// Some compilers masquerade as both MSVC and GCC-likes or
|
||||||
// otherwise support __builtin_clz and __builtin_clzll, so
|
// otherwise support __builtin_clz and __builtin_clzll, so
|
||||||
// only define FMT_BUILTIN_CLZ using the MSVC intrinsics
|
// only define FMT_BUILTIN_CLZ using the MSVC intrinsics
|
||||||
// if the clz and clzll builtins are not available.
|
// if the clz and clzll builtins are not available.
|
||||||
# if !defined(FMT_BUILTIN_CLZ)
|
#if defined(_MSC_VER) && !defined(FMT_BUILTIN_CLZLL)
|
||||||
|
# include <intrin.h> // _BitScanReverse, _BitScanReverse64
|
||||||
|
|
||||||
|
namespace fmt {
|
||||||
|
namespace internal {
|
||||||
# pragma intrinsic(_BitScanReverse)
|
# pragma intrinsic(_BitScanReverse)
|
||||||
inline uint32_t clz(uint32_t x) {
|
inline uint32_t clz(uint32_t x) {
|
||||||
unsigned long r = 0;
|
unsigned long r = 0;
|
||||||
@@ -248,10 +247,7 @@ inline uint32_t clz(uint32_t x) {
|
|||||||
return 31 - r;
|
return 31 - r;
|
||||||
}
|
}
|
||||||
# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)
|
# define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n)
|
||||||
# endif
|
|
||||||
|
|
||||||
# if !defined(FMT_BUILTIN_CLZLL)
|
|
||||||
# pragma intrinsic(_BitScanReverse)
|
|
||||||
# ifdef _WIN64
|
# ifdef _WIN64
|
||||||
# pragma intrinsic(_BitScanReverse64)
|
# pragma intrinsic(_BitScanReverse64)
|
||||||
# endif
|
# endif
|
||||||
@@ -277,7 +273,6 @@ inline uint32_t clzll(uint64_t x) {
|
|||||||
return 63 - r;
|
return 63 - r;
|
||||||
}
|
}
|
||||||
# define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n)
|
# define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n)
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user