Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r69802:af15056321f7
Date: 2014-03-08 13:20 +0100
http://bitbucket.org/pypy/pypy/changeset/af15056321f7/

Log:    in-progress

diff --git a/rpython/translator/c/src/debug_print.c 
b/rpython/translator/c/src/debug_print.c
--- a/rpython/translator/c/src/debug_print.c
+++ b/rpython/translator/c/src/debug_print.c
@@ -162,18 +162,17 @@
 }
 
 #ifdef RPY_STM
-# include <src_stm/atomic_ops.h>
-# include <src_stm/fprintcolor.h>
+# include <src_stm/stm/fprintcolor.h>
+# define bool_cas __sync_bool_compare_and_swap
 #else
-  typedef long revision_t;
 # define bool_cas(vp, o, n) (*(vp)=(n), 1)
 # define dprintfcolor() 0
 #endif
-static revision_t threadcounter = 0;
+static Signed threadcounter = 0;
 
 static void _prepare_display_colors(void)
 {
-    revision_t counter;
+    Signed counter;
     char *p;
     while (1) {
         counter = threadcounter;
diff --git a/rpython/translator/c/src/g_prerequisite.h 
b/rpython/translator/c/src/g_prerequisite.h
--- a/rpython/translator/c/src/g_prerequisite.h
+++ b/rpython/translator/c/src/g_prerequisite.h
@@ -21,3 +21,10 @@
 # define RPY_LENGTH0     1       /* array decl [0] are bad */
 # define RPY_DUMMY_VARLENGTH     /* nothing */
 #endif
+
+
+#ifdef RPY_STM
+#define rpy_duck()  asm("":::"memory")   // work around an llvm bug :-/
+#else
+#define rpy_duck()  /* nothing */
+#endif
diff --git a/rpython/translator/c/src/mem.c b/rpython/translator/c/src/mem.c
--- a/rpython/translator/c/src/mem.c
+++ b/rpython/translator/c/src/mem.c
@@ -46,7 +46,7 @@
 
 #ifdef RPY_STM
 // spinlock_acquire/spinlock_release defined in ../../stm/src_stm/stmgcintf.h
-static revision_t pypy_debug_alloc_lock = 0;
+static Signed pypy_debug_alloc_lock = 0;
 #else
 # define spinlock_acquire(lock, targetvalue)  /* nothing */
 # define spinlock_release(lock)               /* nothing */
diff --git a/rpython/translator/c/src/rtyper.c 
b/rpython/translator/c/src/rtyper.c
--- a/rpython/translator/c/src/rtyper.c
+++ b/rpython/translator/c/src/rtyper.c
@@ -22,17 +22,18 @@
 
 char *RPyString_AsCharP(RPyString *rps)
 {
-#ifdef RPY_STM
-       rps = (RPyString *)stm_read_barrier((gcptr)rps);
-#endif
-       Signed len = RPyString_Size(rps);
+       Signed i, len = RPyString_Size(rps);
        struct _RPyString_dump_t *dump = \
                        malloc(sizeof(struct _RPyString_dump_t) + len);
        if (!dump)
                return "(out of memory!)";
        dump->next = _RPyString_dump;
        _RPyString_dump = dump;
-       memcpy(dump->data, rps->rs_chars.items, len);
+       /* can't use memcpy() in case of stm */
+       for (i = 0; i < len; i++) {
+           dump->data[i] = rps->rs_chars.items[i];
+            rpy_duck();
+        }
        dump->data[len] = 0;
        return dump->data;
 }
@@ -48,8 +49,12 @@
 
 RPyString *RPyString_FromString(char *buf)
 {
-       int length = strlen(buf);
+       int i, length = strlen(buf);
        RPyString *rps = RPyString_New(length);
-       memcpy(rps->rs_chars.items, buf, length);
+       /* can't use memcpy() in case of stm */
+       for (i = 0; i < length; i++) {
+           rps->rs_chars.items[i] = buf[i];
+            rpy_duck();
+        }
        return rps;
 }
diff --git a/rpython/translator/stm/src_stm/stmgcintf.c 
b/rpython/translator/stm/src_stm/stmgcintf.c
--- a/rpython/translator/stm/src_stm/stmgcintf.c
+++ b/rpython/translator/stm/src_stm/stmgcintf.c
@@ -1,4 +1,5 @@
-#include "src_stm/stmgcintf.h"
+/* This is not meant to be compiled stand-alone, but with all
+   of PyPy's #defines and #includes prepended. */
 
 __thread struct stm_thread_local_s stm_thread_local;
 
diff --git a/rpython/translator/stm/src_stm/stmgcintf.h 
b/rpython/translator/stm/src_stm/stmgcintf.h
--- a/rpython/translator/stm/src_stm/stmgcintf.h
+++ b/rpython/translator/stm/src_stm/stmgcintf.h
@@ -1,3 +1,7 @@
+#ifndef _RPY_STMGCINTF_H
+#define _RPY_STMGCINTF_H
+
+
 /* meant to be #included after src_stm/stmgc.h */
 
 #include "stmgc.h"
@@ -25,3 +29,6 @@
 # define spinlock_release(lock)                                 \
     do { write_fence(); assert((lock) != 0); (lock) = 0; } while (0)
 #endif
+
+
+#endif  /* _RPY_STMGCINTF_H */
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to