Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3k Changeset: r74047:f9f6e6ae989f Date: 2014-10-21 17:47 +0200 http://bitbucket.org/pypy/pypy/changeset/f9f6e6ae989f/
Log: hg merge default diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst --- a/pypy/doc/cppyy.rst +++ b/pypy/doc/cppyy.rst @@ -83,7 +83,7 @@ the selection of scientific software) will also work for a build with the builtin backend. -.. _`download`: http://cern.ch/wlav/reflex-2013-08-14.tar.bz2 +.. _`download`: http://cern.ch/wlav/reflex-2014-10-20.tar.bz2 .. _`ROOT`: http://root.cern.ch/ Besides Reflex, you probably need a version of `gccxml`_ installed, which is @@ -98,8 +98,8 @@ To install the standalone version of Reflex, after download:: - $ tar jxf reflex-2013-08-14.tar.bz2 - $ cd reflex-2013-08-14 + $ tar jxf reflex-2014-10-20.tar.bz2 + $ cd reflex-2014-10-20 $ ./build/autogen $ ./configure <usual set of options such as --prefix> $ make && make install @@ -804,7 +804,7 @@ also means that you can't actually find out whether it is in use, other than by running a micro-benchmark or a JIT test). -.. _`provided`: http://cern.ch/wlav/reflex-2013-04-23.tar.bz2 +.. _`provided`: http://cern.ch/wlav/reflex-2014-10-20.tar.bz2 .. _`genreflex-methptrgetter.patch`: https://bitbucket.org/pypy/pypy/src/default/pypy/module/cppyy/genreflex-methptrgetter.patch CPython diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py --- a/pypy/goal/targetpypystandalone.py +++ b/pypy/goal/targetpypystandalone.py @@ -258,7 +258,8 @@ enable_translationmodules(config) config.translation.suggest(check_str_without_nul=True) - config.translation.suggest(shared=True) + if sys.platform.startswith('linux'): + config.translation.suggest(shared=True) if config.translation.thread: config.objspace.usemodules.thread = True diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py --- a/pypy/module/pypyjit/policy.py +++ b/pypy/module/pypyjit/policy.py @@ -111,7 +111,7 @@ '__pypy__', 'cStringIO', '_collections', 'struct', 'mmap', 'marshal', '_codecs', 'rctime', 'cppyy', '_cffi_backend', 'pyexpat', '_continuation', '_io', - 'thread', 'select']: + 'thread', 'select', '_random']: if modname == 'pypyjit' and 'interp_resop' in rest: return False return True @@ -120,7 +120,7 @@ def look_inside_function(self, func): mod = func.__module__ or '?' - if mod == 'rpython.rlib.rbigint' or mod == 'rpython.rlib.rlocale' or mod == 'rpython.rlib.rsocket': + if mod == 'rpython.rlib.rlocale' or mod == 'rpython.rlib.rsocket': return False if mod.startswith('pypy.interpreter.astcompiler.'): return False diff --git a/pypy/module/pypyjit/test/test_policy.py b/pypy/module/pypyjit/test/test_policy.py --- a/pypy/module/pypyjit/test/test_policy.py +++ b/pypy/module/pypyjit/test/test_policy.py @@ -6,15 +6,6 @@ from pypy.objspace.std.intobject import W_IntObject assert pypypolicy.look_inside_function(W_IntObject.descr_add) -def test_bigint(): - from rpython.rlib.rbigint import rbigint - assert not pypypolicy.look_inside_function(rbigint.eq.im_func) - assert not pypypolicy.look_inside_function(rbigint.ne.im_func) - assert not pypypolicy.look_inside_function(rbigint.lt.im_func) - assert not pypypolicy.look_inside_function(rbigint.le.im_func) - assert not pypypolicy.look_inside_function(rbigint.gt.im_func) - assert not pypypolicy.look_inside_function(rbigint.ge.im_func) - def test_rlocale(): from rpython.rlib.rlocale import setlocale assert not pypypolicy.look_inside_function(setlocale) @@ -56,7 +47,7 @@ def test_pypy_module(): from pypy.module._collections.interp_deque import W_Deque from pypy.module._random.interp_random import W_Random - assert not pypypolicy.look_inside_function(W_Random.random) + assert pypypolicy.look_inside_function(W_Random.random) assert pypypolicy.look_inside_function(W_Deque.length) assert pypypolicy.look_inside_pypy_module('__builtin__.operation') assert pypypolicy.look_inside_pypy_module('__builtin__.abstractinst') diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py --- a/rpython/rlib/rbigint.py +++ b/rpython/rlib/rbigint.py @@ -427,7 +427,6 @@ def tolonglong(self): return _AsLongLong(self) - @jit.look_inside def tobool(self): return self.sign != 0 @@ -517,11 +516,9 @@ return (self.sign * self.digit(0)) == other - @jit.look_inside def ne(self, other): return not self.eq(other) - @jit.look_inside def int_ne(self, other): return not self.int_eq(other) @@ -592,11 +589,9 @@ return True return False - @jit.look_inside def le(self, other): return not other.lt(self) - @jit.look_inside def int_le(self, other): # Alternative that might be faster, reimplant this. as a check with other + 1. But we got to check for overflow # or reduce valid range. @@ -605,19 +600,15 @@ return True return self.int_lt(other) - @jit.look_inside def gt(self, other): return other.lt(self) - @jit.look_inside def int_gt(self, other): return not self.int_le(other) - @jit.look_inside def ge(self, other): return not self.lt(other) - @jit.look_inside def int_ge(self, other): return not self.int_lt(other) @@ -784,7 +775,6 @@ return div - @jit.look_inside def div(self, other): return self.floordiv(other) diff --git a/rpython/rlib/rzlib.py b/rpython/rlib/rzlib.py --- a/rpython/rlib/rzlib.py +++ b/rpython/rlib/rzlib.py @@ -37,7 +37,7 @@ Z_NO_FLUSH Z_FINISH Z_SYNC_FLUSH Z_FULL_FLUSH MAX_WBITS MAX_MEM_LEVEL Z_BEST_SPEED Z_BEST_COMPRESSION Z_DEFAULT_COMPRESSION - Z_FILTERED Z_HUFFMAN_ONLY Z_DEFAULT_STRATEGY + Z_FILTERED Z_HUFFMAN_ONLY Z_DEFAULT_STRATEGY Z_NEED_DICT '''.split() class SimpleCConfig: @@ -165,6 +165,9 @@ result = _inflateInit2_(stream, wbits, ZLIB_VERSION, size) return result +_deflateSetDictionary = zlib_external('deflateSetDictionary', [z_stream_p, Bytefp, uInt], rffi.INT) +_inflateSetDictionary = zlib_external('inflateSetDictionary', [z_stream_p, Bytefp, uInt], rffi.INT) + # ____________________________________________________________ CRC32_DEFAULT_START = 0 @@ -184,6 +187,23 @@ ADLER32_DEFAULT_START = 1 +def deflateSetDictionary(stream, string): + bytes = rffi.get_nonmovingbuffer(string) + err = _deflateSetDictionary(stream, rffi.cast(Bytefp, bytes), len(string)) + rffi.free_nonmovingbuffer(string, bytes) + if err == Z_STREAM_ERROR: + raise RZlibError("Parameter is invalid or the stream state is inconsistent") + +def inflateSetDictionary(stream, string): + bytes = rffi.get_nonmovingbuffer(string) + err = _inflateSetDictionary(stream, rffi.cast(Bytefp, bytes), len(string)) + rffi.free_nonmovingbuffer(string, bytes) + if err == Z_STREAM_ERROR: + raise RZlibError("Parameter is invalid or the stream state is inconsistent") + elif err == Z_DATA_ERROR: + raise RZlibError("The given dictionary doesn't match the expected one") + + def adler32(string, start=ADLER32_DEFAULT_START): """ Compute the Adler-32 checksum of the string, possibly with the given diff --git a/rpython/rlib/test/test_rbigint.py b/rpython/rlib/test/test_rbigint.py --- a/rpython/rlib/test/test_rbigint.py +++ b/rpython/rlib/test/test_rbigint.py @@ -582,6 +582,8 @@ def test_int_bitwise(self): for x in gen_signs([0, 1, 5, 11, 42, 43, 2 ** 30]): for y in gen_signs([0, 1, 5, 11, 42, 43, 3 ** 30, 2 ** 31]): + if y != intmask(y): + continue # skip 'y' too large for 32-bit lx = rbigint.fromlong(x) for mod in "xor and_ or_".split(): res1 = getattr(lx, 'int_' + mod)(y).tolong() @@ -666,9 +668,9 @@ for base in [0, 2, 4, 8, 16, 10, math.e]: l = rbigint.fromlong(op).log(base) if base: - assert ulps_check(l, math.log(op, base), 1) is None + assert ulps_check(l, math.log(op, base)) is None else: - assert ulps_check(l, math.log(op), 1) is None + assert ulps_check(l, math.log(op)) is None class TestInternalFunctions(object): def test__inplace_divrem1(self): diff --git a/rpython/rlib/test/test_rzlib.py b/rpython/rlib/test/test_rzlib.py --- a/rpython/rlib/test/test_rzlib.py +++ b/rpython/rlib/test/test_rzlib.py @@ -82,6 +82,39 @@ rzlib.deflateEnd(stream) +def test_deflate_set_dictionary(): + text = 'abcabc' + zdict = 'abc' + stream = rzlib.deflateInit() + rzlib.deflateSetDictionary(stream, zdict) + bytes = rzlib.compress(stream, text, rzlib.Z_FINISH) + rzlib.deflateEnd(stream) + + stream2 = rzlib.inflateInit() + + from rpython.rtyper.lltypesystem import lltype, rffi, rstr + from rpython.rtyper.annlowlevel import llstr + from rpython.rlib.rstring import StringBuilder + with lltype.scoped_alloc(rffi.CCHARP.TO, len(bytes)) as inbuf: + rstr.copy_string_to_raw(llstr(bytes), inbuf, 0, len(bytes)) + stream2.c_next_in = rffi.cast(rzlib.Bytefp, inbuf) + rffi.setintfield(stream2, 'c_avail_in', len(bytes)) + with lltype.scoped_alloc(rffi.CCHARP.TO, 100) as outbuf: + stream2.c_next_out = rffi.cast(rzlib.Bytefp, outbuf) + bufsize = 100 + rffi.setintfield(stream2, 'c_avail_out', bufsize) + err = rzlib._inflate(stream2, rzlib.Z_SYNC_FLUSH) + assert err == rzlib.Z_NEED_DICT + rzlib.inflateSetDictionary(stream2, zdict) + rzlib._inflate(stream2, rzlib.Z_SYNC_FLUSH) + avail_out = rffi.cast(lltype.Signed, stream2.c_avail_out) + result = StringBuilder() + result.append_charpsize(outbuf, bufsize - avail_out) + + rzlib.inflateEnd(stream2) + assert result.build() == text + + def test_compression(): """ Once we have got a deflate stream, rzlib.compress() diff --git a/rpython/translator/platform/linux.py b/rpython/translator/platform/linux.py --- a/rpython/translator/platform/linux.py +++ b/rpython/translator/platform/linux.py @@ -26,11 +26,13 @@ def _include_dirs_for_libffi(self): return self._pkg_config("libffi", "--cflags-only-I", - ['/usr/include/libffi']) + ['/usr/include/libffi'], + check_result_dir=True) def _library_dirs_for_libffi(self): return self._pkg_config("libffi", "--libs-only-L", - ['/usr/lib/libffi']) + ['/usr/lib/libffi'], + check_result_dir=True) class Linux(BaseLinux): diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py --- a/rpython/translator/platform/posix.py +++ b/rpython/translator/platform/posix.py @@ -74,15 +74,36 @@ cwd=str(exe_name.dirpath())) return exe_name - def _pkg_config(self, lib, opt, default): + def _pkg_config(self, lib, opt, default, check_result_dir=False): try: ret, out, err = _run_subprocess("pkg-config", [lib, opt]) - except OSError: + except OSError, e: + err = str(e) ret = 1 if ret: - return default - # strip compiler flags - return [entry[2:] for entry in out.split()] + result = default + else: + # strip compiler flags + result = [entry[2:] for entry in out.split()] + # + if not result: + pass # if pkg-config explicitly returned nothing, then + # we assume it means no options are needed + elif check_result_dir: + # check that at least one of the results is a valid dir + for check in result: + if os.path.isdir(check): + break + else: + if ret: + msg = ("running 'pkg-config %s %s' failed:\n%s\n" + "and the default %r is not a valid directory" % ( + lib, opt, err.rstrip(), default)) + else: + msg = ("'pkg-config %s %s' returned no valid directory:\n" + "%s\n%s" % (lib, opt, out.rstrip(), err.rstrip())) + raise ValueError(msg) + return result def gen_makefile(self, cfiles, eci, exe_name=None, path=None, shared=False, headers_to_precompile=[], _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit