1. Pypy
  2. Untitled project
  3. pypy

Commits

Matti Picus  committed b4eed48

wip - respect calling convention in lltypesystem/ll2ctypes

  • Participants
  • Parent commits fbe73ec
  • Branches win32-fixes3

Comments (0)

Files changed (4)

File rpython/jit/backend/llgraph/runner.py

View file
  • Ignore whitespace
         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
     # ------------------------------------------------------------
 
     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
 
         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
 
             # 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

File rpython/rlib/clibffi.py

View file
  • Ignore whitespace
 
     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

File rpython/rtyper/lltypesystem/ll2ctypes.py

View file
  • Ignore whitespace
                 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:

File rpython/rtyper/lltypesystem/lltype.py

View file
  • Ignore whitespace
 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
         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))