Blob Blame History Raw
diff -up build/premake/premake5.lua.orig build/premake/premake5.lua
--- build/premake/premake5.lua.orig	2021-02-22 11:28:19.004622175 -0300
+++ build/premake/premake5.lua	2021-02-22 11:29:01.178870889 -0300
@@ -87,6 +87,8 @@ else
 			arch = "aarch64"
 		elseif string.find(machine, "e2k") == 1 then
 			arch = "e2k"
+		elseif string.find(machine, "ppc64") == 1 or string.find(machine, "powerpc64") == 1 then
+			arch = "ppc64"
 		else
 			print("WARNING: Cannot determine architecture from GCC, assuming x86")
 		end
@@ -865,6 +867,8 @@ function setup_all_libs ()
 		table.insert(source_dirs, "lib/sysdep/arch/aarch64");
 	elseif arch == "e2k" then
 		table.insert(source_dirs, "lib/sysdep/arch/e2k");
+	elseif arch == "ppc64" then
+		table.insert(source_dirs, "lib/sysdep/arch/ppc64");
 	end
 
 	-- OS-specific
diff -up libraries/source/nvtt/src/extern/poshlib/posh.h.orig 0ad-0.0.24b-alpha/libraries/source/nvtt/src/extern/poshlib/posh.h
diff -up source/lib/alignment.h.orig 0ad-0.0.24b-alpha/source/lib/alignment.h
--- source/lib/alignment.h.orig	2021-02-05 21:27:39.000000000 -0300
+++ source/lib/alignment.h	2021-02-22 11:34:59.732985282 -0300
@@ -80,7 +80,18 @@ static const size_t cacheLineSize = 64;
 // MMU pages
 //
 
+#ifdef __PPC64__
+// NOTE: ppc64 can operate in either 4k or 64k page size mode
+// If the define page size is larger than the active page size,
+// the allocator functions normally.  If the defined page size
+// is less than the active page size, the allocator fails tests.
+//
+// Define the page size to the maximum known architectural page
+// size on ppc64 systems.
+static const size_t g_PageSize = 64 * 1024;	// 64 KB
+#else
 static const size_t g_PageSize = 4 * 1024;	// 4 KB
+#endif
 static const size_t g_LargePageSize = 2 * 1024 * 1024;	// 2 MB
 
 
diff -up source/lib/byte_order.h.orig source/lib/byte_order.h
--- source/lib/byte_order.h.orig	2021-02-22 11:36:38.175565765 -0300
+++ source/lib/byte_order.h	2021-02-22 11:36:40.309578350 -0300
@@ -33,7 +33,7 @@
 #ifndef BYTE_ORDER
 # define LITTLE_ENDIAN 0x4321
 # define BIG_ENDIAN    0x1234
-# if ARCH_IA32 || ARCH_IA64 || ARCH_AMD64 || ARCH_ALPHA || ARCH_ARM || ARCH_AARCH64 || ARCH_MIPS || ARCH_E2K || defined(__LITTLE_ENDIAN__)
+# if ARCH_IA32 || ARCH_IA64 || ARCH_AMD64 || ARCH_ALPHA || ARCH_ARM || ARCH_AARCH64 || ARCH_MIPS || ARCH_E2K || ARCH_PPC64 || defined(__LITTLE_ENDIAN__)
 #  define BYTE_ORDER LITTLE_ENDIAN
 # else
 #  define BYTE_ORDER BIG_ENDIAN
diff -up source/lib/sysdep/arch.h.orig source/lib/sysdep/arch.h
--- source/lib/sysdep/arch.h.orig	2021-02-22 11:37:17.024806390 -0300
+++ source/lib/sysdep/arch.h	2021-02-22 11:37:58.422078693 -0300
@@ -76,9 +76,14 @@
 #else
 # define ARCH_E2K 0
 #endif
+#if defined(__PPC64__)
+# define ARCH_PPC64 1
+#else
+# define ARCH_PPC64 0
+#endif
 
 // ensure exactly one architecture has been detected
-#if (ARCH_IA32+ARCH_IA64+ARCH_AMD64+ARCH_ALPHA+ARCH_ARM+ARCH_AARCH64+ARCH_MIPS+ARCH_E2K) != 1
+#if (ARCH_IA32+ARCH_IA64+ARCH_AMD64+ARCH_ALPHA+ARCH_ARM+ARCH_AARCH64+ARCH_MIPS+ARCH_E2K+ARCH_PPC64) != 1
 # error "architecture not correctly detected (either none or multiple ARCH_* defined)"
 #endif
 
diff -up source/lib/sysdep/arch/ppc64/ppc64.cpp.orig source/lib/sysdep/arch/ppc64/ppc64.cpp
--- source/lib/sysdep/arch/ppc64/ppc64.cpp.orig	2021-02-22 11:38:58.646474826 -0300
+++ source/lib/sysdep/arch/ppc64/ppc64.cpp	2021-02-22 11:39:24.742646481 -0300
@@ -0,0 +1,50 @@
+/* Copyright (C) 2012 Wildfire Games
+ * Copyright (C) 2018 Raptor Engineering, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * routines specific to POWER
+ */
+
+#include "precompiled.h"
+
+#include "lib/sysdep/cpu.h"
+
+intptr_t cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment)
+{
+	return __sync_fetch_and_add(location, increment);
+}
+
+bool cpu_CAS(volatile intptr_t* location, intptr_t expected, intptr_t newValue)
+{
+	return __sync_bool_compare_and_swap(location, expected, newValue);
+}
+
+bool cpu_CAS64(volatile i64* location, i64 expected, i64 newValue)
+{
+	return __sync_bool_compare_and_swap(location, expected, newValue);
+}
+
+const char* cpu_IdentifierString()
+{
+	return "IBM POWER"; // TODO
+}
diff -up source/ps/GameSetup/HWDetect.cpp.orig source/ps/GameSetup/HWDetect.cpp
--- source/ps/GameSetup/HWDetect.cpp.orig	2021-02-22 11:39:36.360722903 -0300
+++ source/ps/GameSetup/HWDetect.cpp	2021-02-22 11:40:11.454953744 -0300
@@ -124,6 +124,7 @@ void RunHardwareDetection()
 	scriptInterface.SetProperty(settings, "arch_arm", ARCH_ARM);
 	scriptInterface.SetProperty(settings, "arch_aarch64", ARCH_AARCH64);
 	scriptInterface.SetProperty(settings, "arch_e2k", ARCH_E2K);
+	scriptInterface.SetProperty(settings, "arch_ppc64", ARCH_PPC64);
 
 #ifdef NDEBUG
 	scriptInterface.SetProperty(settings, "build_debug", 0);