[Gc] mips support broken in gc-7.x (and other pending patches)

Thiemo Seufer ths at networkno.de
Mon Jun 2 12:04:03 PDT 2008


Boehm, Hans wrote:
> Thanks!  That helps a lot.  A lot of those indeed hadn't made it, but I checked them in now.  (Patch 06 had been independently half applied.  The PowerPC patch had been applied, as had the x86 PIC patch.)
> 
> I also checked in the pending patch for thread-local allocation with DONT_ADD_BYTE_AT_END.  I think there was still some dount about whether that patch is complete.  But I can no longer reproduce the problem with it.

The mips part is still incomplete, it seems. I need the attached three
patches on top of current CVS, one of them addresses the test suite
failures Christian spotted. (The Linux/MIPS glibc has no getcontext
implemented.)

All tests pass on Linux/MIPS with this patchset.


Thiemo
-------------- next part --------------
Index: bdwgc/include/private/gcconfig.h
===================================================================
--- bdwgc.orig/include/private/gcconfig.h	2008-05-31 02:10:15.000000000 +0100
+++ bdwgc/include/private/gcconfig.h	2008-05-31 02:10:39.000000000 +0100
@@ -1316,24 +1316,18 @@
 # ifdef MIPS
 #   define MACH_TYPE "MIPS"
 #   ifdef LINUX
-      /* This was developed for a linuxce style platform.  Probably	*/
-      /* needs to be tweaked for workstation class machines.		*/
 #     define OS_TYPE "LINUX"
 #     define DYNAMIC_LOADING
       extern int _end[];
 #     define DATAEND (_end)
       extern int __data_start[];
 #     define DATASTART ((ptr_t)(__data_start))
-#     ifdef _MIPS_SZPTR
-#	define CPP_WORDSZ _MIPS_SZPTR
-#	define ALIGNMENT (_MIPS_SZPTR/8)
-#     else
-#	define ALIGNMENT 4
-#     endif
+#     define CPP_WORDSZ _MIPS_SZPTR
+#     define ALIGNMENT (_MIPS_SZPTR/8)
 #     if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
-#        define LINUX_STACKBOTTOM
+#       define LINUX_STACKBOTTOM
 #     else
-#        define STACKBOTTOM 0x80000000
+#       define STACKBOTTOM ((ptr_t)0x7fff8000)
 #     endif
 #   endif /* Linux */
 #   ifdef EWS4800
-------------- next part --------------
Index: bdwgc/mach_dep.c
===================================================================
--- bdwgc.orig/mach_dep.c	2008-06-02 19:52:02.000000000 +0100
+++ bdwgc/mach_dep.c	2008-06-02 19:52:23.000000000 +0100
@@ -175,7 +175,7 @@
 #   if defined(HAVE_PUSH_REGS)
       GC_push_regs();
 #   elif defined(UNIX_LIKE) && !defined(DARWIN) && !defined(ARM32) && \
-	 !defined(HURD)
+	 !defined(MIPS) && !defined(HURD)
       /* Older versions of Darwin seem to lack getcontext(). */
       /* ARM Linux often doesn't support a real getcontext(). */
       ucontext_t ctxt;
-------------- next part --------------
Package: libatomic-ops
Version: 1.2-2
Tags: patch

This is an update of the mips patch. It now covers weakly ordered
systems as allowed by the architecture definition, and also fixes
some minor omissions.

This update fixes the FTBFS of pulseaudio on mips/mipsel.


Thiemo


Index: bdwgc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/mips.h
===================================================================
--- bdwgc.orig/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/mips.h	2008-06-02 19:53:17.000000000 +0100
+++ bdwgc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/mips.h	2008-06-02 19:55:43.000000000 +0100
@@ -1,52 +1,97 @@
 /*
- * Copyright (c) 2008 Hewlett-Packard Development Company, L.P.
- * 
- * 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. 
+ * Copyright (c) 2005,2007  Thiemo Seufer <ths at networkno.de>
  *
- */ 
-???? needs work
-
-#include "../all_atomic_load_store.h"
-
-??? What is mips memory ordering anyway???
-
-#define AO_TS_t int
-
-#    ifdef LINUX
-#      include <sys/tas.h>
-#      define GC_test_and_set(addr) _test_and_set((int *) addr,1)
-#      define GC_TEST_AND_SET_DEFINED
-#    elif __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) \
-	|| !defined(_COMPILER_VERSION) || _COMPILER_VERSION < 700
-#	 ifdef __GNUC__
-#          define GC_test_and_set(addr) _test_and_set((void *)addr,1)
-#	 else
-#          define GC_test_and_set(addr) test_and_set((void *)addr,1)
-#	 endif
-#    else
-#	 include <sgidefs.h>
-#	 include <mutex.h>
-#	 define GC_test_and_set(addr) __test_and_set32((void *)addr,1)
-#	 define GC_clear(addr) __lock_release(addr);
-#	 define GC_CLEAR_DEFINED
-#    endif
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include "../all_aligned_atomic_load_store.h"
+#include "../acquire_release_volatile.h"
+#include "../test_and_set_t_is_ao_t.h"
+#include "../standard_ao_double_t.h"
+
+/* Data dependence does not imply read ordering.  */
+#define AO_NO_DD_ORDERING
+
+AO_INLINE void
+AO_nop_full()
+{
+  __asm__ __volatile__(
+      "       .set push           \n"
+      "       .set mips2          \n"
+      "       .set noreorder      \n"
+      "       .set nomacro        \n"
+      "       sync                \n"
+      "       .set pop              "
+      : : : "memory");
+}
+
+#define AO_HAVE_nop_full
+
+AO_INLINE int
+AO_compare_and_swap(volatile AO_t *addr, AO_t old, AO_t new_val)
+{
+  register int was_equal = 0;
+  register int temp;
+
+  __asm__ __volatile__(
+      "       .set push           \n"
+      "       .set mips2          \n"
+      "       .set noreorder      \n"
+      "       .set nomacro        \n"
+      "1:     ll      %0, %1      \n"
+      "       bne     %0, %4, 2f  \n"
+      "        move   %0, %3      \n"
+      "       sc      %0, %1      \n"
+      "       .set pop            \n"
+      "       beqz    %0, 1b      \n"
+      "       li      %2, 1       \n"
+      "2:                           "
+      : "=&r" (temp), "+R" (*addr), "+r" (was_equal)
+      : "r" (new_val), "r" (old)
+      : "memory");
+  return was_equal;
+}
+
+#define AO_HAVE_compare_and_swap
+
+AO_INLINE int
+AO_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val) {
+  int result = AO_compare_and_swap(addr, old, new_val);
+  AO_nop_full();
+  return result;
+}
+
+#define AO_HAVE_compare_and_swap_acquire
+
+AO_INLINE int
+AO_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val) {
+  AO_nop_full();
+  return AO_compare_and_swap(addr, old, new_val);
+}
+
+#define AO_HAVE_compare_and_swap_release
+
+AO_INLINE int
+AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val) {
+  AO_t result;
+  AO_nop_full();
+  result = AO_compare_and_swap(addr, old, new_val);
+  AO_nop_full();
+  return result;
+}
 
+#define AO_HAVE_compare_and_swap_full
 
-#define AO_HAVE_test_and_set_full
+/*
+ * FIXME: We should also implement fetch_and_add and or primitives
+ * directly.
+ */
 
+#include "../ao_t_is_int.h"


More information about the Gc mailing list