]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-78469: Declare missing sethostname for Solaris 10 (#109447)
authorJakub Kulík <Kulikjak@gmail.com>
Mon, 9 Oct 2023 21:18:05 +0000 (23:18 +0200)
committerGitHub <noreply@github.com>
Mon, 9 Oct 2023 21:18:05 +0000 (21:18 +0000)
Add OS version specific macro for Solaris: Py_SUNOS_VERSION.

Modules/socketmodule.c
configure
configure.ac
pyconfig.h.in

index 90592ffc152fc19f5c83d5c44bb1425b1737a079..3d099d41d1e7617a3a02a02c789f9af65533a816 100644 (file)
@@ -5652,8 +5652,9 @@ socket_sethostname(PyObject *self, PyObject *args)
     Py_buffer buf;
     int res, flag = 0;
 
-#ifdef _AIX
-/* issue #18259, not declared in any useful header file */
+#if defined(_AIX) || (defined(__sun) && defined(__SVR4) && Py_SUNOS_VERSION <= 510)
+/* issue #18259, sethostname is not declared in any useful header file on AIX
+ * the same is true for Solaris 10 */
 extern int sethostname(const char *, size_t);
 #endif
 
index 1799323e53b79fec6bda47d818a85436ce2d1ffa..d68c4e8e9b0756492774e552dfd4ae8f5d173707 100755 (executable)
--- a/configure
+++ b/configure
@@ -4284,6 +4284,15 @@ then
        darwin*) MACHDEP="darwin";;
        '')     MACHDEP="unknown";;
     esac
+
+    if test "$ac_sys_system" = "SunOS"; then
+       # For Solaris, there isn't an OS version specific macro defined
+       # in most compilers, so we define one here.
+       SUNOS_VERSION=`echo $ac_sys_release | sed -e 's!\.\(0-9\)$!.0\1!g' | tr -d '.'`
+
+printf "%s\n" "#define Py_SUNOS_VERSION $SUNOS_VERSION" >>confdefs.h
+
+    fi
 fi
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: \"$MACHDEP\"" >&5
 printf "%s\n" "\"$MACHDEP\"" >&6; }
index cafc6df75e65001db3589dcb9fbe237f1edab51c..9a9c76f3545c30a3261f1212aeac691bd6d94f08 100644 (file)
@@ -590,6 +590,14 @@ then
        darwin*) MACHDEP="darwin";;
        '')     MACHDEP="unknown";;
     esac
+
+    if test "$ac_sys_system" = "SunOS"; then
+       # For Solaris, there isn't an OS version specific macro defined
+       # in most compilers, so we define one here.
+       SUNOS_VERSION=`echo $ac_sys_release | sed -e 's!\.\([0-9]\)$!.0\1!g' | tr -d '.'`
+       AC_DEFINE_UNQUOTED([Py_SUNOS_VERSION], [$SUNOS_VERSION],
+                          [The version of SunOS/Solaris as reported by `uname -r' without the dot.])
+    fi
 fi
 AC_MSG_RESULT(["$MACHDEP"])
 
index f07e677250a1573afbc5f65e7fdfb23b44b07781..4b8fc4a677c7768d002abb1ea9f59f8bb8e44f6a 100644 (file)
 /* Define if you want to enable internal statistics gathering. */
 #undef Py_STATS
 
+/* The version of SunOS/Solaris as reported by `uname -r' without the dot. */
+#undef Py_SUNOS_VERSION
+
 /* Define if you want to enable tracing references for debugging purpose */
 #undef Py_TRACE_REFS