Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r87791:f896d075d6bb Date: 2016-10-14 16:07 +0200 http://bitbucket.org/pypy/pypy/changeset/f896d075d6bb/
Log: hg merge default diff --git a/lib_pypy/_tkinter/tclobj.py b/lib_pypy/_tkinter/tclobj.py --- a/lib_pypy/_tkinter/tclobj.py +++ b/lib_pypy/_tkinter/tclobj.py @@ -160,7 +160,7 @@ encoded = value.encode('utf-16')[2:] buf = tkffi.new("char[]", encoded) inbuf = tkffi.cast("Tcl_UniChar*", buf) - return tklib.Tcl_NewUnicodeObj(buf, len(encoded)//2) + return tklib.Tcl_NewUnicodeObj(inbuf, len(encoded)/2) if isinstance(value, Tcl_Obj): tklib.Tcl_IncrRefCount(value._value) return value._value diff --git a/lib_pypy/_tkinter/tklib_build.py b/lib_pypy/_tkinter/tklib_build.py --- a/lib_pypy/_tkinter/tklib_build.py +++ b/lib_pypy/_tkinter/tklib_build.py @@ -107,7 +107,7 @@ int Tcl_Init(Tcl_Interp* interp); int Tk_Init(Tcl_Interp* interp); -void Tcl_Free(char* ptr); +void Tcl_Free(void* ptr); const char *Tcl_SetVar(Tcl_Interp* interp, const char* varName, const char* newValue, int flags); const char *Tcl_SetVar2(Tcl_Interp* interp, const char* name1, const char* name2, const char* newValue, int flags); diff --git a/pypy/module/_cffi_backend/ctypeptr.py b/pypy/module/_cffi_backend/ctypeptr.py --- a/pypy/module/_cffi_backend/ctypeptr.py +++ b/pypy/module/_cffi_backend/ctypeptr.py @@ -167,7 +167,7 @@ "will be forbidden in the future (check that the types " "are as you expect; use an explicit ffi.cast() if they " "are correct)" % (other.name, self.name)) - space.warn(space.wrap(msg), space.w_UserWarning, stacklevel=1) + space.warn(space.wrap(msg), space.w_UserWarning) else: raise self._convert_error("compatible pointer", w_ob) diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py --- a/pypy/module/_cffi_backend/test/_backend_test_c.py +++ b/pypy/module/_cffi_backend/test/_backend_test_c.py @@ -3689,3 +3689,5 @@ assert len(w) == 2 newp(new_pointer_type(BIntP), z3) # fine assert len(w) == 2 + # check that the warnings are associated with lines in this file + assert w[1].lineno == w[0].lineno + 4 diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py --- a/rpython/rlib/rposix.py +++ b/rpython/rlib/rposix.py @@ -2305,3 +2305,47 @@ self.cached_nosys = -1 _pipe2_syscall = ENoSysCache() + +# cpu count for linux, windows and mac (+ bsds) +# note that the code is copied from cpython and split up here +if sys.platform.startswith('linux'): + cpucount_eci = ExternalCompilationInfo(includes=["unistd.h"], + separate_module_sources=[""" + RPY_EXTERN int _cpu_count(void) { + return sysconf(_SC_NPROCESSORS_ONLN); + } + """]) +elif sys.platform == "win32": + cpucount_eci = ExternalCompilationInfo(includes=["Windows.h"], + separate_module_sources=[""" + RPY_EXTERN int _cpu_count(void) { + int ncpu = 0; + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; + } + """]) +else: + cpucount_eci = ExternalCompilationInfo(includes=["sys/types.h", "sys/sysctl.h"], + separate_module_sources=[""" + RPY_EXTERN int _cpu_count(void) { + int ncpu = 0; + #if defined(__DragonFly__) || \ + defined(__OpenBSD__) || \ + defined(__FreeBSD__) || \ + defined(__NetBSD__) || \ + defined(__APPLE__) + int mib[2]; + size_t len = sizeof(ncpu); + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + if (sysctl(mib, 2, &ncpu, &len, NULL, 0) != 0) + ncpu = 0; + #endif + return ncpu; + } + """]) + +cpu_count = rffi.llexternal('_cpu_count', [], rffi.INT_real, + compilation_info=cpucount_eci) + diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py --- a/rpython/rlib/test/test_rposix.py +++ b/rpython/rlib/test/test_rposix.py @@ -608,3 +608,7 @@ def test_sync(): if sys.platform != 'win32': rposix.sync() + +def test_cpu_count(): + cc = rposix.cpu_count() + assert cc >= 1 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit