Author: Matti Picus <matti.pi...@gmail.com> Branch: Changeset: r92908:959da02fe2dc Date: 2017-11-02 16:59 +0200 http://bitbucket.org/pypy/pypy/changeset/959da02fe2dc/
Log: merge bsd-patches which fixes failures on FreeBSD (David Naylor) diff --git a/lib-python/2.7/ctypes/__init__.py b/lib-python/2.7/ctypes/__init__.py --- a/lib-python/2.7/ctypes/__init__.py +++ b/lib-python/2.7/ctypes/__init__.py @@ -360,14 +360,15 @@ self._FuncPtr = _FuncPtr if handle is None: - if flags & _FUNCFLAG_CDECL: - pypy_dll = _ffi.CDLL(name, mode) - else: - pypy_dll = _ffi.WinDLL(name, mode) - self.__pypy_dll__ = pypy_dll - handle = int(pypy_dll) - if _sys.maxint > 2 ** 32: - handle = int(handle) # long -> int + handle = 0 + if flags & _FUNCFLAG_CDECL: + pypy_dll = _ffi.CDLL(name, mode, handle) + else: + pypy_dll = _ffi.WinDLL(name, mode, handle) + self.__pypy_dll__ = pypy_dll + handle = int(pypy_dll) + if _sys.maxint > 2 ** 32: + handle = int(handle) # long -> int self._handle = handle def __repr__(self): diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py b/pypy/module/_rawffi/alt/interp_funcptr.py --- a/pypy/module/_rawffi/alt/interp_funcptr.py +++ b/pypy/module/_rawffi/alt/interp_funcptr.py @@ -314,7 +314,7 @@ # ======================================================================== class W_CDLL(W_Root): - def __init__(self, space, name, mode): + def __init__(self, space, name, mode, handle): self.flags = libffi.FUNCFLAG_CDECL self.space = space if name is None: @@ -322,7 +322,7 @@ else: self.name = name try: - self.cdll = libffi.CDLL(name, mode) + self.cdll = libffi.CDLL(name, mode, handle) except DLOpenError as e: raise wrap_dlopenerror(space, e, self.name) except OSError as e: @@ -344,9 +344,9 @@ def getidentifier(self, space): return space.newint(self.cdll.getidentifier()) -@unwrap_spec(name='fsencode_or_none', mode=int) -def descr_new_cdll(space, w_type, name, mode=-1): - return W_CDLL(space, name, mode) +@unwrap_spec(name='fsencode_or_none', mode=int, handle=int) +def descr_new_cdll(space, w_type, name, mode=-1, handle=0): + return W_CDLL(space, name, mode, handle) W_CDLL.typedef = TypeDef( @@ -359,13 +359,13 @@ ) class W_WinDLL(W_CDLL): - def __init__(self, space, name, mode): - W_CDLL.__init__(self, space, name, mode) + def __init__(self, space, name, mode, handle): + W_CDLL.__init__(self, space, name, mode, handle) self.flags = libffi.FUNCFLAG_STDCALL -@unwrap_spec(name='fsencode_or_none', mode=int) -def descr_new_windll(space, w_type, name, mode=-1): - return W_WinDLL(space, name, mode) +@unwrap_spec(name='fsencode_or_none', mode=int, handle=int) +def descr_new_windll(space, w_type, name, mode=-1, handle=0): + return W_WinDLL(space, name, mode, handle) W_WinDLL.typedef = TypeDef( @@ -380,4 +380,4 @@ # ======================================================================== def get_libc(space): - return W_CDLL(space, get_libc_name(), -1) + return W_CDLL(space, get_libc_name(), -1, 0) diff --git a/pypy/module/_vmprof/test/test__vmprof.py b/pypy/module/_vmprof/test/test__vmprof.py --- a/pypy/module/_vmprof/test/test__vmprof.py +++ b/pypy/module/_vmprof/test/test__vmprof.py @@ -1,3 +1,4 @@ +import py import sys from rpython.tool.udir import udir from pypy.tool.pytest.objspace import gettestobjspace @@ -107,6 +108,7 @@ _vmprof.disable() assert _vmprof.is_enabled() is False + @py.test.mark.xfail(sys.platform.startswith('freebsd'), reason = "not implemented") def test_get_profile_path(self): import _vmprof tmpfile = open(self.tmpfilename, 'wb') diff --git a/pypy/module/termios/test/test_termios.py b/pypy/module/termios/test/test_termios.py --- a/pypy/module/termios/test/test_termios.py +++ b/pypy/module/termios/test/test_termios.py @@ -7,9 +7,6 @@ if os.name != 'posix': py.test.skip('termios module only available on unix') -if sys.platform.startswith('freebsd'): - raise Exception('XXX seems to hangs on FreeBSD9') - class TestTermios(object): def setup_class(cls): try: diff --git a/pypy/module/test_lib_pypy/pyrepl/__init__.py b/pypy/module/test_lib_pypy/pyrepl/__init__.py --- a/pypy/module/test_lib_pypy/pyrepl/__init__.py +++ b/pypy/module/test_lib_pypy/pyrepl/__init__.py @@ -1,6 +1,3 @@ import sys import lib_pypy.pyrepl sys.modules['pyrepl'] = sys.modules['lib_pypy.pyrepl'] - -if sys.platform.startswith('freebsd'): - raise Exception('XXX seems to hangs on FreeBSD9') diff --git a/pypy/module/test_lib_pypy/pyrepl/test_readline.py b/pypy/module/test_lib_pypy/pyrepl/test_readline.py --- a/pypy/module/test_lib_pypy/pyrepl/test_readline.py +++ b/pypy/module/test_lib_pypy/pyrepl/test_readline.py @@ -4,7 +4,7 @@ @pytest.mark.skipif("os.name != 'posix' or 'darwin' in sys.platform or " - "'kfreebsd' in sys.platform") + "'freebsd' in sys.platform") def test_raw_input(): import os import pty diff --git a/pypy/tool/cpyext/extbuild.py b/pypy/tool/cpyext/extbuild.py --- a/pypy/tool/cpyext/extbuild.py +++ b/pypy/tool/cpyext/extbuild.py @@ -244,13 +244,13 @@ if sys.platform == 'win32': compile_extra = ["/we4013"] link_extra = ["/LIBPATH:" + os.path.join(sys.exec_prefix, 'libs')] - elif sys.platform == 'darwin': - compile_extra = link_extra = None - pass elif sys.platform.startswith('linux'): compile_extra = [ "-O0", "-g", "-Werror=implicit-function-declaration", "-fPIC"] link_extra = None + else: + compile_extra = link_extra = None + pass return ExtensionCompiler( builddir_base=base_dir, include_extra=[get_python_inc()], diff --git a/rpython/rlib/libffi.py b/rpython/rlib/libffi.py --- a/rpython/rlib/libffi.py +++ b/rpython/rlib/libffi.py @@ -434,11 +434,12 @@ # XXX: it partially duplicate the code in clibffi.py class CDLL(object): - def __init__(self, libname, mode=-1): + def __init__(self, libname, mode=-1, lib=0): """Load the library, or raises DLOpenError.""" - self.lib = rffi.cast(DLLHANDLE, 0) - with rffi.scoped_str2charp(libname) as ll_libname: - self.lib = dlopen(ll_libname, mode) + self.lib = rffi.cast(DLLHANDLE, lib) + if lib == 0: + with rffi.scoped_str2charp(libname) as ll_libname: + self.lib = dlopen(ll_libname, mode) def __del__(self): if self.lib: diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py --- a/rpython/rlib/rvmprof/cintf.py +++ b/rpython/rlib/rvmprof/cintf.py @@ -47,7 +47,10 @@ # Guessing a BSD-like Unix platform compile_extra += ['-DVMPROF_UNIX'] compile_extra += ['-DVMPROF_MAC'] - _libs = [] + if sys.platform.startswith('freebsd'): + _libs = ['unwind'] + else: + _libs = [] eci_kwds = dict( 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 @@ -1147,7 +1147,7 @@ libc_name = get_libc_name() # Make sure the name is determined during import, not at runtime if _FREEBSD: RTLD_DEFAULT = -2 # see <dlfcn.h> - rtld_default_lib = ctypes.CDLL("RTLD_DEFAULT", handle=RTLD_DEFAULT, **load_library_kwargs) + rtld_default_lib = ctypes.CDLL("ld-elf.so.1", handle=RTLD_DEFAULT, **load_library_kwargs) # XXX is this always correct??? standard_c_lib = ctypes.CDLL(libc_name, **load_library_kwargs) @@ -1243,7 +1243,7 @@ if cfunc is None: if _FREEBSD and funcname in ('dlopen', 'fdlopen', 'dlsym', 'dlfunc', 'dlerror', 'dlclose'): - cfunc = get_on_lib(rtld_default_lib, funcname) + cfunc = rtld_default_lib[funcname] else: cfunc = get_on_lib(standard_c_lib, funcname) # XXX magic: on Windows try to load the function from 'kernel32' too _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit