[pypy-commit] pypy default: switch from using rffi to call memcpy form C to using rgc.ll_arraycopy (which works for non-gc arrays apparently)

alex_gaynor noreply at buildbot.pypy.org
Thu Jul 7 23:19:22 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r45411:5d2970523f79
Date: 2011-07-07 14:28 -0700
http://bitbucket.org/pypy/pypy/changeset/5d2970523f79/

Log:	switch from using rffi to call memcpy form C to using
	rgc.ll_arraycopy (which works for non-gc arrays apparently)

diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -11,12 +11,11 @@
 from pypy.objspace.std.stdtypedef import SMM, StdTypeDef
 from pypy.objspace.std.register_all import register_all
 from pypy.rlib.rarithmetic import ovfcheck
+from pypy.rlib.rgc import ll_arraycopy
 from pypy.rlib.unroll import unrolling_iterable
 from pypy.rpython.lltypesystem import lltype, rffi
 
 
-memcpy = rffi.llexternal("memcpy", [rffi.VOIDP, rffi.VOIDP, rffi.SIZE_T], lltype.Void)
-
 @unwrap_spec(typecode=str)
 def w_array(space, w_cls, typecode, __args__):
     if len(__args__.arguments_w) > 1:
@@ -621,10 +620,12 @@
     def array_copy__Array(space, self):
         w_a = mytype.w_class(self.space)
         w_a.setlen(self.len)
-        memcpy(
-            rffi.cast(rffi.VOIDP, w_a.buffer),
-            rffi.cast(rffi.VOIDP, self.buffer),
-            self.len * mytype.bytes
+        ll_arraycopy(
+            self.buffer,
+            w_a.buffer,
+            0,
+            0,
+            self.len,
         )
         return w_a
 


More information about the pypy-commit mailing list