From 9b0212d104ca5b74965b51514347c36aa845cb1a Mon Sep 17 00:00:00 2001
From: yueyuankun <yueyuankun@kylinos.cn>
Date: Wed, 5 Mar 2025 15:45:41 +0800
Subject: [PATCH] add sw_64 support for qt5-webkit

---
 CMakeLists.txt                       | 2 ++
 Source/JavaScriptCore/CMakeLists.txt | 1 +
 Source/WTF/wtf/Platform.h            | 8 +++++++-
 Source/WTF/wtf/dtoa/utils.h          | 2 +-
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 77687d3..d3f697a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,6 +92,8 @@ elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64")
     set(WTF_CPU_LOONGARCH64 1)
 elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64")
     set(WTF_CPU_RISCV64 1)
+elseif (LOWERCASE_CMAKE_SYSTEM_PROCESSOR MATCHES "sw_64")
+    set(WTF_CPU_SW_64 1)
 else ()
     message(FATAL_ERROR "Unknown CPU '${LOWERCASE_CMAKE_SYSTEM_PROCESSOR}'")
 endif ()
diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt
index ed35b54..b620948 100644
--- a/Source/JavaScriptCore/CMakeLists.txt
+++ b/Source/JavaScriptCore/CMakeLists.txt
@@ -1291,6 +1291,7 @@ elseif (WTF_CPU_X86)
 elseif (WTF_CPU_LOONGARCH64)
 elseif (WTF_CPU_RISCV64)
 elseif (WTF_CPU_X86_64)
+elseif (WTF_CPU_SW_64)
     if (MSVC AND ENABLE_JIT)
         add_custom_command(
             OUTPUT ${DERIVED_SOURCES_DIR}/JITStubsMSVC64.obj
diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
index 338fddc..3002ffb 100644
--- a/Source/WTF/wtf/Platform.h
+++ b/Source/WTF/wtf/Platform.h
@@ -185,6 +185,11 @@
 #define WTF_CPU_RISCV64 1
 #endif
 
+/* CPU(SW_64) - SW_64 */
+#if defined(__sw_64)
+#define WTF_CPU_SW_64 1
+#endif
+
 /* CPU(ARM64) - Apple */
 #if (defined(__arm64__) && defined(__APPLE__)) || defined(__aarch64__)
 #define WTF_CPU_ARM64 1
@@ -718,7 +723,8 @@
     || CPU(PPC64) \
     || CPU(PPC64LE) \
     || CPU(RISCV64) \
-    || CPU(LOONGARCH64)
+    || CPU(LOONGARCH64) \
+    || CPU(SW_64)
 #define USE_JSVALUE64 1
 #else
 #define USE_JSVALUE32_64 1
diff --git a/Source/WTF/wtf/dtoa/utils.h b/Source/WTF/wtf/dtoa/utils.h
index b136162..6dc3843 100644
--- a/Source/WTF/wtf/dtoa/utils.h
+++ b/Source/WTF/wtf/dtoa/utils.h
@@ -49,7 +49,7 @@
 defined(__ARMEL__) || \
 defined(_MIPS_ARCH_MIPS32R2)
 #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
-#elif CPU(MIPS) || CPU(MIPS64) || CPU(PPC) || CPU(PPC64) || CPU(PPC64LE) || CPU(SH4) || CPU(S390) || CPU(S390X) || CPU(IA64) || CPU(ALPHA) || CPU(ARM64) || CPU(HPPA) || CPU(LOONGARCH64) || CPU(RISCV64)
+#elif CPU(MIPS) || CPU(MIPS64) || CPU(PPC) || CPU(PPC64) || CPU(PPC64LE) || CPU(SH4) || CPU(S390) || CPU(S390X) || CPU(IA64) || CPU(ALPHA) || CPU(ARM64) || CPU(HPPA) || CPU(LOONGARCH64) || CPU(RISCV64) || CPU(SW_64)
 #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
 #elif defined(_M_IX86) || defined(__i386__)
 #if defined(_WIN32)
-- 
2.43.0

