Author: Matti Picus <matti.pi...@gmail.com> Branch: py3.5 Changeset: r90722:702d82ab8269 Date: 2017-03-16 14:42 +0200 http://bitbucket.org/pypy/pypy/changeset/702d82ab8269/
Log: merge default into py3.5 diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py --- a/lib_pypy/cffi/cparser.py +++ b/lib_pypy/cffi/cparser.py @@ -803,6 +803,16 @@ "the actual array length in this context" % exprnode.coord.line) # + if (isinstance(exprnode, pycparser.c_ast.BinaryOp) and + exprnode.op == '+'): + return (self._parse_constant(exprnode.left) + + self._parse_constant(exprnode.right)) + # + if (isinstance(exprnode, pycparser.c_ast.BinaryOp) and + exprnode.op == '-'): + return (self._parse_constant(exprnode.left) - + self._parse_constant(exprnode.right)) + # raise FFIError(":%d: unsupported expression: expected a " "simple numeric constant" % exprnode.coord.line) diff --git a/pypy/doc/config/translation.gcrootfinder.txt b/pypy/doc/config/translation.gcrootfinder.txt --- a/pypy/doc/config/translation.gcrootfinder.txt +++ b/pypy/doc/config/translation.gcrootfinder.txt @@ -9,10 +9,8 @@ - ``--gcrootfinder=asmgcc``: use assembler hackery to find the roots directly from the normal stack. This is a bit faster, but platform specific. It works so far with GCC or MSVC, - on i386 and x86-64. It is tested only on Linux (where it is - the default) so other platforms (as well as MSVC) may need - various fixes before they can be used. + on i386 and x86-64. It is tested only on Linux + so other platforms (as well as MSVC) may need + various fixes before they can be used. Note asmgcc will be deprecated + at some future date, and does not work with clang. -You may have to force the use of the shadowstack root finder if -you are running into troubles or if you insist on translating -PyPy with other compilers like clang. diff --git a/pypy/doc/release-v5.7.0.rst b/pypy/doc/release-v5.7.0.rst --- a/pypy/doc/release-v5.7.0.rst +++ b/pypy/doc/release-v5.7.0.rst @@ -24,6 +24,12 @@ CFFI_ has been updated to 1.10, improving an already great package for interfacing with C. +We now use shadowstack as our default gcrootfinder_ even on Linux. The +alternative, asmgcc, will be deprecated at some future point. While about 3% +slower, shadowstack is much more easily maintained and debuggable. Also, +the performance of shadowstack has been improved in general: this should +close the speed gap between Linux and other platforms. + As always, this release fixed many issues and bugs raised by the growing community of PyPy users. We strongly recommend updating. @@ -47,6 +53,7 @@ .. _`modules`: project-ideas.html#make-more-python-modules-pypy-friendly .. _`help`: project-ideas.html .. _`these benchmarks show`: https://morepypy.blogspot.com/2017/03/async-http-benchmarks-on-pypy3.html +.. _gcrootfinder: config/translation.gcrootfinder.html What is PyPy? ============= diff --git a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h --- a/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h +++ b/pypy/module/_multibytecodec/src/cjkcodecs/cjkcodecs.h @@ -201,10 +201,13 @@ #define BEGIN_MAPPINGS_LIST /* empty */ #define MAPPING_ENCONLY(enc) \ + RPY_EXTERN const struct dbcs_map pypy_cjkmap_##enc; \ const struct dbcs_map pypy_cjkmap_##enc = {#enc, (void*)enc##_encmap, NULL}; #define MAPPING_DECONLY(enc) \ + RPY_EXTERN const struct dbcs_map pypy_cjkmap_##enc; \ const struct dbcs_map pypy_cjkmap_##enc = {#enc, NULL, (void*)enc##_decmap}; #define MAPPING_ENCDEC(enc) \ + RPY_EXTERN const struct dbcs_map pypy_cjkmap_##enc; \ const struct dbcs_map pypy_cjkmap_##enc = {#enc, (void*)enc##_encmap, \ (void*)enc##_decmap}; #define END_MAPPINGS_LIST /* empty */ @@ -294,7 +297,7 @@ #ifdef USING_IMPORTED_MAPS #define USING_IMPORTED_MAP(charset) \ - extern const struct dbcs_map pypy_cjkmap_##charset; + RPY_EXTERN const struct dbcs_map pypy_cjkmap_##charset; #define IMPORT_MAP(locale, charset, encmap, decmap) \ importmap(&pypy_cjkmap_##charset, encmap, decmap) diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py --- a/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py +++ b/pypy/module/test_lib_pypy/cffi_tests/cffi0/test_parsing.py @@ -387,13 +387,14 @@ def test_enum(): ffi = FFI() ffi.cdef(""" - enum Enum { POS = +1, TWO = 2, NIL = 0, NEG = -1}; + enum Enum { POS = +1, TWO = 2, NIL = 0, NEG = -1, OP = (POS+TWO)-1}; """) C = ffi.dlopen(None) assert C.POS == 1 assert C.TWO == 2 assert C.NIL == 0 assert C.NEG == -1 + assert C.OP == 2 def test_stdcall(): ffi = FFI() diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -237,6 +237,8 @@ 'sys/resource.h', 'grp.h', 'dirent.h', 'sys/stat.h', 'fcntl.h', 'signal.h', 'sys/utsname.h', _ptyh] + if sys.platform.startswith('linux'): + includes.append('sys/sysmacros.h') if sys.platform.startswith('freebsd'): includes.append('sys/ttycom.h') libraries = ['util'] diff --git a/rpython/rlib/rsiphash.py b/rpython/rlib/rsiphash.py --- a/rpython/rlib/rsiphash.py +++ b/rpython/rlib/rsiphash.py @@ -24,14 +24,11 @@ if sys.byteorder == 'little': def _le64toh(x): return x + def _le32toh(x): + return x else: _le64toh = rarithmetic.byteswap - - -class Seed: - k0l = k1l = r_uint64(0) -seed = Seed() - + _le32toh = rarithmetic.byteswap def _decode64(s): return (r_uint64(ord(s[0])) | @@ -43,6 +40,11 @@ r_uint64(ord(s[6])) << 48 | r_uint64(ord(s[7])) << 56) +class Seed: + k0l = k1l = r_uint64(0) +seed = Seed() + + def select_random_seed(s): """'s' is a string of length 16""" seed.k0l = _decode64(s) @@ -177,17 +179,13 @@ """For tests.""" global misaligned_is_fine old = seed.k0l, seed.k1l, misaligned_is_fine - seed.k0l = _le64toh(r_uint64(new_k0)) - seed.k1l = _le64toh(r_uint64(new_k1)) + seed.k0l = r_uint64(new_k0) + seed.k1l = r_uint64(new_k1) if test_misaligned_path: misaligned_is_fine = False yield seed.k0l, seed.k1l, misaligned_is_fine = old -def get_current_seed(): - return _le64toh(seed.k0l), _le64toh(seed.k1l) - - magic0 = r_uint64(0x736f6d6570736575) magic1 = r_uint64(0x646f72616e646f6d) magic2 = r_uint64(0x6c7967656e657261) @@ -271,7 +269,8 @@ size = 4 if size == 4: if direct: - t |= r_uint64(llop.raw_load(rffi.UINT, addr_in, index)) + v = _le32toh(r_uint32(llop.raw_load(rffi.UINT, addr_in, index))) + t |= r_uint64(v) size = 0 else: t |= r_uint64(llop.raw_load(rffi.UCHAR, addr_in, index + 3)) << 24 @@ -287,7 +286,7 @@ size = 0 assert size == 0 - b |= _le64toh(t) + b |= t v3 ^= b v0, v1, v2, v3 = _double_round(v0, v1, v2, v3) diff --git a/rpython/rlib/rvmprof/src/vmprof_getpc.h b/rpython/rlib/rvmprof/src/vmprof_getpc.h --- a/rpython/rlib/rvmprof/src/vmprof_getpc.h +++ b/rpython/rlib/rvmprof/src/vmprof_getpc.h @@ -131,7 +131,7 @@ // typedef int ucontext_t; // #endif -intptr_t GetPC(ucontext_t *signal_ucontext) { +static intptr_t GetPC(ucontext_t *signal_ucontext) { // RAW_LOG(ERROR, "GetPC is not yet implemented on Windows\n"); fprintf(stderr, "GetPC is not yet implemented on Windows\n"); return NULL; @@ -142,7 +142,7 @@ // the right value for your system, and add it to the list in // vmrpof_config.h #else -intptr_t GetPC(ucontext_t *signal_ucontext) { +static intptr_t GetPC(ucontext_t *signal_ucontext) { return signal_ucontext->PC_FROM_UCONTEXT; // defined in config.h } diff --git a/rpython/rlib/rvmprof/src/vmprof_main.h b/rpython/rlib/rvmprof/src/vmprof_main.h --- a/rpython/rlib/rvmprof/src/vmprof_main.h +++ b/rpython/rlib/rvmprof/src/vmprof_main.h @@ -104,8 +104,8 @@ #include <setjmp.h> -volatile int spinlock; -jmp_buf restore_point; +static volatile int spinlock; +static jmp_buf restore_point; static void segfault_handler(int arg) { diff --git a/rpython/rlib/test/test_rsiphash.py b/rpython/rlib/test/test_rsiphash.py --- a/rpython/rlib/test/test_rsiphash.py +++ b/rpython/rlib/test/test_rsiphash.py @@ -52,12 +52,12 @@ os.environ['PYTHONHASHSEED'] = '0' initialize_from_env() assert siphash24("foo") == 15988776847138518036 - # value checked with CPython 3.5 + # value checked with CPython 3.5 (turned positive by adding 2**64) os.environ['PYTHONHASHSEED'] = '4000000000' initialize_from_env() assert siphash24("foo") == 13829150778707464258 - # value checked with CPython 3.5 + # value checked with CPython 3.5 (turned positive by adding 2**64) for env in ['', 'random']: os.environ['PYTHONHASHSEED'] = env @@ -118,8 +118,9 @@ 123, 123, intmask(15988776847138518036), 456, 456, intmask(15988776847138518036), 789, 789] - assert s1[8] in [intmask(17593683438421985039), # ucs2 mode - intmask(94801584261658677)] # ucs4 mode + assert s1[8] in [intmask(17593683438421985039), # ucs2 mode little endian + intmask(94801584261658677), # ucs4 mode little endian + intmask(3849431280840015342),] # ucs4 mode big endian os.environ['PYTHONHASHSEED'] = '3987654321' s1 = getall() @@ -127,8 +128,9 @@ 123, 123, intmask(5890804383681474441), 456, 456, intmask(5890804383681474441), 789, 789] - assert s1[8] in [intmask(4192582507672183374), # ucs2 mode - intmask(7179255293164649778)] # ucs4 mode + assert s1[8] in [intmask(4192582507672183374), # ucs2 mode little endian + intmask(7179255293164649778), # ucs4 mode little endian + intmask(-3945781295304514711),] # ucs4 mode big endian for env in ['', 'random']: os.environ['PYTHONHASHSEED'] = env _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit