[libcxx-commits] [PATCH] D119647: [libcxx] Fix setup of MSVC specific intrinsics in Ryu code
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Feb 12 12:10:02 PST 2022
mstorsjo created this revision.
mstorsjo added a reviewer: Mordante.
Herald added subscribers: pengfei, kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.
This fixes warnings about implicitly declared `_umul128` and
`__shiftright128` when building for x86_64 with clang-cl.
Use `_MSC_VER` instead of `_LIBCPP_COMPILER_MSVC` for enabling MSVC
specific code; `_MSC_VER` is defined both in clang-cl and MSVC,
while `_LIBCPP_COMPILER_MSVC` only is defined if building with the
actual MSVC compiler.
Include `ryu.h` at the head of `d2s_intrinsics.h`, as it uses
the `_LIBCPP_64_BIT` define, which is defined in `ryu.h`.
Now the Ryu files build without warnings with clang-cl for i386,
x86_64, arm and aarch64.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119647
Files:
libcxx/src/include/ryu/d2s_intrinsics.h
libcxx/src/include/ryu/ryu.h
Index: libcxx/src/include/ryu/ryu.h
===================================================================
--- libcxx/src/include/ryu/ryu.h
+++ libcxx/src/include/ryu/ryu.h
@@ -56,9 +56,9 @@
#include "include/ryu/d2s.h"
#include "include/ryu/d2fixed.h"
-#if defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC)
-#include <intrin0.h> // for _umul128() and __shiftright128()
-#endif // defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC)
+#if defined(_MSC_VER)
+#include <intrin.h> // for _umul128(), __shiftright128(), _BitScanForward{,64}
+#endif // defined(_MSC_VER)
#if defined(_WIN64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__aarch64__)
#define _LIBCPP_64_BIT
@@ -68,7 +68,7 @@
// https://github.com/ulfjack/ryu/tree/59661c3/ryu
-#if !defined(_LIBCPP_COMPILER_MSVC)
+#if !defined(_MSC_VER)
_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) {
if (__mask == 0) {
return false;
@@ -84,7 +84,7 @@
*__index = __builtin_ctz(__mask);
return true;
}
-#endif // _LIBCPP_COMPILER_MSVC
+#endif // !_MSC_VER
template <class _Floating>
[[nodiscard]] to_chars_result _Floating_to_chars_ryu(
Index: libcxx/src/include/ryu/d2s_intrinsics.h
===================================================================
--- libcxx/src/include/ryu/d2s_intrinsics.h
+++ libcxx/src/include/ryu/d2s_intrinsics.h
@@ -44,6 +44,8 @@
#include "__config"
+#include "include/ryu/ryu.h"
+
_LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_M_X64) && defined(_MSC_VER)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119647.408209.patch
Type: text/x-patch
Size: 1537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220212/58212150/attachment.bin>
More information about the libcxx-commits
mailing list