[pypy-svn] r48942 - in pypy/branch/remove-extcompiler-rctypes/pypy: jit/codegen/i386 jit/codegen/ppc module/signal rpython rpython/lltypesystem rpython/test translator/c
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Nov 22 18:46:19 CET 2007
Author: cfbolz
Date: Thu Nov 22 18:46:18 2007
New Revision: 48942
Removed:
pypy/branch/remove-extcompiler-rctypes/pypy/module/signal/ctypes_signal.py
Modified:
pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/i386/rgenop.py
pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/ppc/codebuf.py
pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/llmemory.py
pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/lltype.py
pypy/branch/remove-extcompiler-rctypes/pypy/rpython/rbuiltin.py
pypy/branch/remove-extcompiler-rctypes/pypy/rpython/test/test_rbuiltin.py
pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/funcgen.py
pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/node.py
Log:
(pedronis, cfbolz): deal with the removal of rctypes
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/i386/rgenop.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/i386/rgenop.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/i386/rgenop.py Thu Nov 22 18:46:18 2007
@@ -170,12 +170,11 @@
import py
py.test.skip("must run in the main thread")
try:
- from ctypes import cast, c_void_p
- from pypy.rpython.rctypes.tool import util
+ from ctypes import cast, c_void_p, util
path = util.find_library('gc')
if path is None:
raise ImportError("Boehm (libgc) not found")
- boehmlib = util.load_library(path)
+ boehmlib = ctypes.cdll.LoadLibrary(path)
except ImportError, e:
import py
py.test.skip(str(e))
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/ppc/codebuf.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/ppc/codebuf.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/jit/codegen/ppc/codebuf.py Thu Nov 22 18:46:18 2007
@@ -1,48 +1,15 @@
-import pypy.rpython.rctypes.implementation # register rctypes types
-from pypy.rpython.rctypes.tool import ctypes_platform
-from pypy.rpython.rctypes.tool.libc import libc
from ctypes import POINTER, cast, c_void_p, c_int, c_char
-
-class CConfig:
- _includes_ = ("sys/types.h", "sys/mman.h")
- size_t = ctypes_platform.SimpleType("size_t", c_int)
- off_t = ctypes_platform.SimpleType("off_t", c_int)
-
- MAP_PRIVATE = ctypes_platform.DefinedConstantInteger("MAP_PRIVATE")
- MAP_ANON = ctypes_platform.DefinedConstantInteger("MAP_ANON")
- MAP_ANONYMOUS = ctypes_platform.DefinedConstantInteger("MAP_ANONYMOUS")
- PROT_READ = ctypes_platform.DefinedConstantInteger("PROT_READ")
- PROT_WRITE = ctypes_platform.DefinedConstantInteger("PROT_WRITE")
- PROT_EXEC = ctypes_platform.DefinedConstantInteger("PROT_EXEC")
-
-globals().update(ctypes_platform.configure(CConfig))
-if MAP_ANONYMOUS is None:
- MAP_ANONYMOUS = MAP_ANON
- assert MAP_ANONYMOUS is not None
-del MAP_ANON
-
-# ____________________________________________________________
-
-PTR = POINTER(c_char) # cannot use c_void_p as return value of functions :-(
-
-mmap_ = libc.mmap
-mmap_.argtypes = [PTR, size_t, c_int, c_int, c_int, off_t]
-mmap_.restype = PTR
-mmap_.includes = ("sys/mman.h",)
-munmap_ = libc.munmap
-munmap_.argtypes = [PTR, size_t]
-munmap_.restype = c_int
-munmap_.includes = ("sys/mman.h",)
+from pypy.jit.codegen.i386 import codebuf_posix
def alloc(map_size):
- flags = MAP_PRIVATE | MAP_ANONYMOUS
- prot = PROT_EXEC | PROT_READ | PROT_WRITE
- res = mmap_(PTR(), map_size, prot, flags, -1, 0)
+ flags = codebuf_posix.MAP_PRIVATE | codebuf_posix.MAP_ANONYMOUS
+ prot = codebuf_posix.PROT_EXEC | codebuf_posix.PROT_READ | codebuf_posix.PROT_WRITE
+ res = codebuf_posix.mmap_(PTR(), map_size, prot, flags, -1, 0)
if not res:
raise MemoryError
return res
-free = munmap_
+free = codebuf_posix.munmap_
class CodeBlockOverflow(Exception):
pass
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/llmemory.py Thu Nov 22 18:46:18 2007
@@ -84,7 +84,6 @@
repeat = self.repeat
if repeat == 0:
return
- from pypy.rpython.rctypes.rmodel import reccopy
if isinstance(self.TYPE, lltype.ContainerType):
PTR = lltype.Ptr(self.TYPE)
else:
@@ -92,7 +91,7 @@
while True:
src = cast_adr_to_ptr(srcadr, PTR)
dst = cast_adr_to_ptr(dstadr, PTR)
- reccopy(src, dst)
+ _reccopy(src, dst)
repeat -= 1
if repeat <= 0:
break
@@ -133,8 +132,7 @@
PTR = lltype.Ptr(self.TYPE)
src = cast_adr_to_ptr(srcadr, PTR)
dst = cast_adr_to_ptr(dstadr, PTR)
- from pypy.rpython.rctypes.rmodel import reccopy
- reccopy(src, dst)
+ _reccopy(src, dst)
class CompositeOffset(AddressOffset):
@@ -257,8 +255,7 @@
return cast_ptr_to_adr(headerptr)
def raw_memcopy(self, srcadr, dstadr):
- from pypy.rpython.rctypes.rmodel import reccopy
- reccopy(srcadr.ptr, dstadr.ptr)
+ _reccopy(srcadr.ptr, dstadr.ptr)
class GCHeaderAntiOffset(AddressOffset):
def __init__(self, gcheaderbuilder):
@@ -638,3 +635,34 @@
else:
# regular case
return lltype.cast_pointer(EXPECTED_TYPE, ptr)
+
+
+def _reccopy(source, dest):
+ # copy recursively a structure or array onto another.
+ T = lltype.typeOf(source).TO
+ assert T == lltype.typeOf(dest).TO
+ if isinstance(T, (lltype.Array, lltype.FixedSizeArray)):
+ assert source._obj.getlength() == dest._obj.getlength()
+ ITEMTYPE = T.OF
+ for i in range(source._obj.getlength()):
+ if isinstance(ITEMTYPE, lltype.ContainerType):
+ subsrc = source._obj.getitem(i)._as_ptr()
+ subdst = dest._obj.getitem(i)._as_ptr()
+ _reccopy(subsrc, subdst)
+ else:
+ # this is a hack XXX de-hack this
+ llvalue = source._obj.getitem(i, uninitialized_ok=True)
+ dest._obj.setitem(i, llvalue)
+ elif isinstance(T, lltype.Struct):
+ for name in T._names:
+ FIELDTYPE = getattr(T, name)
+ if isinstance(FIELDTYPE, lltype.ContainerType):
+ subsrc = source._obj._getattr(name)._as_ptr()
+ subdst = dest._obj._getattr(name)._as_ptr()
+ _reccopy(subsrc, subdst)
+ else:
+ # this is a hack XXX de-hack this
+ llvalue = source._obj._getattr(name, uninitialized_ok=True)
+ setattr(dest._obj, name, llvalue)
+ else:
+ raise TypeError(T)
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/rpython/lltypesystem/lltype.py Thu Nov 22 18:46:18 2007
@@ -413,9 +413,9 @@
def __init__(self, args, result):
for arg in args:
assert isinstance(arg, LowLevelType)
- # -- disabled the following check for the benefits of rctypes --
- #if isinstance(arg, ContainerType):
- # raise TypeError, "function arguments can only be primitives or pointers"
+ # -- disable the following check for the benefits of rffi --
+ if isinstance(arg, ContainerType):
+ raise TypeError, "function arguments can only be primitives or pointers"
self.ARGS = tuple(args)
assert isinstance(result, LowLevelType)
if isinstance(result, ContainerType):
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/rpython/rbuiltin.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/rpython/rbuiltin.py Thu Nov 22 18:46:18 2007
@@ -116,8 +116,7 @@
def rtype_call_args(self, hop):
# calling a built-in function with keyword arguments:
- # mostly for rpython.objectmodel.hint() and for constructing
- # rctypes structures
+ # mostly for rpython.objectmodel.hint()
hop, kwds_i = call_args_expand(hop)
bltintyper = self.findbltintyper(hop.rtyper)
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/rpython/test/test_rbuiltin.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/rpython/test/test_rbuiltin.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/rpython/test/test_rbuiltin.py Thu Nov 22 18:46:18 2007
@@ -7,7 +7,7 @@
from pypy.rlib.rarithmetic import r_uint, intmask
from pypy.annotation.builtin import *
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
-from pypy.rpython.rctypes.rcarithmetic import CShort
+from pypy.rpython.lltypesystem.rffi import SHORT
from pypy.rpython import extfunc
import py
@@ -473,7 +473,7 @@
res = self.interpret(llf, [ord('x')], policy=LowLevelAnnotatorPolicy())
assert res == u'x'
def llf(v):
- return lltype.cast_primitive(CShort, v)
+ return lltype.cast_primitive(SHORT, v)
res = self.interpret(llf, [123], policy=LowLevelAnnotatorPolicy())
assert res == 123
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/funcgen.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/funcgen.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/funcgen.py Thu Nov 22 18:46:18 2007
@@ -388,6 +388,7 @@
continue # skip 'void' argument
args.append(self.expr(v))
# special case for rctypes: by-value container args:
+ # XXX is this still needed now that rctypes is gone
if isinstance(ARGTYPE, ContainerType):
args[-1] = '*%s' % (args[-1],)
Modified: pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/node.py
==============================================================================
--- pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/node.py (original)
+++ pypy/branch/remove-extcompiler-rctypes/pypy/translator/c/node.py Thu Nov 22 18:46:18 2007
@@ -114,7 +114,7 @@
return self.prefix + name
def verbatim_field_name(self, name):
- if name.startswith('c_'): # produced in this way by rctypes
+ if name.startswith('c_'): # produced in this way by rffi
return name[2:]
else:
# field names have to start with 'c_' or be meant for names that
More information about the Pypy-commit
mailing list