ashay-github created this revision. ashay-github added reviewers: DavidSpickett, jasonmolenda, bulbazord. Herald added a project: All. ashay-github requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
The `__builtin_bswap{32,64}()` builtins (introduced in commit e07a421d <https://reviews.llvm.org/rGe07a421dd587f596b3b34ac2f79081402089f878>) are missing from MSVC, which causes build errors when compiling LLDB on Windows (tested with MSVC 19.34.31943.0). This patch replaces the builtins with either MSVC's `_byteswap_u{long,64}()` or the `bswap_{32,64}()` functions from byteswap.h, which is part of libc. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D148541 Files: lldb/source/Core/DumpRegisterValue.cpp Index: lldb/source/Core/DumpRegisterValue.cpp =================================================================== --- lldb/source/Core/DumpRegisterValue.cpp +++ lldb/source/Core/DumpRegisterValue.cpp @@ -18,10 +18,17 @@ #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private-types.h" +#ifdef _MSC_VER +#define bswap_32(x) _byteswap_ulong(x) +#define bswap_64(x) _byteswap_uint64(x) +#else +#include <byteswap.h> +#endif + using namespace lldb; -static uint32_t swap_value(uint32_t v) { return __builtin_bswap32(v); } -static uint64_t swap_value(uint64_t v) { return __builtin_bswap64(v); } +static uint32_t swap_value(uint32_t v) { return bswap_32(v); } +static uint64_t swap_value(uint64_t v) { return bswap_64(v); } template <typename T> static void dump_type_value(lldb_private::CompilerType &fields_type, T value,
Index: lldb/source/Core/DumpRegisterValue.cpp =================================================================== --- lldb/source/Core/DumpRegisterValue.cpp +++ lldb/source/Core/DumpRegisterValue.cpp @@ -18,10 +18,17 @@ #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private-types.h" +#ifdef _MSC_VER +#define bswap_32(x) _byteswap_ulong(x) +#define bswap_64(x) _byteswap_uint64(x) +#else +#include <byteswap.h> +#endif + using namespace lldb; -static uint32_t swap_value(uint32_t v) { return __builtin_bswap32(v); } -static uint64_t swap_value(uint64_t v) { return __builtin_bswap64(v); } +static uint32_t swap_value(uint32_t v) { return bswap_32(v); } +static uint64_t swap_value(uint64_t v) { return bswap_64(v); } template <typename T> static void dump_type_value(lldb_private::CompilerType &fields_type, T value,
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits