Make snmalloc build on Windows with Clang

Fixes a few places where Clang complains about Windows specific code,
and also uses macros supported by Clang on Windows.  A few places
separating platform and compiler specific code, as MSVC and WIN32 were
used interchangably previously.
This commit is contained in:
Matthew Parkinson
2020-01-24 13:17:45 +00:00
committed by Matthew Parkinson
parent eaeb2aa53d
commit 0affc069cf
8 changed files with 64 additions and 14 deletions

View File

@@ -138,13 +138,16 @@ namespace snmalloc
inline size_t ctz(size_t x)
{
#if defined(_MSC_VER)
#if __has_builtin(__builtin_ctzl)
return static_cast<size_t>(__builtin_ctzl(x));
#elif defined(_MSC_VER)
# ifdef SNMALLOC_VA_BITS_64
return _tzcnt_u64(x);
# else
return _tzcnt_u32((uint32_t)x);
# endif
#else
// Probably GCC at this point.
return static_cast<size_t>(__builtin_ctzl(x));
#endif
}