[pypy-commit] cffi release-1.10: release branch

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: release-1.10
Changeset: r2910:a051c529f3b3
Date: 2017-03-15 09:07 +0100
http://bitbucket.org/cffi/cffi/changeset/a051c529f3b3/

Log:release branch

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Match the description of '-u' to its more correct variant in the python

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90694:45a687d2768f
Date: 2017-03-15 11:28 +0100
http://bitbucket.org/pypy/pypy/changeset/45a687d2768f/

Log:Match the description of '-u' to its more correct variant in the
python man page, and not the error-inducing one in 'python3 --help'.
See also http://bugs.python.org/issue28647

diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -19,8 +19,9 @@
 -q : don't print version and copyright messages on interactive startup
 -s : don't add user site directory to sys.path; also PYTHONNOUSERSITE
 -S : don't imply 'import site' on initialization
--u : unbuffered binary stdout and stderr, stdin always buffered;
- also PYTHONUNBUFFERED=x
+-u : force the binary I/O layers of stdout and stderr to be unbuffered.
+ stdin is always buffered. the text I/O layer will still be
+ line-buffered. see also PYTHONUNBUFFERED=x
 -v : verbose (trace import statements); also PYTHONVERBOSE=x
  can be supplied multiple times to increase verbosity
 -V : print the Python version number and exit (also --version)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Copy more closely the logic of sysconfig_cpython.py. Fix for the

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90695:b517a201935d
Date: 2017-03-15 12:01 +0100
http://bitbucket.org/pypy/pypy/changeset/b517a201935d/

Log:Copy more closely the logic of sysconfig_cpython.py. Fix for the
'venv' standard module on pypy3.

diff --git a/lib-python/3/distutils/sysconfig_pypy.py 
b/lib-python/3/distutils/sysconfig_pypy.py
--- a/lib-python/3/distutils/sysconfig_pypy.py
+++ b/lib-python/3/distutils/sysconfig_pypy.py
@@ -19,13 +19,16 @@
 
 PREFIX = os.path.normpath(sys.prefix)
 EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
+BASE_PREFIX = os.path.normpath(sys.base_prefix)
+BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
 project_base = os.path.dirname(os.path.abspath(sys.executable))
 python_build = False
 
 
 def get_python_inc(plat_specific=0, prefix=None):
