[Lldb-commits] [PATCH] D148541: [lldb] fix build issue on MSVC because of missing byte-swap builtins

Ashay Rane via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 17 11:42:06 PDT 2023


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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148541.514341.patch
Type: text/x-patch
Size: 1074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230417/89b7be4a/attachment.bin>


More information about the lldb-commits mailing list