[pypy-commit] pypy stm: Bah. Temporary workaround: can't use bool_t because casting to

arigo noreply at buildbot.pypy.org
Fri Jan 20 10:03:09 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r51512:3bb490226684
Date: 2012-01-20 00:16 +0100
http://bitbucket.org/pypy/pypy/changeset/3bb490226684/

Log:	Bah. Temporary workaround: can't use bool_t because casting to a
	bool_t has unexpected results for stm_*_partial_word()

diff --git a/pypy/translator/c/src/g_prerequisite.h b/pypy/translator/c/src/g_prerequisite.h
--- a/pypy/translator/c/src/g_prerequisite.h
+++ b/pypy/translator/c/src/g_prerequisite.h
@@ -19,7 +19,7 @@
 #include <stddef.h>
 
 
-#ifdef __GNUC__       /* other platforms too, probably */
+#if 0 //def __GNUC__       /* other platforms too, probably */  XXX FIX ME
 typedef _Bool bool_t;
 #else
 typedef unsigned char bool_t;
diff --git a/pypy/translator/stm/src_stm/et.c b/pypy/translator/stm/src_stm/et.c
--- a/pypy/translator/stm/src_stm/et.c
+++ b/pypy/translator/stm/src_stm/et.c
@@ -513,6 +513,9 @@
 long stm_read_word(long* addr)
 {
   struct tx_descriptor *d = thread_descriptor;
+#ifdef RPY_STM_ASSERT
+  assert((((long)addr) & (sizeof(void*)-1)) == 0);
+#endif
   if (!d->transaction_active)
     return *addr;
 
@@ -576,6 +579,7 @@
 void stm_write_word(long* addr, long val)
 {
   struct tx_descriptor *d = thread_descriptor;
+  assert((((long)addr) & (sizeof(void*)-1)) == 0);
   if (!d->transaction_active) {
     *addr = val;
     return;
@@ -864,7 +868,7 @@
 unsigned long stm_read_partial_word(int fieldsize, void *addr)
 {
   int misalignment = ((long)addr) & (sizeof(void*)-1);
-  long *p = (long*)((char *)addr - misalignment);
+  long *p = (long*)(((char *)addr) - misalignment);
   unsigned long word = stm_read_word(p);
   return word >> (misalignment * 8);
 }
@@ -873,7 +877,7 @@
 void stm_write_partial_word(int fieldsize, void *addr, unsigned long nval)
 {
   int misalignment = ((long)addr) & (sizeof(void*)-1);
-  long *p = (long*)((char *)addr - misalignment);
+  long *p = (long*)(((char *)addr) - misalignment);
   long val = nval << (misalignment * 8);
   long word = stm_read_word(p);
   long mask = ((1L << (fieldsize * 8)) - 1) << (misalignment * 8);
diff --git a/pypy/translator/stm/test/test_llstm.py b/pypy/translator/stm/test/test_llstm.py
--- a/pypy/translator/stm/test/test_llstm.py
+++ b/pypy/translator/stm/test/test_llstm.py
@@ -97,7 +97,13 @@
     assert float(stm_getfield(a, 'sb')) == float(rs1b)
     stm_setfield(a, 'x', 42 * a.y)
     stm_setfield(a, 'c1', '(')
+    assert stm_getfield(a, 'c1') == '('
+    assert stm_getfield(a, 'c2') == '*'
+    assert stm_getfield(a, 'c3') == '#'
     stm_setfield(a, 'c2', '?')
+    assert stm_getfield(a, 'c1') == '('
+    assert stm_getfield(a, 'c2') == '?'
+    assert stm_getfield(a, 'c3') == '#'
     stm_setfield(a, 'c3', ')')
     stm_setfield(a, 'l', rll2)
     stm_setfield(a, 'f', rf2)


More information about the pypy-commit mailing list