-from os.path import join as j
-return j(sys.prefix, 'include')
+if prefix is None:
+prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
+return os.path.join(prefix, 'include')
 
 def get_python_version():
 """Return a string containing the major and minor Python version,
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy vmprof-native: merge default

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90696:107955f416ca
Date: 2017-03-14 14:30 +0100
http://bitbucket.org/pypy/pypy/changeset/107955f416ca/

Log:merge default

diff too long, truncating to 2000 out of 37236 lines

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -60,6 +60,9 @@
 ^lib_pypy/ctypes_config_cache/_.+_cache\.py$
 ^lib_pypy/ctypes_config_cache/_.+_.+_\.py$
 ^lib_pypy/_libmpdec/.+.o$
+^lib_pypy/.+.c$
+^lib_pypy/.+.o$
+^lib_pypy/.+.so$
 ^pypy/doc/discussion/.+\.html$
 ^include/.+\.h$
 ^include/.+\.inl$
@@ -74,7 +77,7 @@
 ^rpython/doc/_build/.*$
 ^compiled
 ^.git/
-^.hypothesis/
+.hypothesis/
 ^release/
 ^rpython/_cache$
 
diff --git a/extra_tests/README.txt b/extra_tests/README.txt
new file mode 100644
--- /dev/null
+++ b/extra_tests/README.txt
@@ -0,0 +1,5 @@
+The tests in this directory are a complement to lib-python/3/test/.
+
+They are meant to run on top of a compiled pypy3 or CPython3.5 in an
+environment containing at least pytest and hypothesis, using a command like
+'pytest extra_tests/'.
diff --git a/extra_tests/pytest.ini b/extra_tests/pytest.ini
new file mode 100644
diff --git a/extra_tests/test_unicode.py b/extra_tests/test_unicode.py
new file mode 100644
--- /dev/null
+++ b/extra_tests/test_unicode.py
@@ -0,0 +1,34 @@
+import pytest
+from hypothesis import strategies as st
+from hypothesis import given, settings, example
+
+from unicodedata import normalize
+
+# For every (n1, n2, n3) triple, applying n1 then n2 must be the same
+# as applying n3.
+# Reference: http://unicode.org/reports/tr15/#Design_Goals
+compositions = [
+('NFC', 'NFC', 'NFC'),
+('NFC', 'NFD', 'NFD'),
+('NFC', 'NFKC', 'NFKC'),
+('NFC', 'NFKD', 'NFKD'),
+('NFD', 'NFC', 'NFC'),
+('NFD', 'NFD', 'NFD'),
+('NFD', 'NFKC', 'NFKC'),
+('NFD', 'NFKD', 'NFKD'),
+('NFKC', 'NFC', 'NFKC'),
+('NFKC', 'NFD', 'NFKD'),
+('NFKC', 'NFKC', 'NFKC'),
+('NFKC', 'NFKD', 'NFKD'),
+('NFKD', 'NFC', 'NFKC'),
+('NFKD', 'NFD', 'NFKD'),
+('NFKD', 'NFKC', 'NFKC'),
+('NFKD', 'NFKD', 'NFKD'),
+]
+
+@pytest.mark.parametrize('norm1, norm2, norm3', compositions)
+@settings(max_examples=1000)
+@example(s=u'---\uafb8\u11a7---')  # issue 2289
+@given(s=st.text())
+def test_composition(s, norm1, norm2, norm3):
+assert normalize(norm2, normalize(norm1, s)) == normalize(norm3, s)
diff --git a/lib-python/2.7/collections.py b/lib-python/2.7/collections.py
--- a/lib-python/2.7/collections.py
+++ b/lib-python/2.7/collections.py
@@ -33,6 +33,10 @@
 from __pypy__ import reversed_dict as _reversed_dict
 except ImportError:
 _reversed_dict = None # don't have ordered dicts
+try:
+from __pypy__ import dict_popitem_first as _dict_popitem_first
+except ImportError:
+_dict_popitem_first = None
 
 try:
 from thread import get_ident as _get_ident
@@ -44,6 +48,17 @@
 ### OrderedDict
 

 
+if _dict_popitem_first is None:
+def _dict_popitem_first(self):
+it = dict.iteritems(self)
+try:
+k, v = it.next()
+except StopIteration:
+raise KeyError('dictionary is empty')
+dict.__delitem__(self, k)
+return (k, v)
+
+
 class OrderedDict(dict):
 '''Dictionary that remembers insertion order.
 
@@ -68,12 +83,7 @@
 if last:
 return dict.popitem(self)
 else:
-it = dict.__iter__(self)
-try:
-k = it.next()
-except StopIteration:
-raise KeyError('dictionary is empty')
-return (k, self.pop(k))
+return _dict_popitem_first(self)
 
 def __repr__(self, _repr_running={}):
 'od.__repr__() <==> repr(od)'
diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py
--- a/lib-python/2.7/sysconfig.py
+++ b/lib-python/2.7/sysconfig.py
@@ -369,11 +369,8 @@
 
 def _init_posix(vars):
 """Initialize the module as appropriate for POSIX systems."""
-# in cPython, _sysconfigdata is generated at build time, see 
_generate_posix_vars()
-# in PyPy no such module exists
-#from _sysconfigdata import build_time_vars
-#vars.update(build_time_vars)
-return
+from _sysconfigdata import build_time_vars
+vars.update(build_time_vars)
 
 def _init_non_posix(vars):
 """Initialize the module as appropriate for NT"""
@@ -529,7 +526,9 @@
 for suffix, mode, type_ in imp.get_suffixes():
 if type_ == imp.C_EXTENSION:
 _CONFIG_VARS['SOABI'] = suffix.split('.')[1]
-break
+break
+_CONFIG_VARS['INCLUDEPY'] = os.path.join(_CONFIG_VARS['prefix'],
+ 'include')
 
 if args:
 vals = []
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -604,7 +60

[pypy-commit] pypy vmprof-native: copy over the changes from vmprof-python/f7df918fbdd

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90699:aa5c858b1622
Date: 2017-03-15 12:56 +0100
http://bitbucket.org/pypy/pypy/changeset/aa5c858b1622/

Log:copy over the changes from vmprof-python/f7df918fbdd

diff --git a/rpython/rlib/rvmprof/src/shared/_vmprof.c 
b/rpython/rlib/rvmprof/src/shared/_vmprof.c
--- a/rpython/rlib/rvmprof/src/shared/_vmprof.c
+++ b/rpython/rlib/rvmprof/src/shared/_vmprof.c
@@ -248,14 +248,15 @@
 
 
 static PyObject *
-sample_stack_now(PyObject *module, PyObject *args)
+sample_stack_now(PyObject *module, PyObject * args)
 {
 PyThreadState * tstate = NULL;
-PyObject * list;
+PyObject * list = NULL;
 int i;
 int entry_count;
 void ** m;
 void * routine_ip;
+long skip = 0;
 
 // stop any signal to occur
 vmprof_ignore_signals(1);
@@ -265,6 +266,10 @@
 goto error;
 }
 
+if (!PyArg_ParseTuple(args, "l", &skip)) {
+goto error;
+}
+
 tstate = PyGILState_GetThisThreadState();
 m = (void**)malloc(SINGLE_BUF_SIZE);
 if (m == NULL) {
@@ -272,7 +277,7 @@
 vmprof_ignore_signals(0);
 return NULL;
 }
-entry_count = vmp_walk_and_record_stack(tstate->frame, m, 
MAX_STACK_DEPTH-1, 0, 0);
+entry_count = vmp_walk_and_record_stack(tstate->frame, m, 
MAX_STACK_DEPTH-1, skip, 0);
 
 for (i = 0; i < entry_count; i++) {
 routine_ip = m[i];
@@ -337,7 +342,7 @@
 {"disable", disable_vmprof, METH_NOARGS, "Disable profiling."},
 {"write_all_code_objects", write_all_code_objects, METH_NOARGS,
  "Write eagerly all the IDs of code objects"},
-{"sample_stack_now", sample_stack_now, METH_NOARGS, "Sample the stack 
now"},
+{"sample_stack_now", sample_stack_now, METH_VARARGS, "Sample the stack 
now"},
 #ifdef VMP_SUPPORTS_NATIVE_PROFILING
 {"resolve_addr", resolve_addr, METH_VARARGS, "Return the name of the 
addr"},
 #endif
diff --git a/rpython/rlib/rvmprof/src/shared/compat.h 
b/rpython/rlib/rvmprof/src/shared/compat.h
--- a/rpython/rlib/rvmprof/src/shared/compat.h
+++ b/rpython/rlib/rvmprof/src/shared/compat.h
@@ -13,6 +13,7 @@
   #define PyStr_GET_SIZE PyString_GET_SIZE
   #define PyStr_NEW  PyString_FromString
   #define PyLong_NEW PyInt_FromSsize_t
+  #define PyLong_AsLong  PyInt_AsLong
 #  endif
 #endif
 
diff --git a/rpython/rlib/rvmprof/src/shared/machine.c 
b/rpython/rlib/rvmprof/src/shared/machine.c
--- a/rpython/rlib/rvmprof/src/shared/machine.c
+++ b/rpython/rlib/rvmprof/src/shared/machine.c
@@ -27,14 +27,3 @@
 #endif
 }
 
-#ifdef VMP_SUPPORTS_NATIVE_PROFILING
-#include "libudis86/udis86.h"
-unsigned int vmp_machine_code_instr_length(char* pc)
-{
-struct ud u;
-ud_init(&u);
-ud_set_input_buffer(&u, (uint8_t*)pc, 12);
-ud_set_mode(&u, vmp_machine_bits());
-return ud_decode(&u);
-}
-#endif
diff --git a/rpython/rlib/rvmprof/src/shared/machine.h 
b/rpython/rlib/rvmprof/src/shared/machine.h
--- a/rpython/rlib/rvmprof/src/shared/machine.h
+++ b/rpython/rlib/rvmprof/src/shared/machine.h
@@ -10,11 +10,3 @@
  */
 const char * vmp_machine_os_name(void);
 
-/**
- * How many bytes does the x86 instruction take at pc[0..].
- *
- * Returns 0 on failure.
- */
-#ifdef VMP_SUPPORTS_NATIVE_PROFILING
-unsigned int vmp_machine_code_instr_length(char* pc);
-#endif
diff --git a/rpython/rlib/rvmprof/src/shared/trampoline.c 
b/rpython/rlib/rvmprof/src/shared/trampoline.c
--- a/rpython/rlib/rvmprof/src/shared/trampoline.c
+++ b/rpython/rlib/rvmprof/src/shared/trampoline.c
@@ -121,6 +121,16 @@
 }
 #endif
 
+#include "libudis86/udis86.h"
+unsigned int vmp_machine_code_instr_length(char* pc)
+{
+struct ud u;
+ud_init(&u);
+ud_set_input_buffer(&u, (uint8_t*)pc, 12);
+ud_set_mode(&u, vmp_machine_bits());
+return ud_decode(&u);
+}
+
 // a hilarious typo, tramp -> trump :)
 int _redirect_trampoline_and_back(char * eval, char * trump, char * 
vmprof_eval) {
 
diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c 
b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -15,24 +15,18 @@
 #include "compat.h"
 
 #ifdef VMP_SUPPORTS_NATIVE_PROFILING
-#define UNW_LOCAL_ONLY
-#include "unwind/libunwind.h"
-#  ifdef X86_64
-#define REG_RBX UNW_X86_64_RBX
-#  elif defined(X86_32)
-#define REG_RBX UNW_X86_EDI
-#  endif
+#include "unwind/vmprof_unwind.h"
+
+typedef mcontext_t unw_context_t;
 
 // functions copied from libunwind using dlopen
 
-#ifdef VMPROF_UNIX
 static int (*unw_get_reg)(unw_cursor_t*, int, unw_word_t*) = NULL;
 static int (*unw_step)(unw_cursor_t*) = NULL;
 static int (*unw_init_local)(unw_cursor_t *, unw_context_t *) = NULL;
 static int (*unw_get_proc_info)(unw_cursor_t *, unw_proc_info_t *) = NULL;
 static int (*unw_is_signal_frame)(unw_cursor_t *) = NULL;
-static int (*unw_getcontext)(unw_cursor_t *) = NULL;
-#endif
+static int (*unw_getcontext)(unw_context_t *) = NULL;
 
 #endif
 
@@ -176,30 +170,39 @

[pypy-commit] pypy vmprof-native: copy over changes made to vmprof-python

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90697:ac30c079910e
Date: 2017-03-14 15:00 +0100
http://bitbucket.org/pypy/pypy/changeset/ac30c079910e/

Log:copy over changes made to vmprof-python

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
@@ -1,3 +1,5 @@
+#pragma once
+
 /* VMPROF
  *
  * statistical sampling profiler specifically designed to profile programs
@@ -10,45 +12,49 @@
  *
  * Tested only on gcc, linux, x86_64.
  *
- * Copyright (C) 2014-2015
+ * Copyright (C) 2014-2017
  *   Antonio Cuni - anto.c...@gmail.com
  *   Maciej Fijalkowski - fij...@gmail.com
  *   Armin Rigo - ar...@tunes.org
+ *   Richard Plangger - planri...@gmail.com
  *
  */
 
 #define _GNU_SOURCE 1
 
 #include 
+#include 
+#include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "vmprof_stack.h"
+
+#include "vmprof.h"
+
+#include "vmp_stack.h"
 #include "vmprof_getpc.h"
 #include "vmprof_mt.h"
-#include "vmprof_get_custom_offset.h"
 #include "vmprof_common.h"
+#include "compat.h"
+
+#if defined(__unix__)
+#include "rss_unix.h"
+#elif defined(__APPLE__)
+#include "rss_darwin.h"
+#endif
+
 
 //
 
-static long prepare_interval_usec;
-static long saved_profile_file;
-static struct profbuf_s *volatile current_codes;
 static void *(*mainloop_get_virtual_ip)(char *) = 0;
-
-static int opened_profile(char *interp_name);
+static int opened_profile(const char *interp_name, int memory, int proflines, 
int native);
 static void flush_codes(void);
 
-
 //
 
 /* value: last bit is 1 if signals must be ignored; all other bits
@@ -79,24 +85,26 @@
 static char atfork_hook_installed = 0;
 
 
-static intptr_t get_current_thread_id(void)
+/* *
+ * functions to dump the stack trace
+ * *
+ */
+
+int get_stack_trace(PY_THREAD_STATE_T * current, void** result, int max_depth, 
intptr_t pc)
 {
-/* xxx This function is a hack on two fronts:
-
-   - It assumes that pthread_self() is async-signal-safe.  This
- should be true on Linux.  I hope it is also true elsewhere.
-
-   - It abuses pthread_self() by assuming it just returns an
- integer.  According to comments in CPython's source code, the
- platforms where it is not the case are rare nowadays.
-
-   An alternative would be to try to look if the information is
-   available in the ucontext_t in the caller.
-*/
-return (intptr_t)pthread_self();
+PY_STACK_FRAME_T * frame;
+#ifdef RPYTHON_VMPROF
+// do nothing here, 
+frame = (PY_STACK_FRAME_T*)current;
+#else
+if (!current) {
+return 0;
+}
+frame = current->frame;
+#endif
+return vmp_walk_and_record_stack(frame, result, max_depth, 1, pc);
 }
 
-
 /* *
  * the signal handler
  * *
@@ -112,9 +120,67 @@
 longjmp(restore_point, SIGSEGV);
 }
 
+int _vmprof_sample_stack(struct profbuf_s *p, PY_THREAD_STATE_T * tstate, 
ucontext_t * uc)
+{
+int depth;
+struct prof_stacktrace_s *st = (struct prof_stacktrace_s *)p->data;
+st->marker = MARKER_STACKTRACE;
+st->count = 1;
+#ifdef RPYTHON_VMPROF
+depth = get_stack_trace(get_vmprof_stack(), st->stack, MAX_STACK_DEPTH-1, 
(intptr_t)GetPC(uc));
+#else
+depth = get_stack_trace(tstate, st->stack, MAX_STACK_DEPTH-1, 
(intptr_t)NULL);
+#endif
+if (depth == 0) {
+return 0;
+}
+st->depth = depth;
+st->stack[depth++] = tstate;
+long rss = get_current_proc_rss();
+if (rss >= 0)
+st->stack[depth++] = (void*)rss;
+p->data_offset = offsetof(struct prof_stacktrace_s, marker);
+p->data_size = (depth * sizeof(void *) +
+sizeof(struct prof_stacktrace_s) -
+offsetof(struct prof_stacktrace_s, marker));
+return 1;
+}
+
+#ifndef RPYTHON_VMPROF
+static PY_THREAD_STATE_T * _get_pystate_for_this_thread(void) {
+// see issue 116 on github.com/vmprof/vmprof-python.
+// PyGILState_GetThisThreadState(); can hang forever
+//
+PyInterpreterState * istate;
+PyThreadState * state;
+long mythread_id;
+
+istate = PyInterpreterState_Head();
+if (istate == NULL) {
+return NULL;
+}
+mythread_id = PyThread_get_thread_ident();
+// fish fish fish, it will NOT lock the keymutex in pythread
+do {
+state = PyInterpreterState_ThreadHead(istate);
+do {
+if (state->thread_id == mythread_id) {
+r

[pypy-commit] pypy vmprof-native: copy dynamic loading for libunwind functions from pypy's history

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90698:c6cdfd64054c
Date: 2017-03-14 15:12 +0100
http://bitbucket.org/pypy/pypy/changeset/c6cdfd64054c/

Log:copy dynamic loading for libunwind functions from pypy's history

diff --git a/rpython/rlib/rvmprof/src/shared/_vmprof.c 
b/rpython/rlib/rvmprof/src/shared/_vmprof.c
--- a/rpython/rlib/rvmprof/src/shared/_vmprof.c
+++ b/rpython/rlib/rvmprof/src/shared/_vmprof.c
@@ -276,7 +276,7 @@
 
 for (i = 0; i < entry_count; i++) {
 routine_ip = m[i];
-PyList_Append(list, PyLong_NEW((long)routine_ip));
+PyList_Append(list, PyLong_NEW((ssize_t)routine_ip));
 }
 
 free(m);
diff --git a/rpython/rlib/rvmprof/src/shared/compat.h 
b/rpython/rlib/rvmprof/src/shared/compat.h
--- a/rpython/rlib/rvmprof/src/shared/compat.h
+++ b/rpython/rlib/rvmprof/src/shared/compat.h
@@ -7,12 +7,12 @@
   #define PyStr_AS_STRING PyBytes_AS_STRING
   #define PyStr_GET_SIZE PyBytes_GET_SIZE
   #define PyStr_NEW  PyUnicode_FromString
-  #define PyLong_NEW PyLong_FromLong
+  #define PyLong_NEW PyLong_FromSsize_t
 #  else
   #define PyStr_AS_STRING PyString_AS_STRING
   #define PyStr_GET_SIZE PyString_GET_SIZE
   #define PyStr_NEW  PyString_FromString
-  #define PyLong_NEW PyInt_FromLong
+  #define PyLong_NEW PyInt_FromSsize_t
 #  endif
 #endif
 
diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c 
b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -16,12 +16,24 @@
 
 #ifdef VMP_SUPPORTS_NATIVE_PROFILING
 #define UNW_LOCAL_ONLY
-#include 
+#include "unwind/libunwind.h"
 #  ifdef X86_64
 #define REG_RBX UNW_X86_64_RBX
 #  elif defined(X86_32)
 #define REG_RBX UNW_X86_EDI
 #  endif
+
+// functions copied from libunwind using dlopen
+
+#ifdef VMPROF_UNIX
+static int (*unw_get_reg)(unw_cursor_t*, int, unw_word_t*) = NULL;
+static int (*unw_step)(unw_cursor_t*) = NULL;
+static int (*unw_init_local)(unw_cursor_t *, unw_context_t *) = NULL;
+static int (*unw_get_proc_info)(unw_cursor_t *, unw_proc_info_t *) = NULL;
+static int (*unw_is_signal_frame)(unw_cursor_t *) = NULL;
+static int (*unw_getcontext)(unw_cursor_t *) = NULL;
+#endif
+
 #endif
 
 #ifdef __APPLE__
@@ -59,7 +71,7 @@
 int len;
 int addr;
 int j;
-long line;
+uint64_t line;
 char *lnotab;
 
 #ifndef RPYTHON_VMPROF // pypy does not support line profiling
@@ -76,7 +88,7 @@
 lnotab = PyStr_AS_STRING(frame->f_code->co_lnotab);
 
 if (lnotab != NULL) {
-line = (long)frame->f_lineno;
+line = (uint64_t)frame->f_lineno;
 addr = 0;
 
 len = (int)PyStr_GET_SIZE(frame->f_code->co_lnotab);
@@ -202,7 +214,6 @@
 //printf("  %s %p\n", name, func_addr);
 //}
 
-
 //if (func_addr == 0) {
 //unw_word_t rip = 0;
 //if (unw_get_reg(&cursor, UNW_REG_IP, &rip) < 0) {
@@ -479,14 +490,47 @@
 }
 #endif
 
+static const char * vmprof_error = NULL;
+
 int vmp_native_enable(void) {
+void * libhandle;
 vmp_native_traces_enabled = 1;
 
+if (!unw_get_reg) {
+if (!(libhandle = dlopen("libunwind.so", RTLD_LAZY | RTLD_LOCAL))) {
+goto bail_out;
+}
+if (!(unw_getcontext = dlsym(libhandle, "_ULx86_64_getcontext"))) {
+goto bail_out;
+}
+if (!(unw_get_reg = dlsym(libhandle, "_ULx86_64_get_reg"))) {
+goto bail_out;
+}
+if (!(unw_get_proc_info = dlsym(libhandle, 
"_ULx86_64_get_proc_info"))){
+goto bail_out;
+}
+if (!(unw_init_local = dlsym(libhandle, "_ULx86_64_init_local"))) {
+goto bail_out;
+}
+if (!(unw_step = dlsym(libhandle, "_ULx86_64_step"))) {
+goto bail_out;
+}
+if (!(unw_is_signal_frame = dlsym(libhandle, 
"_ULx86_64_is_signal_frame"))) {
+goto bail_out;
+}
+if (dlclose(libhandle)) {
+goto bail_out;
+}
+}
+
 #if defined(__unix__)
 return vmp_read_vmaps("/proc/self/maps");
 #elif defined(__APPLE__)
 return vmp_read_vmaps(NULL);
 #endif
+bail_out:
+fprintf(stderr, "could not load libunwind at runtime. error: %s\n", 
vmprof_error);
+return 0;
 }
 
 void vmp_native_disable(void) {
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof.h 
b/rpython/rlib/rvmprof/src/shared/vmprof.h
--- a/rpython/rlib/rvmprof/src/shared/vmprof.h
+++ b/rpython/rlib/rvmprof/src/shared/vmprof.h
@@ -1,6 +1,8 @@
 #pragma once
 
+#ifdef VMPROF_UNIX
 #include 
+#endif
 
 // common defines
 #define MARKER_STACKTRACE '\x01'
@@ -52,6 +54,7 @@
 // for cpython
 #include "_vmprof.h"
 #include 
+#include 
 #include 
 #define PY_STACK_FRAME_T PyFrameObject
 #define PY_EVAL_RETURN_T PyObject
diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_common.h 
b/rpython/rlib/rvmprof/src/shared/vmprof_common

[pypy-commit] pypy vmprof-native: revert the changes done to rpython/jit/* to support _U_dyn_register and _U_dyn_cancel (does not exist on mac os x)

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90700:abc1cf9c6e4a
Date: 2017-03-15 13:07 +0100
http://bitbucket.org/pypy/pypy/changeset/abc1cf9c6e4a/

Log:revert the changes done to rpython/jit/* to support _U_dyn_register
and _U_dyn_cancel (does not exist on mac os x)

diff --git a/pypy/doc/build.rst b/pypy/doc/build.rst
--- a/pypy/doc/build.rst
+++ b/pypy/doc/build.rst
@@ -80,7 +80,7 @@
 libssl
 
 _vmprof
-libunwind
+libunwind (optional, loaded dynamically at runtime)
 
 Make sure to have these libraries (with development headers) installed
 before building PyPy, otherwise the resulting binary will not contain
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -491,6 +491,7 @@
 if not we_are_translated():
 # Arguments should be unique
 assert len(set(inputargs)) == len(inputargs)
+
 self.setup(looptoken)
 if self.cpu.HAS_CODEMAP:
 self.codemap_builder.enter_portal_frame(jd_id, unique_id,
diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -162,10 +162,9 @@
 jitcell_token.outermost_jitdriver_sd = jitdriver_sd
 return jitcell_token
 
-def record_loop_or_bridge(metainterp_sd, loop, asminfo):
+def record_loop_or_bridge(metainterp_sd, loop):
 """Do post-backend recordings and cleanups on 'loop'.
 """
-from rpython.rlib.rvmprof import rvmprof
 # get the original jitcell token corresponding to jitcell form which
 # this trace starts
 original_jitcell_token = loop.original_jitcell_token
@@ -175,11 +174,6 @@
 wref = weakref.ref(original_jitcell_token)
 clt = original_jitcell_token.compiled_loop_token
 clt.loop_token_wref = wref
-
-rvmprof.dyn_register_jit_page(original_jitcell_token, asminfo.asmaddr,
-  asminfo.asmaddr+asminfo.asmlen)
-
-
 for op in loop.operations:
 descr = op.getdescr()
 # not sure what descr.index is about
@@ -250,9 +244,9 @@
 if not we_are_translated():
 loop.check_consistency()
 jitcell_token.target_tokens = [target_token]
-asminfo = send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd,
-loop, "loop", runtime_args, metainterp.box_names_memo)
-record_loop_or_bridge(metainterp_sd, loop, asminfo)
+send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, "loop",
+ runtime_args, metainterp.box_names_memo)
+record_loop_or_bridge(metainterp_sd, loop)
 return target_token
 
 def compile_loop(metainterp, greenkey, start, inputargs, jumpargs,
@@ -345,9 +339,9 @@
loop_info.extra_before_label + [loop_info.label_op] + 
loop_ops)
 if not we_are_translated():
 loop.check_consistency()
-asminfo = send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd,
-loop, "loop", inputargs, metainterp.box_names_memo)
-record_loop_or_bridge(metainterp_sd, loop, asminfo)
+send_loop_to_backend(greenkey, jitdriver_sd, metainterp_sd, loop, "loop",
+ inputargs, metainterp.box_names_memo)
+record_loop_or_bridge(metainterp_sd, loop)
 loop_info.post_loop_compilation(loop, jitdriver_sd, metainterp, 
jitcell_token)
 return start_descr
 
@@ -422,9 +416,9 @@
 loop.quasi_immutable_deps = quasi_immutable_deps
 
 target_token = loop.operations[-1].getdescr()
-asminfo = resumekey.compile_and_attach(metainterp, loop, inputargs)
+resumekey.compile_and_attach(metainterp, loop, inputargs)
 
-record_loop_or_bridge(metainterp_sd, loop, asminfo)
+record_loop_or_bridge(metainterp_sd, loop)
 return target_token
 
 def get_box_replacement(op, allow_none=False):
@@ -509,12 +503,11 @@
   'compiling', None, name, memo)
 _log = metainterp_sd.jitlog.log_trace(jl.MARK_TRACE_OPT, metainterp_sd, 
None)
 _log.write(inputargs, operations)
-asminfo = metainterp_sd.cpu.compile_loop(inputargs,
+return metainterp_sd.cpu.compile_loop(inputargs,
   operations, looptoken,
   jd_id=jd_id, unique_id=unique_id,
-  log=log, name=name, 
logger=metainterp_sd.jitlog)
-
-return asminfo
+  log=log, name=name,
+  logger=metainterp_sd.jitlog)
 
 def do_compile_bridge(metainterp_sd, faildescr, inputargs, operations,
   original_loop_token, log=True, memo=None):
@@ -524,10 +517,9 @@
 _log = metainterp_sd.jitlog.log_trace(jl.MARK_TRACE_OPT, metainterp_sd, 
None)
 _log.write(inputargs, operations)
 assert isinstance(faildescr, Abstrac

[pypy-commit] stmgc c8-overheads-instrumentation: Fix missing duration measurement of inevitable transactions' validation and initialization of duration struct

2017-03-15 Thread tobweber
Author: Tobias Weber 
Branch: c8-overheads-instrumentation
Changeset: r2031:a73dbda25da5
Date: 2017-03-14 21:25 +0100
http://bitbucket.org/pypy/stmgc/changeset/a73dbda25da5/

Log:Fix missing duration measurement of inevitable transactions'
validation and initialization of duration struct

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -156,10 +156,10 @@
 
 static bool _stm_validate(void)
 {
+/* returns true if we reached a valid state, or false if
+   we need to abort now */
 start_timer();
 
-/* returns true if we reached a valid state, or false if
-   we need to abort now */
 dprintf(("_stm_validate() at cl=%p, rev=%lu\n", 
STM_PSEGMENT->last_commit_log_entry,
  STM_PSEGMENT->last_commit_log_entry->rev_num));
 /* go from last known entry in commit log to the
@@ -173,6 +173,8 @@
 
 if (STM_PSEGMENT->transaction_state == TS_INEVITABLE) {
 assert(first_cl->next == INEV_RUNNING);
+
+stop_timer_and_publish(STM_DURATION_VALIDATION);
 return true;
 }
 
diff --git a/c8/stm/timing.h b/c8/stm/timing.h
--- a/c8/stm/timing.h
+++ b/c8/stm/timing.h
@@ -5,30 +5,31 @@
 /* Use raw monotonic time, i.e., solely based on local hardware (no NTP
adjustments) as in prof.c to obtain values comparable with total program
runtime. */
-#define start_timer() struct timespec start, stop, duration = { 0, 0 };  \
+#define start_timer() struct timespec start, stop; 
\
+  struct timespec duration = { .tv_sec = 0, .tv_nsec = 0 
};\
   continue_timer()
 
 /* Must use start_timer before using this macro. */
-#define get_duration() duration.tv_sec = \
-  stop.tv_sec - start.tv_sec + duration.tv_sec;  \
-   duration.tv_nsec =\
+#define get_duration() duration.tv_sec =\
+  stop.tv_sec - start.tv_sec + duration.tv_sec; \
+   duration.tv_nsec =   \
   stop.tv_nsec - start.tv_nsec + duration.tv_nsec;
 
-#define pause_timer() clock_gettime(CLOCK_MONOTONIC_RAW, &stop); \
+#define pause_timer() clock_gettime(CLOCK_MONOTONIC_RAW, &stop);\
   get_duration()
 
-#define stm_duration_payload(duration)   \
-stm_timing_event_payload_data_t stm_duration_data =  \
-{ .duration = &duration };   \
-stm_timing_event_payload_t stm_duration_payload =\
+#define stm_duration_payload(duration)  \
+stm_timing_event_payload_data_t stm_duration_data = \
+{ .duration = &duration };  \
+stm_timing_event_payload_t stm_duration_payload =   \
 { STM_EVENT_PAYLOAD_DURATION, stm_duration_data };
 
-#define publish_event(event) \
-(timing_enabled() ?  \
-stmcb_timing_event(  \
-STM_SEGMENT->running_thread, event, &stm_duration_payload) : \
+#define publish_event(event)\
+(timing_enabled() ? \
+stmcb_timing_event( \
+STM_SEGMENT->running_thread, event, &stm_duration_payload) :\
 (void)0);
 
-#define stop_timer_and_publish(event) pause_timer()  \
-  stm_duration_payload(duration) \
+#define stop_timer_and_publish(event) pause_timer() \
+  stm_duration_payload(duration)\
   publish_event(event)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] stmgc c8-overheads-instrumentation: Fix logger accesses to running thread info after it has already been reset

2017-03-15 Thread tobweber
Author: Tobias Weber 
Branch: c8-overheads-instrumentation
Changeset: r2032:6c8ad9d4223c
Date: 2017-03-15 13:25 +0100
http://bitbucket.org/pypy/stmgc/changeset/6c8ad9d4223c/

Log:Fix logger accesses to running thread info after it has already been
reset

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -159,6 +159,7 @@
 /* returns true if we reached a valid state, or false if
we need to abort now */
 start_timer();
+stm_thread_local_t *thread_local_for_logging = STM_SEGMENT->running_thread;
 
 dprintf(("_stm_validate() at cl=%p, rev=%lu\n", 
STM_PSEGMENT->last_commit_log_entry,
  STM_PSEGMENT->last_commit_log_entry->rev_num));
@@ -174,7 +175,10 @@
 if (STM_PSEGMENT->transaction_state == TS_INEVITABLE) {
 assert(first_cl->next == INEV_RUNNING);
 
-stop_timer_and_publish(STM_DURATION_VALIDATION);
+if (thread_local_for_logging != NULL) {
+stop_timer_and_publish_for_thread(
+thread_local_for_logging, STM_DURATION_VALIDATION);
+}
 return true;
 }
 
@@ -342,7 +346,10 @@
 release_privatization_lock(my_segnum);
 }
 
-stop_timer_and_publish(STM_DURATION_VALIDATION);
+if (thread_local_for_logging != NULL) {
+stop_timer_and_publish_for_thread(
+thread_local_for_logging, STM_DURATION_VALIDATION);
+}
 
 return !needs_abort;
 }
@@ -1219,6 +1226,7 @@
 static void _core_commit_transaction(bool external)
 {
 start_timer();
+stm_thread_local_t *thread_local_for_logging = STM_SEGMENT->running_thread;
 
 exec_local_finalizers();
 
@@ -1316,7 +1324,8 @@
 
 s_mutex_unlock();
 
-stop_timer_and_publish(STM_DURATION_COMMIT_EXCEPT_GC);
+stop_timer_and_publish_for_thread(
+thread_local_for_logging, STM_DURATION_COMMIT_EXCEPT_GC);
 
 /* between transactions, call finalizers. this will execute
a transaction itself */
diff --git a/c8/stm/gcpage.c b/c8/stm/gcpage.c
--- a/c8/stm/gcpage.c
+++ b/c8/stm/gcpage.c
@@ -747,6 +747,8 @@
 dprintf((" .- major collection ---\n"));
 assert(_has_mutex());
 
+stm_thread_local_t *thread_local_for_logging = STM_SEGMENT->running_thread;
+
 /* first, force a minor collection in each of the other segments */
 major_do_validation_and_minor_collections();
 
@@ -784,8 +786,9 @@
 if (must_abort())
 abort_with_mutex();
 
-stop_timer_and_publish(STM_DURATION_MAJOR_GC_LOG_ONLY);
-
+stop_timer_and_publish_for_thread(
+thread_local_for_logging, STM_DURATION_MAJOR_GC_LOG_ONLY);
+
 return;
 #endif
 }
@@ -843,5 +846,6 @@
 if (must_abort())
 abort_with_mutex();
 
-stop_timer_and_publish(STM_DURATION_MAJOR_GC_FULL);
+stop_timer_and_publish_for_thread(
+thread_local_for_logging, STM_DURATION_MAJOR_GC_FULL);
 }
diff --git a/c8/stm/timing.h b/c8/stm/timing.h
--- a/c8/stm/timing.h
+++ b/c8/stm/timing.h
@@ -10,10 +10,8 @@
   continue_timer()
 
 /* Must use start_timer before using this macro. */
-#define get_duration() duration.tv_sec =\
-  stop.tv_sec - start.tv_sec + duration.tv_sec; \
-   duration.tv_nsec =   \
-  stop.tv_nsec - start.tv_nsec + duration.tv_nsec;
+#define get_duration() duration.tv_sec += stop.tv_sec - start.tv_sec;   \
+   duration.tv_nsec += stop.tv_nsec - start.tv_nsec;
 
 #define pause_timer() clock_gettime(CLOCK_MONOTONIC_RAW, &stop);\
   get_duration()
@@ -24,12 +22,16 @@
 stm_timing_event_payload_t stm_duration_payload =   \
 { STM_EVENT_PAYLOAD_DURATION, stm_duration_data };
 
-#define publish_event(event)\
+#define publish_event(thread_local, event)  \
 (timing_enabled() ? \
-stmcb_timing_event( \
-STM_SEGMENT->running_thread, event, &stm_duration_payload) :\
+stmcb_timing_event(thread_local, event, &stm_duration_payload) :\
 (void)0);
 
-#define stop_timer_and_publish(event) pause_timer() \
-  stm_duration_payload(duration)\
-  publish_event(event)
+#define stop_timer_and_publish_for_thread(thread_local, event)  \
+pause_timer()   \
+stm_duration_payload(duration)  \
+assert(thread_local != NULL);   \
+publish_event(thread_local, event)
+
+#define stop_timer_and_publish(event) 

[pypy-commit] pypy stricter-encode: Try to correctly call error handlers on pypy3 in utf16 and utf32 encoders

2017-03-15 Thread rlamy
Author: Ronan Lamy 
Branch: stricter-encode
Changeset: r90701:af44b848333d
Date: 2017-03-14 17:45 +
http://bitbucket.org/pypy/pypy/changeset/af44b848333d/

Log:Try to correctly call error handlers on pypy3 in utf16 and utf32
encoders

diff --git a/rpython/rlib/runicode.py b/rpython/rlib/runicode.py
--- a/rpython/rlib/runicode.py
+++ b/rpython/rlib/runicode.py
@@ -604,14 +604,19 @@
 _STORECHAR(result, 0xFEFF, BYTEORDER)
 byteorder = BYTEORDER
 
-i = 0
-while i < size:
-ch = ord(s[i])
-i += 1
+pos = 0
+while pos < size:
+ch = ord(s[pos])
+pos += 1
 ch2 = 0
 if 0xD800 <= ch < 0xDFFF:
-errorhandler(
-errors, 'utf16', 'surrogates not allowed', s, i - 1, i)
+ru, rs, pos = errorhandler(
+errors, 'utf16', 'surrogates not allowed', s, pos - 1, pos)
+if rs is not None:
+result.append(rs)
+continue
+else:
+pass  # XXX
 if ch >= 0x1:
 ch2 = 0xDC00 | ((ch-0x1) & 0x3FF)
 ch  = 0xD800 | ((ch-0x1) >> 10)
@@ -772,19 +777,24 @@
 _STORECHAR32(result, 0xFEFF, BYTEORDER)
 byteorder = BYTEORDER
 
-i = 0
-while i < size:
-ch = ord(s[i])
-i += 1
+pos = 0
+while pos < size:
+ch = ord(s[pos])
+pos += 1
 ch2 = 0
 if 0xD800 <= ch < 0xDFFF:
-errorhandler(
-errors, 'utf32', 'surrogates not allowed', s, i - 1, i)
-if MAXUNICODE < 65536 and 0xD800 <= ch <= 0xDBFF and i < size:
-ch2 = ord(s[i])
+ru, rs, pos = errorhandler(
+errors, 'utf32', 'surrogates not allowed', s, pos - 1, pos)
+if rs is not None:
+result.append(rs)
+continue
+else:
+pass  # XXX
+if MAXUNICODE < 65536 and 0xD800 <= ch <= 0xDBFF and pos < size:
+ch2 = ord(s[pos])
 if 0xDC00 <= ch2 <= 0xDFFF:
 ch = (((ch & 0x3FF)<<10) | (ch2 & 0x3FF)) + 0x1;
-i += 1
+pos += 1
 _STORECHAR32(result, ch, byteorder)
 
 return result.build()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: add missing names

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90702:05b724e21868
Date: 2017-03-15 14:56 +0100
http://bitbucket.org/pypy/pypy/changeset/05b724e21868/

Log:add missing names

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -609,6 +609,7 @@
 'Py_FrozenFlag', 'Py_TabcheckFlag', 'Py_UnicodeFlag', 
'Py_IgnoreEnvironmentFlag',
 'Py_DivisionWarningFlag', 'Py_DontWriteBytecodeFlag', 
'Py_NoUserSiteDirectory',
 '_Py_QnewFlag', 'Py_Py3kWarningFlag', 'Py_HashRandomizationFlag', 
'_Py_PackageContext',
+'_PyTraceMalloc_Track', '_PyTraceMalloc_Untrack', 'PyMem_Malloc',
 ]
 TYPES = {}
 FORWARD_DECLS = []
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: hg merge default

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90703:ed16c1e6473c
Date: 2017-03-15 14:59 +0100
http://bitbucket.org/pypy/pypy/changeset/ed16c1e6473c/

Log:hg merge default

diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,3 +1,5 @@
+#encoding utf-8
+
 License
 ===
 
@@ -42,9 +44,9 @@
   Antonio Cuni
   Samuele Pedroni
   Matti Picus
+  Ronan Lamy
   Alex Gaynor
   Philip Jenvey
-  Ronan Lamy
   Brian Kearns
   Richard Plangger
   Michael Hudson
@@ -55,12 +57,12 @@
   Hakan Ardo
   Benjamin Peterson
   Anders Chrigstrom
+  Wim Lavrijsen
   Eric van Riet Paap
-  Wim Lavrijsen
   Richard Emslie
   Alexander Schremmer
+  Remi Meier
   Dan Villiom Podlaski Christiansen
-  Remi Meier
   Lukas Diekmann
   Sven Hager
   Anders Lehmann
@@ -83,8 +85,8 @@
   Lawrence Oluyede
   Bartosz Skowron
   Daniel Roberts
+  Adrien Di Mascio
   Niko Matsakis
-  Adrien Di Mascio
   Alexander Hesse
   Ludovic Aubry
   Jacob Hallen
@@ -100,8 +102,8 @@
   Michael Foord
   Stephan Diehl
   Stefan Schwarzer
+  Tomek Meka
   Valentino Volonghi
-  Tomek Meka
   Stefano Rivera
   Patrick Maupin
   Devin Jeanpierre
@@ -109,268 +111,273 @@
   Bruno Gola
   David Malcolm
   Jean-Paul Calderone
-  Timo Paulssen
   Edd Barrett
   Squeaky
+  Timo Paulssen
   Marius Gedminas
   Alexandre Fayolle
   Simon Burton
+  Nicolas Truessel
   Martin Matusiak
-  Nicolas Truessel
+  Wenzhu Man
   Konstantin Lopuhin
-  Wenzhu Man
   John Witulski
   Laurence Tratt
+  Greg Price
   Ivan Sichmann Freitas
-  Greg Price
   Dario Bertini
+  Jeremy Thurgood
   Mark Pearse
   Simon Cross
-  Jeremy Thurgood
+  Tobias Pape
   Andreas Stührk
-  Tobias Pape
   Jean-Philippe St. Pierre
   Guido van Rossum
   Pavel Vinogradov
   Paweł Piotr Przeradowski
+  William Leslie
+  marky1991
+  Ilya Osadchiy
+  Tobias Oberstein
   Paul deGrandis
-  Ilya Osadchiy
-  marky1991
-  Tobias Oberstein
+  Boris Feigin
+  Taavi Burns
   Adrian Kuhn
-  Boris Feigin
   tav
-  Taavi Burns
   Georg Brandl
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
+  Mike Blume
   Gerald Klix
-  Mike Blume
   Oscar Nierstrasz
+  Rami Chowdhury
   Stefan H. Muller
-  Rami Chowdhury
+  Joannah Nanjekye
   Eugene Oden
+  Tim Felgentreff
+  Jeff Terrace
   Henry Mason
   Vasily Kuznetsov
   Preston Timmons
   David Ripton
-  Jeff Terrace
-  Tim Felgentreff
   Dusty Phillips
   Lukas Renggli
   Guenter Jantzen
-  William Leslie
   Ned Batchelder
+  Amit Regmi
   Anton Gulenko
-  Amit Regmi
-  Ben Young
+  Sergey Matyunin
   Jasper Schulz
+  Andrew Chambers
   Nicolas Chauvat
   Andrew Durdin
-  Andrew Chambers
-  Sergey Matyunin
+  Ben Young
   Michael Schneider
   Nicholas Riley
   Jason Chu
   Igor Trindade Oliveira
   Yichao Yu
+  Michael Twomey
   Rocco Moretti
   Gintautas Miliauskas
-  Michael Twomey
   Lucian Branescu Mihaila
   anatoly techtonik
+  Karl Bartel
   Gabriel Lavoie
+  Jared Grubb
   Olivier Dormond
-  Jared Grubb
-  Karl Bartel
   Wouter van Heyst
+  Sebastian Pawluś
   Brian Dorsey
   Victor Stinner
   Andrews Medina
-  Sebastian Pawluś
-  Stuart Williams
-  Daniel Patrick
   Aaron Iles
   Toby Watson
+  Daniel Patrick
+  Stuart Williams
   Antoine Pitrou
   Christian Hudon
+  Justas Sadzevicius
+  Neil Shepperd
   Michael Cheng
-  Justas Sadzevicius
+  Mikael Schönenberg
+  Stanislaw Halik
+  Berkin Ilbeyi
   Gasper Zejn
-  Neil Shepperd
-  Stanislaw Halik
-  Mikael Schönenberg
-  Berkin Ilbeyi
   Faye Zhao
   Elmo Mäntynen
-  Jonathan David Riehl
   Anders Qvist
   Corbin Simpson
   Chirag Jadwani
+  Jonathan David Riehl
   Beatrice During
   Alex Perry
+  p_ziesch...@yahoo.de
+  Robert Zaremba
+  Alan McIntyre
+  Alexander Sedov
   Vaibhav Sood
-  Alan McIntyre
   Reuben Cummings
-  Alexander Sedov
-  p_ziesch...@yahoo.de
   Attila Gobi
   Christopher Pope
-  Aaron Gallagher
+  Tristan Arthur
+  Christian Tismer 
+  Dan Stromberg
+  Carl Meyer
   Florin Papa
-  Christian Tismer 
-  Marc Abramowitz
-  Dan Stromberg
-  Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
   touilleMan
+  Marc Abramowitz
+  Arjun Naik
+  Aaron Gallagher
   Alexis Daboville
-  Jens-Uwe Mager
-  Carl Meyer
+  Pieter Zieschang
   Karl Ramm
-  Pieter Zieschang
-  Gabriel
   Lukas Vacek
-  Kunal Grover
-  Andrew Dalke
+  Omer Katz
+  Jacek Generowicz
   Sylvain Thenault
   Jakub Stasiak
+  Stefan Beyer
+  Andrew Dalke
+  Alejandro J. Cura
+  Vladimir Kryachko
+  Gabriel
+  Mark Williams
+  Kunal Grover
   Nathan Taylor
-  Vladimir Kryachko
-  Omer Katz
-  Mark Williams
-  Jacek Generowicz
-  Alejandro J. Cura
+  Travis Francis Athougies
+  Yasir Suhail
+  Sergey Kishchenko
+  Martin Blais
+  Lutz Paelike
+  Ian Foote
+  Philipp Rustemeuer
+  Catalin Gabriel Manciu
   Jacob Oscarson
-  Travis Francis Athougies
   Ryan Gonzalez
-  Ian Foote
   Kristjan Valur Jonsson
+  Lucio Torre
+  Richard Lancaster
+  Dan Buch
+  Lene Wagner
+  Tomo Cocoa
+  Alecsandru Patrascu
   David Lievens
   Neil Blakey-Milner
-  Lutz Paelike
-  Lucio Torre
+  Henrik Vendelbo
   Lars Wasserma

[pypy-commit] pypy py3.5: add missing names

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90704:f4793ab18123
Date: 2017-03-15 15:00 +0100
http://bitbucket.org/pypy/pypy/changeset/f4793ab18123/

Log:add missing names

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -620,6 +620,7 @@
 'PyMem_Malloc', 'PyMem_Calloc', 'PyMem_Realloc', 'PyMem_Free',
 'PyObject_CallFinalizerFromDealloc',
 '_PyTraceMalloc_Track', '_PyTraceMalloc_Untrack',
+'PyBytes_FromFormat', 'PyBytes_FromFormatV',
 ]
 TYPES = {}
 FORWARD_DECLS = []
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Use correct struct definitions for modules

2017-03-15 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r90705:4838a4613d1c
Date: 2017-03-15 14:25 +
http://bitbucket.org/pypy/pypy/changeset/4838a4613d1c/

Log:Use correct struct definitions for modules

diff --git a/pypy/module/cpyext/include/moduleobject.h 
b/pypy/module/cpyext/include/moduleobject.h
--- a/pypy/module/cpyext/include/moduleobject.h
+++ b/pypy/module/cpyext/include/moduleobject.h
@@ -6,31 +6,7 @@
 extern "C" {
 #endif
 
-typedef struct PyModuleDef_Base {
-  PyObject_HEAD
-  PyObject* (*m_init)(void);
-  Py_ssize_t m_index;
-  PyObject* m_copy;
-} PyModuleDef_Base;
-
-#define PyModuleDef_HEAD_INIT { \
-PyObject_HEAD_INIT(NULL)\
-NULL, /* m_init */  \
-0,/* m_index */ \
-NULL, /* m_copy */  \
-  }
-
-typedef struct PyModuleDef{
-  PyModuleDef_Base m_base;
-  const char* m_name;
-  const char* m_doc;
-  Py_ssize_t m_size;
-  PyMethodDef *m_methods;
-  inquiry m_reload;
-  traverseproc m_traverse;
-  inquiry m_clear;
-  freefunc m_free;
-}PyModuleDef;
+#include "cpyext_moduleobject.h"
 
 #ifdef __cplusplus
 }
diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -1,6 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.module.cpyext.api import cpython_api, cpython_struct, \
-METH_STATIC, METH_CLASS, METH_COEXIST, CANNOT_FAIL, CONST_STRING
+from pypy.module.cpyext.api import (
+cpython_api, METH_STATIC, METH_CLASS, METH_COEXIST, CANNOT_FAIL, cts,
+parse_dir)
 from pypy.module.cpyext.pyobject import PyObject, as_pyobj
 from pypy.interpreter.module import Module
 from pypy.module.cpyext.methodobject import (
@@ -10,18 +11,8 @@
 from pypy.module.cpyext.state import State
 from pypy.interpreter.error import oefmt
 
-PyModuleDef_BaseStruct = cpython_struct(
-'PyModuleDef_Base',
-[])
-
-PyModuleDefStruct = cpython_struct(
-'PyModuleDef',
-[('m_base', PyModuleDef_BaseStruct),
- ('m_name', rffi.CCHARP),
- ('m_doc', rffi.CCHARP),
- ('m_methods', lltype.Ptr(PyMethodDef)),
- ], level=2)
-PyModuleDef = lltype.Ptr(PyModuleDefStruct)
+cts.parse_header(parse_dir / 'cpyext_moduleobject.h')
+PyModuleDef = cts.gettype('PyModuleDef *')
 
 @cpython_api([PyModuleDef, rffi.INT_real], PyObject)
 def PyModule_Create2(space, module, api_version):
diff --git a/pypy/module/cpyext/parse/cpyext_moduleobject.h 
b/pypy/module/cpyext/parse/cpyext_moduleobject.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/cpyext/parse/cpyext_moduleobject.h
@@ -0,0 +1,38 @@
+typedef struct PyModuleDef_Base {
+  PyObject_HEAD
+  PyObject* (*m_init)(void);
+  Py_ssize_t m_index;
+  PyObject* m_copy;
+} PyModuleDef_Base;
+
+#define PyModuleDef_HEAD_INIT { \
+PyObject_HEAD_INIT(NULL)\
+NULL, /* m_init */  \
+0,/* m_index */ \
+NULL, /* m_copy */  \
+  }
+
+struct PyModuleDef_Slot;
+/* New in 3.5 */
+typedef struct PyModuleDef_Slot{
+int slot;
+void *value;
+} PyModuleDef_Slot;
+
+#define Py_mod_create 1
+#define Py_mod_exec 2
+
+#define _Py_mod_LAST_SLOT 2
+
+
+typedef struct PyModuleDef{
+  PyModuleDef_Base m_base;
+  const char* m_name;
+  const char* m_doc;
+  Py_ssize_t m_size;
+  PyMethodDef *m_methods;
+  struct PyModuleDef_Slot* m_slots;
+  traverseproc m_traverse;
+  inquiry m_clear;
+  freefunc m_free;
+} PyModuleDef;
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy vmprof-native: remove files not needed by vmprof anymore

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90706:47e816fb4917
Date: 2017-03-15 15:44 +0100
http://bitbucket.org/pypy/pypy/changeset/47e816fb4917/

Log:remove files not needed by vmprof anymore

diff too long, truncating to 2000 out of 10237 lines

diff --git a/rpython/rlib/rvmprof/src/shared/libudis86/Makefile.am 
b/rpython/rlib/rvmprof/src/shared/libudis86/Makefile.am
deleted file mode 100644
--- a/rpython/rlib/rvmprof/src/shared/libudis86/Makefile.am
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# -- udis86/libudis86
-#
-
-PYTHON  = @PYTHON@
-OPTABLE = @top_srcdir@/docs/x86/optable.xml
-
-MAINTAINERCLEANFILES = Makefile.in
-
-lib_LTLIBRARIES = libudis86.la
-
-libudis86_la_SOURCES = \
-   itab.c \
-   decode.c \
-   syn.c \
-   syn-intel.c \
-   syn-att.c \
-   udis86.c \
-   udint.h \
-   syn.h \
-   decode.h
-
-include_ladir = ${includedir}/libudis86
-include_la_HEADERS = \
-   types.h \
-   extern.h \
-   itab.h
-
-
-BUILT_SOURCES = \
-   itab.c \
-   itab.h
-
-#
-# DLLs may not contain undefined symbol references.  
-# We have the linker check this explicitly.
-#
-if TARGET_WINDOWS
-libudis86_la_LDFLAGS = -no-undefined -version-info 0:0:0
-endif
-
-itab.c itab.h: $(OPTABLE) \
-   $(top_srcdir)/scripts/ud_itab.py \
-   $(top_srcdir)/scripts/ud_opcode.py
-   $(PYTHON) $(top_srcdir)/scripts/ud_itab.py $(OPTABLE) $(srcdir)
-
-
-clean-local:
-   rm -rf $(BUILT_SOURCES)
-
-maintainer-clean-local:
diff --git a/rpython/rlib/rvmprof/src/shared/libudis86/README.md 
b/rpython/rlib/rvmprof/src/shared/libudis86/README.md
deleted file mode 100644
--- a/rpython/rlib/rvmprof/src/shared/libudis86/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# COPYING
-
-Copied from https://github.com/vmt/udis86 and ran the script command to 
generate itab.h/c
-
-# LICENCE
-
-BSD 2-clause license
diff --git a/rpython/rlib/rvmprof/src/shared/libudis86/decode.c 
b/rpython/rlib/rvmprof/src/shared/libudis86/decode.c
deleted file mode 100644
--- a/rpython/rlib/rvmprof/src/shared/libudis86/decode.c
+++ /dev/null
@@ -1,1266 +0,0 @@
-/* udis86 - libudis86/decode.c
- * 
- * Copyright (c) 2002-2009 Vivek Thampi
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without 
modification, 
- * are permitted provided that the following conditions are met:
- * 
- * * Redistributions of source code must retain the above copyright 
notice, 
- *   this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright 
notice, 
- *   this list of conditions and the following disclaimer in the 
documentation 
- *   and/or other materials provided with the distribution.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND 
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED 
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
FOR 
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
DAMAGES 
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
SERVICES; 
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
ON 
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS 
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "udint.h"
-#include "types.h"
-#include "extern.h"
-#include "decode.h"
-
-#ifndef __UD_STANDALONE__
-# include 
-#endif /* __UD_STANDALONE__ */
-
-/* The max number of prefixes to an instruction */
-#define MAX_PREFIXES15
-
-/* rex prefix bits */
-#define REX_W(r)( ( 0xF & ( r ) )  >> 3 )
-#define REX_R(r)( ( 0x7 & ( r ) )  >> 2 )
-#define REX_X(r)( ( 0x3 & ( r ) )  >> 1 )
-#define REX_B(r)( ( 0x1 & ( r ) )  >> 0 )
-#define REX_PFX_MASK(n) ( ( P_REXW(n) << 3 ) | \
-  ( P_REXR(n) << 2 ) | \
-  ( P_REXX(n) << 1 ) | \
-  ( P_REXB(n) << 0 ) )
-
-/* scable-index-base bits */
-#define SIB_S(b)( ( b ) >> 6 )
-#define SIB_I(b)( ( ( b ) >> 3 ) & 7 )
-#define SIB_B(b)( ( b ) & 7 )
-
-/* modrm bits */
-#define MODRM_REG(b)( ( ( b ) >> 3 ) & 7 )
-#define MODRM_NNN(b)( ( ( b ) >> 3 ) & 7 )
-#define MODRM_MOD(b)( ( ( b ) >> 6 ) & 3 )
-#define MODRM_RM(b) ( ( b ) & 7 )
-
-static int decode_ext(struct ud *u, uint16_t ptr);
-static int decode_opcode(struct ud *u);
-
-enum reg_class { /* register classes */
-  REGCLASS_GPR,
-  REGCLASS_MMX,
-  REGCLASS_CR,
-  REGCLASS_DB,
-  REGCLASS_SEG,
-  REGCLASS_XMM
-};
-
- /* 
- * inp_start
- *Should be called before each de-code operation.
- */
-static void
-inp_start(struct ud *u)
-{
-  u->inp_ctr

[pypy-commit] pypy vmprof-native: fix test, no debugging symbols could be found

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90707:0f877a858b49
Date: 2017-03-15 17:22 +0100
http://bitbucket.org/pypy/pypy/changeset/0f877a858b49/

Log:fix test, no debugging symbols could be found

diff --git a/rpython/rlib/rvmprof/src/rvmprof.c 
b/rpython/rlib/rvmprof/src/rvmprof.c
--- a/rpython/rlib/rvmprof/src/rvmprof.c
+++ b/rpython/rlib/rvmprof/src/rvmprof.c
@@ -8,6 +8,7 @@
 #  include "structdef.h"
 #  include "src/threadlocal.h"
 #  include "rvmprof.h"
+#  include "forwarddecl.h"
 #endif
 
 
@@ -23,7 +24,6 @@
 #ifdef RPYTHON_LL2CTYPES
 int IS_VMPROF_EVAL(void * ptr) { return 0; }
 #else
-extern void * __vmprof_eval_vmprof;
 int IS_VMPROF_EVAL(void * ptr)
 {
 return ptr == __vmprof_eval_vmprof;
diff --git a/rpython/rlib/rvmprof/src/shared/vmp_stack.c 
b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
--- a/rpython/rlib/rvmprof/src/shared/vmp_stack.c
+++ b/rpython/rlib/rvmprof/src/shared/vmp_stack.c
@@ -25,6 +25,7 @@
 static int (*unw_step)(unw_cursor_t*) = NULL;
 static int (*unw_init_local)(unw_cursor_t *, unw_context_t *) = NULL;
 static int (*unw_get_proc_info)(unw_cursor_t *, unw_proc_info_t *) = NULL;
+static int (*unw_get_proc_name)(unw_cursor_t *, char *, size_t, unw_word_t*) = 
NULL;
 static int (*unw_is_signal_frame)(unw_cursor_t *) = NULL;
 static int (*unw_getcontext)(unw_context_t *) = NULL;
 
@@ -226,7 +227,7 @@
 //printf("func_addr is 0, now %p\n", rip);
 //}
 
-#ifdef RPYTHON_VMPROF
+#ifdef PYPY_JIT_CODEMAP
 long start_addr = 0;
 unw_word_t rip = 0;
 if (unw_get_reg(&cursor, UNW_REG_IP, &rip) < 0) {
@@ -237,7 +238,7 @@
 if (IS_VMPROF_EVAL((void*)pip.start_ip)) {
 // yes we found one stack entry of the python frames!
 return vmp_walk_and_record_python_stack_only(frame, result, 
max_depth, depth, pc);
-#ifdef RPYTHON_VMPROF
+#ifdef PYPY_JIT_CODEMAP
 } else if (pypy_find_codemap_at_addr(rip, &start_addr) != NULL) {
 depth = vmprof_write_header_for_jit_addr(result, depth, pc, 
max_depth);
 return vmp_walk_and_record_python_stack_only(frame, result, 
max_depth, depth, pc);
@@ -468,6 +469,8 @@
 #define UL_PREFIX ""
 #endif
 
+extern void * __vmprof_eval_vmprof_addr;
+
 int vmp_native_enable(void) {
 void * libhandle;
 vmp_native_traces_enabled = 1;
@@ -482,6 +485,9 @@
 if (!(unw_get_proc_info = dlsym(libhandle, UL_PREFIX PREFIX 
"_get_proc_info"))){
 goto bail_out;
 }
+if (!(unw_get_proc_name = dlsym(libhandle, UL_PREFIX PREFIX 
"_get_proc_name"))){
+goto bail_out;
+}
 if (!(unw_init_local = dlsym(libhandle, UL_PREFIX PREFIX 
"_init_local"))) {
 goto bail_out;
 }
diff --git a/rpython/rlib/rvmprof/test/test_rvmprof.py 
b/rpython/rlib/rvmprof/test/test_rvmprof.py
--- a/rpython/rlib/rvmprof/test/test_rvmprof.py
+++ b/rpython/rlib/rvmprof/test/test_rvmprof.py
@@ -151,18 +151,22 @@
 os.unlink(tmpfilename)
 
 def test_native():
-eci = ExternalCompilationInfo(compile_extra=['-g','-O1'],
+eci = ExternalCompilationInfo(compile_extra=['-g','-O0'],
 separate_module_sources=["""
