summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub KulĂ­k <Kulikjak@gmail.com>2023-10-09 21:18:05 (GMT)
committerGitHub <noreply@github.com>2023-10-09 21:18:05 (GMT)
commit3b1580af07c0ce90d1c2073ab087772283d7e3b9 (patch)
tree764bd45ee98417ec03223e7d0324cf93cf0c36ca
parent0050670d76193ea529f51d0526256cb7a769d61b (diff)
downloadcpython-3b1580af07c0ce90d1c2073ab087772283d7e3b9.zip
cpython-3b1580af07c0ce90d1c2073ab087772283d7e3b9.tar.gz
cpython-3b1580af07c0ce90d1c2073ab087772283d7e3b9.tar.bz2
gh-78469: Declare missing sethostname for Solaris 10 (#109447)
Add OS version specific macro for Solaris: Py_SUNOS_VERSION.
-rw-r--r--Modules/socketmodule.c5
-rwxr-xr-xconfigure9
-rw-r--r--configure.ac8
-rw-r--r--pyconfig.h.in3
4 files changed, 23 insertions, 2 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 90592ff..3d099d4 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -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
diff --git a/configure b/configure
index 1799323..d68c4e8 100755
--- 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; }
diff --git a/configure.ac b/configure.ac
index cafc6df..9a9c76f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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"])
diff --git a/pyconfig.h.in b/pyconfig.h.in
index f07e677..4b8fc4a 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -1621,6 +1621,9 @@
/* 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