[pypy-svn] r27478 - in pypy/dist/pypy/rpython/lltypesystem: . test
mwh at codespeak.net
mwh at codespeak.net
Fri May 19 16:43:41 CEST 2006
Author: mwh
Date: Fri May 19 16:43:39 2006
New Revision: 27478
Modified:
pypy/dist/pypy/rpython/lltypesystem/llheap.py
pypy/dist/pypy/rpython/lltypesystem/llmemory.py
pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
Log:
implement llmemory.raw_memcopy by using existing code that does the donkey work
in rctypes.
Modified: pypy/dist/pypy/rpython/lltypesystem/llheap.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llheap.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/llheap.py Fri May 19 16:43:39 2006
@@ -2,4 +2,5 @@
from pypy.rpython.lltypesystem.lltype import pyobjectptr, malloc, free
from pypy.rpython.lltypesystem.llmemory import raw_malloc, raw_free
+from pypy.rpython.lltypesystem.llmemory import raw_memcopy
from pypy.rpython.lltypesystem.llmemory import raw_malloc_usage
Modified: pypy/dist/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/llmemory.py Fri May 19 16:43:39 2006
@@ -510,6 +510,14 @@
size = convert_offset_to_int(size)
return size
+def raw_memcopy(source, dest, size):
+ source = source.get()
+ dest = dest.get()
+ # this check would be nice...
+ #assert sizeof(lltype.typeOf(source)) == sizeof(lltype.typeOf(dest)) == size
+ from pypy.rpython.rctypes.rmodel import reccopy
+ reccopy(source, dest)
+
# ____________________________________________________________
class _arena(object):
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py Fri May 19 16:43:39 2006
@@ -392,6 +392,17 @@
repr(adr)
str(p_u)
+def test_raw_memcopy():
+ T = lltype.GcStruct('T', ('x', lltype.Signed))
+ t1 = lltype.malloc(T)
+ t2 = lltype.malloc(T)
+ t1.x = 1
+ t2.x = 2
+ at1 = cast_ptr_to_adr(t1)
+ at2 = cast_ptr_to_adr(t2)
+ raw_memcopy(at1, at2, sizeof(T))
+ assert t2.x == 1
+
def test_inlined_substruct():
T = lltype.Struct('T', ('x', lltype.Signed))
S1 = lltype.GcStruct('S1', ('t1', T), ('t2', T))
More information about the Pypy-commit
mailing list