Author: Armin Rigo <[email protected]>
Branch: stmgc-c8
Changeset: r78237:c75627b708d5
Date: 2015-06-21 22:09 +0200
http://bitbucket.org/pypy/pypy/changeset/c75627b708d5/

Log:    Try to add 'unsafe_write_int32' to experiment with it

diff --git a/pypy/module/pypystm/__init__.py b/pypy/module/pypystm/__init__.py
--- a/pypy/module/pypystm/__init__.py
+++ b/pypy/module/pypystm/__init__.py
@@ -29,4 +29,6 @@
         'stmdict': 'stmdict.W_STMDict',
         'queue': 'queue.W_Queue',
         'Empty': 'space.fromcache(queue.Cache).w_Empty',
+
+        'unsafe_write_int32': 'unsafe_op.unsafe_write_int32',
     }
diff --git a/pypy/module/pypystm/unsafe_op.py b/pypy/module/pypystm/unsafe_op.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypystm/unsafe_op.py
@@ -0,0 +1,13 @@
+from pypy.interpreter.gateway import unwrap_spec
+from pypy.module._cffi_backend import cdataobj
+from rpython.rlib.rstm import stm_ignored
+from rpython.rtyper.lltypesystem import rffi
+
+
+@unwrap_spec(w_cdata=cdataobj.W_CData, index=int, value='c_int')
+def unsafe_write_int32(space, w_cdata, index, value):
+    with w_cdata as ptr:
+        ptr = rffi.cast(rffi.INTP, rffi.ptradd(ptr, index * 4))
+        value = rffi.cast(rffi.INT, value)
+        with stm_ignored:
+            ptr[0] = value
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to