Fix python crash on resource.getrusage

This commit is contained in:
Timothy Gu
2015-01-11 18:20:24 -08:00
parent 1fb737ad9f
commit b33f96fa88
2 changed files with 68 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
From f7d6b2b6f44a8f9337c9103d298222747d547ebf Mon Sep 17 00:00:00 2001
From ca78f3e4c26f1d94def56bd1a5fec519d2b0579c Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Wed, 12 Mar 2014 21:17:06 +0000
Subject: initial Haiku patch
@@ -79,7 +79,7 @@ index b9f1c6c..7be61d3 100644
# finalize_unix ()
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 4aa9334..d06e5e8 100644
index de7da1d..8180c8e 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -90,7 +90,8 @@ def get_python_inc(plat_specific=0, prefix=None):
@@ -497,10 +497,10 @@ index 53a6c3e..6c5f52f 100644
if (PyErr_Occurred()) {
Py_DECREF(result);
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 880f311..54b66f7 100644
index e9e4479..84b6305 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4868,7 +4868,9 @@ init_socket(void)
@@ -4869,7 +4869,9 @@ init_socket(void)
#ifndef __BEOS__
/* We have incomplete socket support. */
PyModule_AddIntConstant(m, "SOCK_RAW", SOCK_RAW);
@@ -511,7 +511,7 @@ index 880f311..54b66f7 100644
PyModule_AddIntConstant(m, "SOCK_RDM", SOCK_RDM);
#endif
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
index 8515499..4e33e4f 100644
index d98e00e..2bfb3dc 100644
--- a/Modules/socketmodule.h
+++ b/Modules/socketmodule.h
@@ -47,6 +47,10 @@ typedef int socklen_t;
@@ -584,10 +584,10 @@ index c64501e..7df3ad7 100755
elif sys.platform.startswith("atheos"):
searchdirs=os.environ['C_INCLUDE_PATH'].split(':')
diff --git a/configure.ac b/configure.ac
index 54f8c0f..1ea438a 100644
index 94a215e..41fbd47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -883,7 +883,7 @@ if test $enable_shared = "yes"; then
@@ -886,7 +886,7 @@ if test $enable_shared = "yes"; then
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
INSTSONAME="$LDLIBRARY".$SOVERSION
;;
@@ -596,7 +596,7 @@ index 54f8c0f..1ea438a 100644
LDLIBRARY='libpython$(VERSION).so'
BLDLIBRARY='-L. -lpython$(VERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
@@ -891,6 +891,9 @@ if test $enable_shared = "yes"; then
@@ -894,6 +894,9 @@ if test $enable_shared = "yes"; then
FreeBSD*)
SOVERSION=`echo $SOVERSION|cut -d "." -f 1`
;;
@@ -606,7 +606,7 @@ index 54f8c0f..1ea438a 100644
esac
INSTSONAME="$LDLIBRARY".$SOVERSION
;;
@@ -1006,7 +1009,7 @@ AC_PROG_MKDIR_P
@@ -1009,7 +1012,7 @@ AC_PROG_MKDIR_P
AC_SUBST(LN)
if test -z "$LN" ; then
case $ac_sys_system in
@@ -615,7 +615,7 @@ index 54f8c0f..1ea438a 100644
CYGWIN*) LN="ln -s";;
atheos*) LN="ln -s";;
*) LN=ln;;
@@ -2030,7 +2033,7 @@ then
@@ -2033,7 +2036,7 @@ then
BLDSHARED="$LDSHARED"
fi
;;
@@ -624,7 +624,7 @@ index 54f8c0f..1ea438a 100644
LDSHARED='$(CC) -shared'
LDCXXSHARED='$(CXX) -shared';;
BSD/OS*/4*)
@@ -2102,7 +2105,7 @@ then
@@ -2105,7 +2108,7 @@ then
then CCSHARED="-fPIC";
else CCSHARED="+z";
fi;;
@@ -633,7 +633,7 @@ index 54f8c0f..1ea438a 100644
BSD/OS*/4*) CCSHARED="-fpic";;
FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";;
OpenUNIX*|UnixWare*)
@@ -2134,7 +2137,7 @@ then
@@ -2137,7 +2140,7 @@ then
LINKFORSHARED="-Wl,-E -Wl,+s";;
# LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";;
BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";;
@@ -642,7 +642,7 @@ index 54f8c0f..1ea438a 100644
# -u libsys_s pulls in all symbols in libsys
Darwin/*)
# -u _PyMac_Error is needed to pull in the mac toolbox glue,
@@ -2249,14 +2252,16 @@ case "$ac_sys_system" in
@@ -2252,14 +2255,16 @@ case "$ac_sys_system" in
esac
# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
@@ -663,7 +663,7 @@ index 54f8c0f..1ea438a 100644
esac
AC_MSG_CHECKING(for --with-libs)
@@ -3592,7 +3597,7 @@ fi],
@@ -3595,7 +3600,7 @@ fi],
AC_SUBST(LIBM)
case $ac_sys_system in
Darwin) ;;
@@ -673,10 +673,10 @@ index 54f8c0f..1ea438a 100644
esac
AC_MSG_CHECKING(for --with-libm=STRING)
diff --git a/setup.py b/setup.py
index a46bf35..9fe247f 100644
index 7868b7b..bc4a1a4 100644
--- a/setup.py
+++ b/setup.py
@@ -523,6 +523,12 @@ class PyBuildExt(build_ext):
@@ -525,6 +525,12 @@ class PyBuildExt(build_ext):
lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
inc_dirs += ['/system/include', '/atheos/autolnk/include']
inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
@@ -689,7 +689,7 @@ index a46bf35..9fe247f 100644
# OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
if host_platform in ['osf1', 'unixware7', 'openunix8']:
@@ -551,7 +557,7 @@ class PyBuildExt(build_ext):
@@ -553,7 +559,7 @@ class PyBuildExt(build_ext):
# Check for MacOS X, which doesn't need libm.a at all
math_libs = ['m']
@@ -698,7 +698,7 @@ index a46bf35..9fe247f 100644
math_libs = []
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
@@ -790,15 +796,22 @@ class PyBuildExt(build_ext):
@@ -792,15 +798,22 @@ class PyBuildExt(build_ext):
'/usr/local/ssl/include',
'/usr/contrib/ssl/include/'
]
@@ -724,7 +724,7 @@ index a46bf35..9fe247f 100644
['/usr/local/ssl/lib',
'/usr/contrib/ssl/lib/'
] )
@@ -806,8 +819,8 @@ class PyBuildExt(build_ext):
@@ -808,8 +821,8 @@ class PyBuildExt(build_ext):
if (ssl_incs is not None and
ssl_libs is not None):
exts.append( Extension('_ssl', ['_ssl.c'],
@@ -735,7 +735,7 @@ index a46bf35..9fe247f 100644
libraries = ['ssl', 'crypto'],
depends = ['socketmodule.h']), )
else:
@@ -845,8 +858,8 @@ class PyBuildExt(build_ext):
@@ -847,8 +860,8 @@ class PyBuildExt(build_ext):
# The _hashlib module wraps optimized implementations
# of hash functions from the OpenSSL library.
exts.append( Extension('_hashlib', ['_hashopenssl.c'],
@@ -746,7 +746,7 @@ index a46bf35..9fe247f 100644
libraries = ['ssl', 'crypto']) )
else:
print ("warning: openssl 0x%08x is too old for _hashlib" %
@@ -1325,7 +1338,7 @@ class PyBuildExt(build_ext):
@@ -1327,7 +1340,7 @@ class PyBuildExt(build_ext):
missing.append('resource')
# Sun yellow pages. Some systems have the functions in libc.
@@ -759,14 +759,14 @@ index a46bf35..9fe247f 100644
1.8.3.4
From 571ed69e1ab40fd11c4a1fdcb6198ff787c5129b Mon Sep 17 00:00:00 2001
From af64f0fbd90f24886cac80f79f3db0da46ede0e5 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 5 Apr 2014 21:16:40 +0000
Subject: fix pyconfig.h path
diff --git a/Makefile.pre.in b/Makefile.pre.in
index bcd83bf..f93c10a 100644
index 7f4ec2f..25a93e5 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -105,7 +105,7 @@ BINDIR= @bindir@
@@ -782,7 +782,7 @@ index bcd83bf..f93c10a 100644
1.8.3.4
From d49a8ee2494391b3a1c50bc652f0838ac036e046 Mon Sep 17 00:00:00 2001
From fa99392d5c5df974b86ff319148514644731d192 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Wed, 18 Jun 2014 12:19:13 +0000
Subject: Import missed change from the 2.6.9 patches
@@ -814,17 +814,17 @@ index d2e18f1..34d5aee 100644
1.8.3.4
From a0b72ccfc2f385c3ec9148523d981c7d971e2636 Mon Sep 17 00:00:00 2001
From c2e1dc174241f7beedf43ee5bef3c76e0600e069 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 21 Sep 2014 18:59:44 +0200
Subject: gcc2 fix.
diff --git a/Modules/_ctypes/libffi/include/ffi_common.h b/Modules/_ctypes/libffi/include/ffi_common.h
index 650ca69..02a1913 100644
index 37f5a9e..37b0b25 100644
--- a/Modules/_ctypes/libffi/include/ffi_common.h
+++ b/Modules/_ctypes/libffi/include/ffi_common.h
@@ -115,7 +115,7 @@ typedef signed int SINT64 __attribute__((__mode__(__DI__)));
@@ -119,7 +119,7 @@ typedef signed int SINT64 __attribute__((__mode__(__DI__)));
typedef float FLOAT32;
@@ -837,17 +837,17 @@ index 650ca69..02a1913 100644
1.8.3.4
From d50a28e47cbd54263d065f47b2650333d917c2b9 Mon Sep 17 00:00:00 2001
From a0bdbb8e92894e1de5a453ca08659d68e75b67d1 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 28 Nov 2014 16:26:28 +0000
Subject: tarfile: let link fail and catch exception.
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 57ea877..bc3f82c 100644
index b0d1292..b5952ae 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2242,7 +2242,7 @@ class TarFile(object):
@@ -2261,7 +2261,7 @@ class TarFile(object):
(platform limitation), we try to make a copy of the referenced file
instead of a link.
"""
@@ -856,7 +856,7 @@ index 57ea877..bc3f82c 100644
# For systems that support symbolic and hard links.
if tarinfo.issym():
if os.path.lexists(targetpath):
@@ -2256,7 +2256,7 @@ class TarFile(object):
@@ -2275,7 +2275,7 @@ class TarFile(object):
os.link(tarinfo._link_target, targetpath)
else:
self._extract_member(self._find_link_target(tarinfo), targetpath)
@@ -868,3 +868,39 @@ index 57ea877..bc3f82c 100644
--
1.8.3.4
From 77217bde28ee863a42421f87692d986a8f784896 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Sun, 11 Jan 2015 18:18:22 -0800
Subject: Fix resource module after the initial haiku patch
diff --git a/Modules/resource.c b/Modules/resource.c
index 6c5f52f..73758bb 100644
--- a/Modules/resource.c
+++ b/Modules/resource.c
@@ -101,6 +101,21 @@ resource_getrusage(PyObject *self, PyObject *args)
PyStructSequence_SET_ITEM(result, 13, PyInt_FromLong(ru.ru_nsignals));
PyStructSequence_SET_ITEM(result, 14, PyInt_FromLong(ru.ru_nvcsw));
PyStructSequence_SET_ITEM(result, 15, PyInt_FromLong(ru.ru_nivcsw));
+#else
+ PyStructSequence_SET_ITEM(result, 2, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 3, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 4, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 5, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 6, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 7, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 8, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 9, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 10, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 11, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 12, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 13, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 14, PyInt_FromLong(0));
+ PyStructSequence_SET_ITEM(result, 15, PyInt_FromLong(0));
#endif
if (PyErr_Occurred()) {
--
1.8.3.4