components/python/python27/patches/01-ext-stdio.patch
author Rich Burridge <rich.burridge@oracle.com>
Tue, 02 May 2017 17:33:26 -0700
changeset 7964 d9801318ed3d
parent 6445 0edecb568b2e
permissions -rw-r--r--
25981468 Build ilmbase and openexr with the GNU compilers
This patch provides extended file stdio support.
As it is Solaris-specific, it is not suitable for upstream.

--- Python-2.7.12/Modules/python.c.~1~	2016-06-25 14:49:31.000000000 -0700
+++ Python-2.7.12/Modules/python.c	2016-07-07 13:39:38.170867069 -0700
@@ -6,6 +6,13 @@
 #include <fenv.h>
 #endif
 
+#if defined(sun) && defined(__SVR4) && !defined(_LP64)
+#define USE_EXTENDED_FILE_STDIO 1
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <signal.h>
+#endif
+
 int
 main(int argc, char **argv)
 {
@@ -17,5 +24,18 @@
 #ifdef __FreeBSD__
 	fedisableexcept(FE_OVERFLOW);
 #endif
+#ifdef USE_EXTENDED_FILE_STDIO
+	/*
+	 * enable extended FILE facility on Solaris so that Python
+	 * apps can keep more than 256 file descriptors open
+	 */
+	struct rlimit rlp;
+	(void) getrlimit(RLIMIT_NOFILE, &rlp);
+	rlp.rlim_cur = rlp.rlim_max;
+	if (setrlimit(RLIMIT_NOFILE, &rlp) != -1) {
+		enable_extended_FILE_stdio(-1, 0);
+	}
+#endif
+
 	return Py_Main(argc, argv);
 }