Author: mattip <[email protected]>
Branch: win32-fixes3
Changeset: r63636:b4eed482703d
Date: 2013-04-26 14:46 +0300
http://bitbucket.org/pypy/pypy/changeset/b4eed482703d/
Log: wip - respect calling convention in lltypesystem/ll2ctypes
diff --git a/rpython/jit/backend/llgraph/runner.py
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -64,14 +64,15 @@
self.args = args
class CallDescr(AbstractDescr):
- def __init__(self, RESULT, ARGS, extrainfo):
+ def __init__(self, RESULT, ARGS, extrainfo, abi):
self.RESULT = RESULT
self.ARGS = ARGS
self.extrainfo = extrainfo
+ self.abi = abi
def __repr__(self):
- return 'CallDescr(%r, %r, %r)' % (self.RESULT, self.ARGS,
- self.extrainfo)
+ return 'CallDescr(%r, %r, %r %r)' % (self.RESULT, self.ARGS,
+ self.extrainfo, self.abi)
def get_extra_info(self):
return self.extrainfo
@@ -290,13 +291,14 @@
# ------------------------------------------------------------
def calldescrof(self, FUNC, ARGS, RESULT, effect_info):
+ abi = 0
key = ('call', getkind(RESULT),
tuple([getkind(A) for A in ARGS]),
- effect_info)
+ effect_info, abi)
try:
return self.descrs[key]
except KeyError:
- descr = CallDescr(RESULT, ARGS, effect_info)
+ descr = CallDescr(RESULT, ARGS, effect_info, abi)
self.descrs[key] = descr
return descr
@@ -362,7 +364,7 @@
try:
return self.descrs[key]
except KeyError:
- descr = CallDescr(RESULT, ARGS, extrainfo)
+ descr = CallDescr(RESULT, ARGS, extrainfo, cif_description.abi)
self.descrs[key] = descr
return descr
@@ -865,7 +867,7 @@
# graph, not to directly execute the python function
result = self.cpu.maybe_on_top_of_llinterp(func, call_args,
descr.RESULT)
else:
- FUNC = lltype.FuncType(descr.ARGS, descr.RESULT)
+ FUNC = lltype.FuncType(descr.ARGS, descr.RESULT, descr.abi)
func_to_call = rffi.cast(lltype.Ptr(FUNC), func)
result = func_to_call(*call_args)
del self.force_guard_op
diff --git a/rpython/rlib/clibffi.py b/rpython/rlib/clibffi.py
--- a/rpython/rlib/clibffi.py
+++ b/rpython/rlib/clibffi.py
@@ -503,6 +503,7 @@
def __init__(self, name, argtypes, restype, flags=FUNCFLAG_CDECL):
self.name = name
+ print 'AbstractFuncPtr
of',name,'flags',flags,'FUNCFLAG_CDECL',FUNCFLAG_CDECL
self.argtypes = argtypes
self.restype = restype
self.flags = flags
diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py
b/rpython/rtyper/lltypesystem/ll2ctypes.py
--- a/rpython/rtyper/lltypesystem/ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/ll2ctypes.py
@@ -362,12 +362,16 @@
restype = None
else:
restype = get_ctypes_type(T.TO.RESULT)
+ if T.TO.CALL_CONV == ctypes._FUNCFLAG_STDCALL:
+ rettype = ctypes.WINFUNCTYPE
+ else:
+ rettype = ctypes.CFUNCTYPE
try:
kwds = {'use_errno': True}
- return ctypes.CFUNCTYPE(restype, *argtypes, **kwds)
+ return rettype(restype, *argtypes, **kwds)
except TypeError:
# unexpected 'use_errno' argument, old ctypes version
- return ctypes.CFUNCTYPE(restype, *argtypes)
+ return rettype(restype, *argtypes)
elif isinstance(T.TO, lltype.OpaqueType):
return ctypes.c_void_p
else:
diff --git a/rpython/rtyper/lltypesystem/lltype.py
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -540,7 +540,7 @@
class FuncType(ContainerType):
_gckind = 'raw'
__name__ = 'func'
- def __init__(self, args, result):
+ def __init__(self, args, result, call_conv=0):
for arg in args:
assert isinstance(arg, LowLevelType)
# There are external C functions eating raw structures, not
@@ -550,6 +550,7 @@
if isinstance(result, ContainerType):
raise TypeError, "function result can only be primitive or pointer"
self.RESULT = result
+ self.CALL_CONV = call_conv
def __str__(self):
args = ', '.join(map(str, self.ARGS))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit