]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35550: Fix incorrect Solaris define guards (GH-11275)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 31 Dec 2018 02:39:00 +0000 (18:39 -0800)
committerGitHub <noreply@github.com>
Mon, 31 Dec 2018 02:39:00 +0000 (18:39 -0800)
Python source code uses on several places ifdef sun or defined(sun) without the underscores, which is not standard compliant and shouldn't be used.

Defines should check for __sun instead. Reference: http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_systemGH-Solaris

https://bugs.python.org/issue35550
(cherry picked from commit 6f9bc72c79c3262e5d0f2c0e96b016477399cfb1)

Co-authored-by: Jakub KulĂ­k <Kulikjak@gmail.com>
Misc/NEWS.d/next/Build/2018-12-29-10-19-43.bpo-35550.BTuu8e.rst [new file with mode: 0644]
Modules/_posixsubprocess.c
Modules/posixmodule.c
Modules/socketmodule.c
Modules/timemodule.c
Python/bootstrap_hash.c

diff --git a/Misc/NEWS.d/next/Build/2018-12-29-10-19-43.bpo-35550.BTuu8e.rst b/Misc/NEWS.d/next/Build/2018-12-29-10-19-43.bpo-35550.BTuu8e.rst
new file mode 100644 (file)
index 0000000..8a6b90d
--- /dev/null
@@ -0,0 +1 @@
+Fix incorrect Solaris #ifdef checks to look for __sun && __SVR4 instead of sun when compiling.
\ No newline at end of file
index 851aa9777168084d98c9f9f61f79214d110a5ceb..3cf0683ad98bba4022331da9e837d6082d7325ce 100644 (file)
@@ -30,7 +30,7 @@
 # define SYS_getdents64  __NR_getdents64
 #endif
 
-#if defined(sun)
+#if defined(__sun) && defined(__SVR4)
 /* readdir64 is used to work around Solaris 9 bug 6395699. */
 # define readdir readdir64
 # define dirent dirent64
index 383999ea8492e883b5fa2ed80ef4aadd2695c121..909b06e5a9dd28be5c8ee4372271682c828841b0 100644 (file)
@@ -5926,7 +5926,7 @@ os_openpty_impl(PyObject *module)
 #endif
 #if defined(HAVE_DEV_PTMX) && !defined(HAVE_OPENPTY) && !defined(HAVE__GETPTY)
     PyOS_sighandler_t sig_saved;
-#ifdef sun
+#if defined(__sun) && defined(__SVR4)
     extern char *ptsname(int fildes);
 #endif
 #endif
index 661e1bdf578401432b8c7f3e4fa650fc9a44354a..988471e15fbe3025ce12867fd239766b85f4a0fb 100644 (file)
@@ -265,7 +265,7 @@ http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82&
 #endif
 
 /* Solaris fails to define this variable at all. */
-#if defined(sun) && !defined(INET_ADDRSTRLEN)
+#if (defined(__sun) && defined(__SVR4)) && !defined(INET_ADDRSTRLEN)
 #define INET_ADDRSTRLEN 16
 #endif
 
index 5e99bd82d1de1a19590c7b88accd27588d09005d..bbfb7db7abde93e3ce6fb10cd2409edb898c3395 100644 (file)
@@ -725,7 +725,7 @@ time_strftime(PyObject *self, PyObject *args)
         return NULL;
     }
 
-#if defined(_MSC_VER) || defined(sun) || defined(_AIX)
+#if defined(_MSC_VER) || (defined(__sun) && defined(__SVR4)) || defined(_AIX)
     if (buf.tm_year + 1900 < 1 || 9999 < buf.tm_year + 1900) {
         PyErr_SetString(PyExc_ValueError,
                         "strftime() requires year in [1; 9999]");
@@ -771,7 +771,7 @@ time_strftime(PyObject *self, PyObject *args)
             return NULL;
         }
     }
-#elif (defined(_AIX) || defined(sun)) && defined(HAVE_WCSFTIME)
+#elif (defined(_AIX) || (defined(__sun) && defined(__SVR4))) && defined(HAVE_WCSFTIME)
     for (outbuf = wcschr(fmt, '%');
         outbuf != NULL;
         outbuf = wcschr(outbuf+2, '%'))
index e2afba2b2e33a82776160902bdeb976288234b15..58b0802f4668878269245742fef02a29bece3fb5 100644 (file)
@@ -116,7 +116,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
     flags = blocking ? 0 : GRND_NONBLOCK;
     dest = buffer;
     while (0 < size) {
-#ifdef sun
+#if defined(__sun) && defined(__SVR4)
         /* Issue #26735: On Solaris, getrandom() is limited to returning up
            to 1024 bytes. Call it multiple times if more bytes are
            requested. */
@@ -266,7 +266,7 @@ py_getentropy(char *buffer, Py_ssize_t size, int raise)
     }
     return 1;
 }
-#endif /* defined(HAVE_GETENTROPY) && !defined(sun) */
+#endif /* defined(HAVE_GETENTROPY) && !(defined(__sun) && defined(__SVR4)) */
 
 
 static struct {