-RPY_EXTERN int native_func(void) {
+RPY_EXTERN int native_func(int d) {
 int j = 0;
-for (int i = 0; i < 42; i++) {
-j += 1;
+if (d > 0) {
+return native_func(d-1);
+} else {
+for (int i = 0; i < 42000; i++) {
+j += d;
+}
 }
 return j;
 }
 """])
 
-native_func = rffi.llexternal("native_func", [], rffi.INT,
+native_func = rffi.llexternal("native_func", [rffi.INT], rffi.INT,
   compilation_info=eci)
 
 class MyCode:
@@ -180,7 +184,7 @@
 if num > 0:
 return main(code, num-1)
 else:
-return native_func()
+return native_func(100)
 
 tmpfilename = str(udir.join('test_rvmprof'))
 
@@ -195,8 +199,7 @@
 period = 0.0001
 rvmprof.enable(fd, period, native=1)
 for i in range(num):
-res = main(code, 10)
-#assert res == 4950
+res = main(code, 3)
 rvmprof.disable()
 os.close(fd)
 return 0
@@ -217,8 +220,7 @@
 walk(child, symbols)
 symbols = []
 walk(tree, symbols)
-not_found = ['n:pypy_g_main', 'n:native_func', 'n:pypy_g_f',
-'n:pypy_g_main']
+not_found = ['n:native_func']
 for sym in symbols:
 for i,name in enumerate(not_found):
 if sym.startswith(name):
@@ -226,7 +228,7 @@
 break
 assert not_found == []
 
-fn = compile(f, [], gcpolicy="minimark")
+fn = compile(f, [], gcpolicy="incminimark", lldebug=True)
 assert fn() == 0
 try:

[pypy-commit] pypy vmprof-native: remove vmp_dynamic.c and do not use the API exposed of that c file

2017-03-15 Thread plan_rich
Author: Richard Plangger 
Branch: vmprof-native
Changeset: r90708:76c2ff962014
Date: 2017-03-15 17:43 +0100
http://bitbucket.org/pypy/pypy/changeset/76c2ff962014/

Log:remove vmp_dynamic.c and do not use the API exposed of that c file

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
@@ -53,7 +53,6 @@
 SHARED.join('machine.c'),
 SHARED.join('symboltable.c'),
 SHARED.join('vmp_stack.c'),
-SHARED.join('vmp_dynamic.c'),
 ] + separate_module_files,
 post_include_bits=[],
 compile_extra=compile_extra
@@ -92,19 +91,6 @@
   lltype.Signed, compilation_info=eci,
   _nowrapper=True)
 
-vmp_dyn_register_jit_page = rffi.llexternal("vmp_dyn_register_jit_page",
-  [lltype.Signed, lltype.Signed, rffi.CCHARP],
-  rffi.INT, compilation_info=eci,
-  _nowrapper=True)
-
-vmp_dyn_cancel = rffi.llexternal("vmp_dyn_cancel", [rffi.INT],
-  lltype.Void, compilation_info=eci,
-  _nowrapper=True)
-
-vmp_dyn_teardown = rffi.llexternal("vmp_dyn_teardown", [lltype.Void],
-   rffi.INT, compilation_info=eci,
-   _nowrapper=True)
-
 return CInterface(locals())
 
 
diff --git a/rpython/rlib/rvmprof/src/shared/vmp_dynamic.c 
b/rpython/rlib/rvmprof/src/shared/vmp_dynamic.c
deleted file mode 100644
--- a/rpython/rlib/rvmprof/src/shared/vmp_dynamic.c
+++ /dev/null
@@ -1,133 +0,0 @@
-#include "vmp_dynamic.h"
-
-#include 
-#include 
-#include 
-
-static int g_dyn_entry_count = 0;
-static int g_has_holes = -1;
-static int g_dyn_entry_count_max = 0;
-static unw_dyn_info_t ** g_dyn_entries = 0;
-
-RPY_EXTERN
-int vmp_dyn_teardown(void)
-{
-int i;
-for (i = 0; i < g_dyn_entry_count; i++) {
-unw_dyn_info_t * u = g_dyn_entries[i];
-if (u != NULL) {
-free(u);
-g_dyn_entries[i] = NULL;
-}
-}
-if (g_dyn_entries != NULL) {
-free(g_dyn_entries);
-}
-g_dyn_entry_count = 0;
-g_dyn_entry_count_max = 0;
-g_has_holes = -1;
-return 0;
-}
-
-static void _vmp_dyn_resize(void) {
-if (g_dyn_entry_count_max == 0) {
-g_dyn_entry_count_max = 128;
-g_dyn_entries = (unw_dyn_info_t**)calloc(sizeof(unw_dyn_info_t*), 128);
-}
-
-if (g_dyn_entry_count + 1 >= g_dyn_entry_count_max) {
-g_dyn_entry_count_max *= 2;
-g_dyn_entries = (unw_dyn_info_t**)realloc(g_dyn_entries, 
sizeof(unw_dyn_info_t*) * g_dyn_entry_count_max);
-memset(g_dyn_entries + g_dyn_entry_count, 0,
-   sizeof(unw_dyn_info_t*)*(g_dyn_entry_count_max - 
g_dyn_entry_count));
-}
-}
-
-static unw_dyn_info_t * _vmp_alloc_dyn_info(int * reference)
-{
-unw_dyn_info_t * u;
-
-u = (unw_dyn_info_t*)malloc(sizeof(unw_dyn_info_t));
-
-int i = 0;
-int ref = -1;
-if (g_has_holes >= 0) {
-i = g_has_holes;
-while (i < g_dyn_entry_count) {
-if (g_dyn_entries[i] == NULL) {
-ref = i;
-g_has_holes += 1;
-}
-}
-if (i == g_dyn_entry_count) {
-_vmp_dyn_resize();
-ref = g_dyn_entry_count;
-g_dyn_entry_count++;
-}
-} else {
-_vmp_dyn_resize();
-ref = g_dyn_entry_count;
-g_dyn_entry_count++;
-}
-assert(ref != -1 && "ref position MUST be found");
-g_dyn_entries[ref] = u;
-*reference = ref;
-
-return u;
-}
-
-static void _vmp_free_dyn_info(unw_dyn_info_t * u)
-{
-free(u);
-}
-
-RPY_EXTERN
-int vmp_dyn_register_jit_page(intptr_t addr, intptr_t end_addr,
-  const char * name)
-{
-char * name_cpy = NULL;
-int ref = -1;
-unw_dyn_info_t * u = _vmp_alloc_dyn_info(&ref);
-if (ref == -1) {
-return -1; // fail, could not alloc
-}
-u->start_ip = (unw_word_t)addr;
-u->end_ip = (unw_word_t)end_addr;
-u->format = UNW_INFO_FORMAT_DYNAMIC;
-if (name != NULL) {
-name_cpy = strdup(name);
-}
-unw_dyn_proc_info_t * ip = (unw_dyn_proc_info_t*)&(u->u);
-ip->name_ptr = (unw_word_t)name_cpy;
-ip->handler = 0;
-// the docs say, we cannot use this field. but looking at libunwind, it 
just copies
-// the value over when unw_get_proc_info is called. This should be fine to 
identify
-ip->flags = DYN_JIT_FLAG;
-ip->regions = NULL;
-
-_U_dyn_register(u);
-
-return ref;
-}
-
-RPY_EXTERN
-int vmp_dyn_cancel(int ref) {
-unw_dyn_info_t * u;
-
-if (ref >= g_dyn_entry_count || ref < 0) {
-return 1;
-}
-
-u = g_dyn_entries[ref];
-if (u != NULL) {
-g_dyn_entries[ref] = NULL;
-if (g_has_holes > ref) {
-   

[pypy-commit] pypy py3.5: fix test

2017-03-15 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r90709:9709a3b66222
Date: 2017-03-15 16:47 +
http://bitbucket.org/pypy/pypy/changeset/9709a3b66222/

Log:fix test

diff --git a/pypy/module/cpyext/test/test_tupleobject.py 
b/pypy/module/cpyext/test/test_tupleobject.py
--- a/pypy/module/cpyext/test/test_tupleobject.py
+++ b/pypy/module/cpyext/test/test_tupleobject.py
@@ -158,6 +158,6 @@
 assert module.is_TupleLike(a) == 1
 assert isinstance(a, tuple)
 assert issubclass(type(a), tuple)
-assert list(a) == range(100, 400, 100)
-assert list(a) == range(100, 400, 100)
-assert list(a) == range(100, 400, 100)
+assert list(a) == list(range(100, 400, 100))
+assert list(a) == list(range(100, 400, 100))
+assert list(a) == list(range(100, 400, 100))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: fix test

2017-03-15 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r90710:7cd246019641
Date: 2017-03-15 16:56 +
http://bitbucket.org/pypy/pypy/changeset/7cd246019641/

Log:fix test

diff --git a/pypy/module/cpyext/test/test_object.py 
b/pypy/module/cpyext/test/test_object.py
--- a/pypy/module/cpyext/test/test_object.py
+++ b/pypy/module/cpyext/test/test_object.py
@@ -345,7 +345,7 @@
 module = self.import_extension('foo', [
 ("foo", "METH_O",
 """
-_PyTraceMalloc_Track(0, 0, PyInt_AsLong(args) - sizeof(long));
+_PyTraceMalloc_Track(0, 0, PyLong_AsLong(args) - sizeof(long));
 Py_INCREF(Py_None);
 return Py_None;
 """)])
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Un-export a few meaningless symbols from libpypy-c.so

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90711:b9f4dc1c4cd1
Date: 2017-03-15 17:59 +0100
http://bitbucket.org/pypy/pypy/changeset/b9f4dc1c4cd1/

Log:Un-export a few meaningless symbols from libpypy-c.so

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/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 
 
-volatile int spinlock;
-jmp_buf restore_point;
+static volatile int spinlock;
+static jmp_buf restore_point;
 
 static void segfault_handler(int arg)
 {
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: document that we're expecting a positive value here

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90712:2adedf0af060
Date: 2017-03-15 19:44 +0100
http://bitbucket.org/pypy/pypy/changeset/2adedf0af060/

Log:document that we're expecting a positive value here

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'] = '40'
 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
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: highlight asmgcc and update doc

2017-03-15 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r90713:031f96ce5f5a
Date: 2017-03-15 20:48 +0200
http://bitbucket.org/pypy/pypy/changeset/031f96ce5f5a/

Log:highlight asmgcc and update doc

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,10 @@
 CFFI_ has been updated to 1.10, improving an already great package for
 interfacing with C.
 
+We now use shadowstack as our default gcrootfinder_, asmgcc will be deprecated
+at some future point. While about 3% slower, shadowstack is much more
+easily maintained and debuggable.
+
 As always, this release fixed many issues and bugs raised by the
 growing community of PyPy users. We strongly recommend updating.
 
@@ -47,6 +51,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?
 =
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: a few more details

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90714:4b6b0c95ec49
Date: 2017-03-15 19:57 +0100
http://bitbucket.org/pypy/pypy/changeset/4b6b0c95ec49/

Log:a few more details

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,9 +24,11 @@
 CFFI_ has been updated to 1.10, improving an already great package for
 interfacing with C.
 
-We now use shadowstack as our default gcrootfinder_, asmgcc will be deprecated
-at some future point. While about 3% slower, shadowstack is much more
-easily maintained and debuggable.
+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.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: fix translation (arigato around)

2017-03-15 Thread mattip
Author: Matti Picus 
Branch: py3.5
Changeset: r90716:e08e9c6ffbd8
Date: 2017-03-15 22:16 +0200
http://bitbucket.org/pypy/pypy/changeset/e08e9c6ffbd8/

Log:fix translation (arigato around)

diff --git a/pypy/module/cpyext/modsupport.py b/pypy/module/cpyext/modsupport.py
--- a/pypy/module/cpyext/modsupport.py
+++ b/pypy/module/cpyext/modsupport.py
@@ -23,9 +23,9 @@
 Most uses of this function should be using PyModule_Create()
 instead; only use this if you are sure you need it."""
 
-modname = rffi.charp2str(module.c_m_name)
+modname = rffi.charp2str(rffi.cast(rffi.CCHARP, module.c_m_name))
 if module.c_m_doc:
-doc = rffi.charp2str(module.c_m_doc)
+doc = rffi.charp2str(rffi.cast(rffi.CCHARP, module.c_m_doc))
 else:
 doc = None
 methods = module.c_m_methods
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Merged in realitix/cffi/binary_enum (pull request #78)

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2913:663852865a03
Date: 2017-03-15 20:22 +
http://bitbucket.org/cffi/cffi/changeset/663852865a03/

Log:Merged in realitix/cffi/binary_enum (pull request #78)

Add operation support in enum

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/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/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -386,13 +386,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()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi binary_enum: Add test for binary operation in enum definition

2017-03-15 Thread realitix
Author: Jean-Sebastien Bevilacqua 
Branch: binary_enum
Changeset: r2912:330013c6d0c3
Date: 2017-03-15 21:10 +0100
http://bitbucket.org/cffi/cffi/changeset/330013c6d0c3/

Log:Add test for binary operation in enum definition

diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -386,13 +386,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()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi binary_enum: Add operation support in enum

2017-03-15 Thread realitix
Author: Jean-Sebastien Bevilacqua 
Branch: binary_enum
Changeset: r2911:5e9d6a26b6b1
Date: 2017-03-15 16:48 +0100
http://bitbucket.org/cffi/cffi/changeset/5e9d6a26b6b1/

Log:Add operation support in enum

With this patch, the following C code works now:

```c typedef enum VkPipelineCacheHeaderVersion {
VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1,
VK_PIPELINE_CACHE_HEADER_VERSION_RANGE_SIZE =
(VK_PIPELINE_CACHE_HEADER_VERSION_ONE -
VK_PIPELINE_CACHE_HEADER_VERSION_ONE + 1), }
VkPipelineCacheHeaderVersion; ```

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/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)
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: import cffi/663852865a03

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r90717:ccf33d2353fa
Date: 2017-03-15 21:24 +0100
http://bitbucket.org/pypy/pypy/changeset/ccf33d2353fa/

Log:import cffi/663852865a03

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/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()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi release-1.10: hg merge default

2017-03-15 Thread arigo
Author: Armin Rigo 
Branch: release-1.10
Changeset: r2914:00667b1b0ab3
Date: 2017-03-15 21:25 +0100
http://bitbucket.org/cffi/cffi/changeset/00667b1b0ab3/

Log:hg merge default

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/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/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py
--- a/testing/cffi0/test_parsing.py
+++ b/testing/cffi0/test_parsing.py
@@ -386,13 +386,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()
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Silence glibc warning.

2017-03-15 Thread mjacob
Author: Manuel Jacob 
Branch: 
Changeset: r90718:853bb72fa73c
Date: 2017-03-15 22:51 +0100
http://bitbucket.org/pypy/pypy/changeset/853bb72fa73c/

Log:Silence glibc warning.

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']
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Fix test_importlib.util.EXTENSIONS for lazily built _testcapi on PyPy.

2017-03-15 Thread mjacob
Author: Manuel Jacob 
Branch: py3.5
Changeset: r90719:cba0df095b3f
Date: 2017-03-16 00:04 +0100
http://bitbucket.org/pypy/pypy/changeset/cba0df095b3f/

Log:Fix test_importlib.util.EXTENSIONS for lazily built _testcapi on
PyPy.

diff --git a/lib-python/3/test/test_importlib/util.py 
b/lib-python/3/test/test_importlib/util.py
--- a/lib-python/3/test/test_importlib/util.py
+++ b/lib-python/3/test/test_importlib/util.py
@@ -30,7 +30,12 @@
 
 def _extension_details():
 global EXTENSIONS
-for path in sys.path:
+# we need this hack on PyPy because _testcapi is built lazily
+import _testcapi
+import _pypy_testcapi
+lib_pypy_dir = os.path.dirname(_pypy_testcapi.__file__)
+c_file = os.path.join(lib_pypy_dir, '_testcapimodule.c')
+for path in [_pypy_testcapi.get_hashed_dir(c_file)]:
 for ext in machinery.EXTENSION_SUFFIXES:
 filename = EXTENSIONS.name + ext
 file_path = os.path.join(path, filename)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit