Tue Feb 19 15:18:19 2019 UTC ()
Add support for mutexes on aarch64 with GCC via databases/db4.


(hauke)
diff -r1.7 -r1.8 pkgsrc/databases/db5/patches/patch-ab
diff -r0 -r1.1 pkgsrc/databases/db5/patches/patch-dist_config.bin
diff -r0 -r1.1 pkgsrc/databases/db5/patches/patch-src_dbinc_mutex_int.h

cvs diff -r1.7 -r1.8 pkgsrc/databases/db5/patches/patch-ab (expand / switch to unified diff)

--- pkgsrc/databases/db5/patches/patch-ab 2016/08/26 12:40:25 1.7
+++ pkgsrc/databases/db5/patches/patch-ab 2019/02/19 15:18:19 1.8
@@ -1,16 +1,22 @@ @@ -1,16 +1,22 @@
1$NetBSD: patch-ab,v 1.7 2016/08/26 12:40:25 richard Exp $ 1$NetBSD: patch-ab,v 1.8 2019/02/19 15:18:19 hauke Exp $
2 2
3--- dist/configure.orig 2012-05-11 17:57:48.000000000 +0000 3Fix bashisms.
 4
 5FreeBSD 10 is not FreeBSD 1.
 6
 7Add support for mutexes on aarch64 with GCC.
 8
 9--- dist/configure.orig 2013-09-09 15:35:02.000000000 +0000
4+++ dist/configure 10+++ dist/configure
5@@ -5112,7 +5112,7 @@ bsdi3*) CC=${CC-"shlicc2"} 11@@ -5112,7 +5112,7 @@ bsdi3*) CC=${CC-"shlicc2"}
6 LIBSO_LIBS="$LIBSO_LIBS -lipc";; 12 LIBSO_LIBS="$LIBSO_LIBS -lipc";;
7 cygwin*) 13 cygwin*)
8 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_REENTRANT";; 14 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_REENTRANT";;
9-freebsd*) 15-freebsd*)
10+freebsd*|dragonfly*) 16+freebsd*|dragonfly*)
11 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" 17 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
12 LDFLAGS="$LDFLAGS -pthread";; 18 LDFLAGS="$LDFLAGS -pthread";;
13 gnu*|k*bsd*-gnu|linux*) 19 gnu*|k*bsd*-gnu|linux*)
14@@ -6905,7 +6905,7 @@ fi 20@@ -6905,7 +6905,7 @@ fi
15 # we're using. 21 # we're using.
16 case "$host_os" in 22 case "$host_os" in
@@ -91,13 +97,56 @@ $NetBSD: patch-ab,v 1.7 2016/08/26 12:40 @@ -91,13 +97,56 @@ $NetBSD: patch-ab,v 1.7 2016/08/26 12:40
91+ freebsd*|dragonfly*) _JNI_INC_SUBDIRS="freebsd";; 97+ freebsd*|dragonfly*) _JNI_INC_SUBDIRS="freebsd";;
92 hp*) _JNI_INC_SUBDIRS="hp-ux";; 98 hp*) _JNI_INC_SUBDIRS="hp-ux";;
93 linux*) _JNI_INC_SUBDIRS="linux genunix";; 99 linux*) _JNI_INC_SUBDIRS="linux genunix";;
94 osf*) _JNI_INC_SUBDIRS="alpha";; 100 osf*) _JNI_INC_SUBDIRS="alpha";;
95@@ -20565,7 +20565,7 @@ if test "$db_cv_mutex" = no; then 101@@ -20565,7 +20565,7 @@ if test "$db_cv_mutex" = no; then
96 # avoid these probes for multiprocess pthreads. 102 # avoid these probes for multiprocess pthreads.
97 ;; 103 ;;
98 *) 104 *)
99- if test "$db_cv_mutex" = no -o "$db_cv_mutex" = posix_only; then 105- if test "$db_cv_mutex" = no -o "$db_cv_mutex" = posix_only; then
100+ if test "$ac_cv_lib_pthread_main" = yes -a "$db_cv_mutex" = no -o "$db_cv_mutex" = posix_only; then 106+ if test "$ac_cv_lib_pthread_main" = yes -a "$db_cv_mutex" = no -o "$db_cv_mutex" = posix_only; then
101 LIBS="$LIBS -lpthread" 107 LIBS="$LIBS -lpthread"
102  108
103 if test "$cross_compiling" = yes; then : 109 if test "$cross_compiling" = yes; then :
 110@@ -21796,6 +21796,31 @@ fi
 111 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 112 fi
 113
 114+# AARCH64/gcc: Linux
 115+if test "$db_cv_mutex" = no; then
 116+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 117+/* end confdefs.h. */
 118+
 119+int
 120+main ()
 121+{
 122+
 123+#if defined(__aarch64__) && defined(__GNUC__)
 124+ exit(0);
 125+#else
 126+ FAIL TO COMPILE/LINK
 127+#endif
 128+
 129+ ;
 130+ return 0;
 131+}
 132+_ACEOF
 133+if ac_fn_c_try_compile "$LINENO"; then :
 134+ db_cv_mutex=AARCH64/gcc-assembly
 135+fi
 136+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 137+fi
 138+
 139 # MIPS/gcc: Linux
 140 if test "$db_cv_mutex" = no; then
 141 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 142@@ -22124,6 +22149,10 @@ ARM/gcc-assembly) ADDITIONAL_OBJS="mut_t
 143 $as_echo "#define HAVE_MUTEX_ARM_GCC_ASSEMBLY 1" >>confdefs.h
 144
 145 ;;
 146+AARCH64/gcc-assembly) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS"
 147+ $as_echo "#define HAVE_MUTEX_AARCH64_GCC_ASSEMBLY 1" >>confdefs.h
 148+
 149+ ;;
 150 HP/msem_init) ADDITIONAL_OBJS="mut_tas${o} $ADDITIONAL_OBJS"
 151 $as_echo "#define HAVE_MUTEX_HPPA_MSEM_INIT 1" >>confdefs.h
 152

File Added: pkgsrc/databases/db5/patches/patch-dist_config.bin
$NetBSD: patch-dist_config.bin,v 1.1 2019/02/19 15:18:19 hauke Exp $

Add support for mutexes on aarch64 with GCC.

--- dist/config.hin.orig	2010-04-12 20:25:23.000000000 +0000
+++ dist/config.hin
@@ -212,6 +212,9 @@
 /* Define to 1 to use the GCC compiler and ARM assembly language mutexes. */
 #undef HAVE_MUTEX_ARM_GCC_ASSEMBLY
 
+/* Define to 1 to use the GCC compiler and AARCH64 assembly language mutexes. */
+#undef HAVE_MUTEX_AARCH64_GCC_ASSEMBLY
+
 /* Define to 1 to use the Apple/Darwin _spin_lock_try mutexes. */
 #undef HAVE_MUTEX_DARWIN_SPIN_LOCK_TRY
 

File Added: pkgsrc/databases/db5/patches/patch-src_dbinc_mutex_int.h
$NetBSD: patch-src_dbinc_mutex_int.h,v 1.1 2019/02/19 15:18:19 hauke Exp $

* adds support for mutexes on aarch64
* fixes build failure on MIPS arch with -mips1.

--- src/dbinc/mutex_int.h.orig	2010-04-12 20:25:22.000000000 +0000
+++ src/dbinc/mutex_int.h
@@ -491,6 +491,43 @@ typedef unsigned char tsl_t;
 #endif
 
 /*********************************************************************
+ * AARCH64/gcc assembly.
+ *********************************************************************/
+
+#ifdef HAVE_MUTEX_AARCH64_GCC_ASSEMBLY
+typedef unsigned int tsl_t;
+
+#ifdef LOAD_ACTUAL_MUTEX_CODE
+static inline int
+MUTEX_SET(tsl_t *tsl) {
+	register tsl_t *__l = tsl;
+	register tsl_t __r;
+	__asm__ volatile(
+		"1:	ldxr	%w0,[%1]\n"
+		"	cbnz	%w0,2f\n"
+		"	stxr	%w0,%w2,[%1]\n"
+		"	cbnz	%w0,1b\n"
+		"	dmb	st\n"
+		"2:"
+		: "=&r"(__r)
+		: "r"(__l), "r"(1)
+		: "memory");
+
+	return !__r;
+}
+
+static inline int
+MUTEX_UNSET(tsl_t *tsl) {
+	__asm__ volatile(
+		"	dsb	sy\n" ::: "memory");
+	return *tsl = 0;
+}
+
+#define	MUTEX_INIT(tsl)		(MUTEX_UNSET(tsl), 0)
+#endif
+#endif
+
+/*********************************************************************
  * HPPA/gcc assembly.
  *********************************************************************/
 #ifdef HAVE_MUTEX_HPPA_GCC_ASSEMBLY
@@ -778,10 +815,14 @@ MUTEX_SET(tsl_t *tsl) {
 static inline void
 MUTEX_UNSET(tsl_t *tsl) {
 	__asm__ volatile(
+	       "       .set push           \n"
+	       "       .set mips2          \n"
 	       "       .set noreorder      \n"
+	       "       .set nomacro        \n"
 	       "       sync                \n"
 	       "       sw      $0, %0      \n"
 	       "       .set reorder        \n"
+	       "       .set pop            \n"
 	       : "=m" (*tsl)
 	       : "m" (*tsl)
 	       : "memory");