Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r73684:eab5254eaafa
Date: 2014-09-24 19:24 -0700
http://bitbucket.org/pypy/pypy/changeset/eab5254eaafa/
Log: workaround FuncType pointer calls w/ a non-standard calling
convention not actually using said convention (after translation)
with a stupid shim for now
diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -167,8 +167,7 @@
if os.name == 'nt':
interpleveldefs.update({
'_getfileinformation': 'interp_posix._getfileinformation',
- # XXX: currently broken
- #'_getfinalpathname': 'interp_posix._getfinalpathname',
+ '_getfinalpathname': 'interp_posix._getfinalpathname',
})
if hasattr(os, 'chroot'):
interpleveldefs['chroot'] = 'interp_posix.chroot'
diff --git a/rpython/rtyper/module/ll_win32file.py
b/rpython/rtyper/module/ll_win32file.py
--- a/rpython/rtyper/module/ll_win32file.py
+++ b/rpython/rtyper/module/ll_win32file.py
@@ -10,6 +10,17 @@
from rpython.tool.sourcetools import func_renamer
from rpython.rlib.objectmodel import specialize
+separate_module_source = """\
+DWORD
+pypy_GetFinalPathNameByHandle(FARPROC address, HANDLE hFile,
+ LPTSTR lpszFilePath, DWORD cchFilePath,
+ DWORD dwFlags) {
+ DWORD (WINAPI *func)(HANDLE, LPTSTR, DWORD, DWORD);
+ *(FARPROC*)&func = address;
+ return func(hFile, lpszFilePath, cchFilePath, dwFlags);
+}
+"""
+
def make_win32_traits(traits):
from rpython.rlib import rwin32
@@ -21,6 +32,8 @@
class CConfig:
_compilation_info_ = ExternalCompilationInfo(
includes = ['windows.h', 'winbase.h', 'sys/stat.h'],
+ separate_module_sources=[separate_module_source],
+ export_symbols=['pypy_GetFinalPathNameByHandle']
)
WIN32_FIND_DATA = platform.Struct(
'struct _WIN32_FIND_DATA' + suffix,
@@ -192,15 +205,15 @@
[traits.CCHARP, traits.CCHARP],
rwin32.BOOL)
- GETFINALPATHNAMEBYHANDLE_TP = lltype.Ptr(lltype.FuncType(
- [rwin32.HANDLE, traits.CCHARP, rwin32.DWORD, rwin32.DWORD],
- rwin32.DWORD, abi='FFI_STDCALL'))
- # dynamically loaded
- GetFinalPathNameByHandle = lltype.nullptr(
- GETFINALPATHNAMEBYHANDLE_TP.TO)
+ GetFinalPathNameByHandle_HANDLE = lltype.nullptr(rffi.VOIDP.TO)
+ pypy_GetFinalPathNameByHandle = staticmethod(rffi.llexternal(
+ 'pypy_GetFinalPathNameByHandle',
+ [rffi.VOIDP, rwin32.HANDLE, rffi.CWCHARP, rwin32.DWORD,
rwin32.DWORD],
+ rwin32.DWORD, compilation_info=CConfig._compilation_info_))
def check_GetFinalPathNameByHandle(self):
- if self.GetFinalPathNameByHandle:
+ if (self.GetFinalPathNameByHandle_HANDLE !=
+ lltype.nullptr(rffi.VOIDP.TO)):
return True
from rpython.rlib.rdynload import GetModuleHandle, dlsym
@@ -210,10 +223,15 @@
except KeyError:
return False
- self.GetFinalPathNameByHandle = rffi.cast(
- Win32Traits.GETFINALPATHNAMEBYHANDLE_TP, func)
+ self.GetFinalPathNameByHandle_HANDLE = func
return True
+ def GetFinalPathNameByHandle(self, *args):
+ assert (self.GetFinalPathNameByHandle_HANDLE !=
+ lltype.nullptr(rffi.VOIDP.TO))
+ return self.pypy_GetFinalPathNameByHandle(
+ self.GetFinalPathNameByHandle_HANDLE, *args)
+
return Win32Traits()
#_______________________________________________________________
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit