components/python/python34/patches/02-ext-stdio.patch
author John Beck <John.Beck@Oracle.COM>
Mon, 19 May 2014 07:37:20 -0700
changeset 1907 446472de62e9
permissions -rw-r--r--
PSARC 2014/151 Python 3.4 15819724 SUNBT7202228 python 3.4 18756157 upgrade setuptools to 0.9.6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1907
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     1
This patch provides extended file stdio support.
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     2
As it is Solaris-specific, it is not suitable for upstream.
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     3
Note that this patch is no longer needed, since is we build Python 3 64-bit
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     4
only, but we are keeping it around as a precaution in case we need to add
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     5
32-bit support back in at some point.  If a time comes when we are certain
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     6
we will never need 32-bit support, then the patch can be removed.
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     7
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     8
--- Python-3.4.0/Modules/python.c.~1~	2014-03-16 19:31:31.000000000 -0700
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     9
+++ Python-3.4.0/Modules/python.c	2014-03-17 11:08:20.154195402 -0700
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    10
@@ -15,6 +15,13 @@
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    11
 }
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    12
 #else
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    13
 
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    14
+#if defined(sun) && defined(__SVR4) && !defined(_LP64)
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    15
+#define USE_EXTENDED_FILE_STDIO 1
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    16
+#include <stdio.h>
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    17
+#include <stdio_ext.h>
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    18
+#include <signal.h>
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    19
+#endif
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    20
+
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    21
 int
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    22
 main(int argc, char **argv)
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    23
 {
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    24
@@ -44,6 +51,19 @@
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    25
     fpsetmask(m & ~FP_X_OFL);
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    26
 #endif
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    27
 
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    28
+#ifdef USE_EXTENDED_FILE_STDIO
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    29
+    /*
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    30
+     * enable extended FILE facility on Solaris so that Python
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    31
+     * apps can keep more than 256 file descriptors open
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    32
+     */
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    33
+    struct rlimit rlp;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    34
+    (void) getrlimit(RLIMIT_NOFILE, &rlp);
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    35
+    rlp.rlim_cur = rlp.rlim_max;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    36
+    if (setrlimit(RLIMIT_NOFILE, &rlp) != -1) {
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    37
+            enable_extended_FILE_stdio(-1, 0);
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    38
+    }
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    39
+#endif
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    40
+
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    41
     oldloc = _PyMem_RawStrdup(setlocale(LC_ALL, NULL));
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    42
     if (!oldloc) {
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    43
         fprintf(stderr, "out of memory\n");