File 1135-Enable-use-of-lwsync-on-64-bit-ppc.patch of Package erlang

From 1ee8e107855f9b4779d8d53063829a31b14a6d9e Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Fri, 12 Feb 2021 15:40:00 +0100
Subject: [PATCH 1/2] Enable use of lwsync on 64-bit ppc

---
 erts/aclocal.m4                               | 29 +++++++++++++++++++
 .../internal/ethread_header_config.h.in       |  6 ++++
 2 files changed, 35 insertions(+)

diff --git a/erts/aclocal.m4 b/erts/aclocal.m4
index d237f7ae08..bd7d047725 100644
--- a/erts/aclocal.m4
+++ b/erts/aclocal.m4
@@ -1495,6 +1495,33 @@ AC_ARG_WITH(with_sparc_memory_order,
 	    AS_HELP_STRING([--with-sparc-memory-order=TSO|PSO|RMO],
 			   [specify sparc memory order (defaults to RMO)]))
 
+AC_ARG_ENABLE(ppc-lwsync-instruction,
+AS_HELP_STRING([--enable-ppc-lwsync-instruction], [enable use of powerpc lwsync instruction])
+AS_HELP_STRING([--disable-ppc-lwsync-instruction], [disable use of powerpc lwsync instruction]),
+[ case "$enableval" in
+    no) enable_lwsync=no ;;
+    *)  enable_lwsync=yes ;;
+  esac ],
+[
+  AC_CHECK_SIZEOF(void *)
+  case $host_cpu-$ac_cv_sizeof_void_p in
+       macppc-8|powerpc-8|ppc-8|powerpc64-8|ppc64-8|powerpc64le-8|ppc64le-8|"Power Macintosh"-8)
+           enable_lwsync=yes;;
+       *)
+           enable_lwsync=undefined;;
+  esac ])
+
+case $enable_lwsync in
+     no)
+       AC_DEFINE(ETHR_PPC_HAVE_NO_LWSYNC, [1], [Define if you do not have the powerpc lwsync instruction])
+       ;;
+     yes)
+       AC_DEFINE(ETHR_PPC_HAVE_LWSYNC, [1], [Define if you have the powerpc lwsync instruction])
+       ;;
+     *)
+       ;;
+esac
+
 LM_CHECK_THR_LIB
 ERL_INTERNAL_LIBS
 
diff --git a/erts/configure.in b/erts/configure.in
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -660,6 +660,8 @@ case $chk_arch_ in
     ppc)	ARCH=ppc;;
     ppc64)	ARCH=ppc64;;
     ppc64le)	ARCH=ppc64le;;
+    powerpc64)	ARCH=ppc64;;
+    powerpc64le) ARCH=ppc64le;;
     "Power Macintosh")	ARCH=ppc;;
     armv5b)	ARCH=arm;;
     armv5teb)	ARCH=arm;;
diff --git a/erts/include/internal/ethread_header_config.h.in b/erts/include/internal/ethread_header_config.h.in
index 6309f10439..a64ba32a20 100644
--- a/erts/include/internal/ethread_header_config.h.in
+++ b/erts/include/internal/ethread_header_config.h.in
@@ -76,6 +76,12 @@
 /* Define if x86/x86_64 out of order instructions should be synchronized */
 #undef ETHR_X86_OUT_OF_ORDER
 
+/* Define if you have the powerpc lwsync instruction */
+#undef ETHR_PPC_HAVE_LWSYNC
+
+/* Define if you do not have the powerpc lwsync instruction */
+#undef ETHR_PPC_HAVE_NO_LWSYNC
+
 /* Define if only run in Sparc TSO mode */
 #undef ETHR_SPARC_TSO
 
-- 
2.26.2

openSUSE Build Service is sponsored by