ashay-github updated this revision to Diff 514341. ashay-github added a comment.
Updated to check for builtins and use them, if available. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148541/new/ 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,24 @@ #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private-types.h" +#if !defined(__has_builtin) +#define __has_builtin(x) 0 +#endif + +#if __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64) +#define bswap_32(x) __builtin_bswap32(x) +#define bswap_64(x) __builtin_bswap64(x) +#elif defined(_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,24 @@ #include "lldb/Utility/StreamString.h" #include "lldb/lldb-private-types.h" +#if !defined(__has_builtin) +#define __has_builtin(x) 0 +#endif + +#if __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64) +#define bswap_32(x) __builtin_bswap32(x) +#define bswap_64(x) __builtin_bswap64(x) +#elif defined(_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