Tested on MSVC 2013, 2015 and 2017 targeting X86, X64 and ARM.
This fixes building emutls.c for Windows for ARM (both with clang which don't need these atomics fallbacks at all, but just failed due to the immintrin.h include before, and with MSVC).
Differential D36071
[builtins] Use Interlocked* intrinsics for atomics on MSVC mstorsjo on Jul 30 2017, 11:23 PM. Authored by
Details Tested on MSVC 2013, 2015 and 2017 targeting X86, X64 and ARM. This fixes building emutls.c for Windows for ARM (both with clang which don't need these atomics fallbacks at all, but just failed due to the immintrin.h include before, and with MSVC).
Diff Detail
Event TimelineComment Actions I'm wondering if the #ifdef is now a dead code path entirely. Comment Actions I had only tested it with clang for ARM, where the whole ifdef isn't used. I hadn't tested this with MSVC for ARM though (I only use compiler-rt when building with clang-mingw, not when building with MSVC), but it does indeed fail there. The _load/store_be_u32/64 intrinsics aren't perhaps the most canonical way of doing atomic loads/stores, but MSVC is pretty badly lacking in that department. They do document this though: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684122(v=vs.85).aspx
Although I'm not sure how well that applies to non-x86 platforms. I can update it to use the Interlocked* intrinsics that are available for many platforms. They're a bit hairy though since not all of them are available for all platforms, and it varies a little across MSVC versions as well.
Comment Actions Added the requested comment. Switched to the version of the intrinsics without a leading underscore, which made it work more consistently across MSVC versions, simplifying the code yet quite a bit. |