From e71d8fbad2cac9405ef1ff4cfd7847c253987a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Fri, 15 Sep 2023 11:08:59 +0200 Subject: [PATCH 1/7] Add OS version specific macro for Solaris --- configure | 9 +++++++++ configure.ac | 8 ++++++++ pyconfig.h.in | 3 +++ 3 files changed, 20 insertions(+) diff --git a/configure b/configure index 8326a1db06c2da..6c6404dc017f7a 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 | tr -d '.'` + +printf "%s\n" "#define 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 843f2b267a5253..feb06e24249797 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 | tr -d '.'` + AC_DEFINE_UNQUOTED([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 86c72cc6b4e62a..0c3a9c2f097da7 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1681,6 +1681,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* The version of SunOS/Solaris as reported by `uname -r' without the dot. */ +#undef SUNOS_VERSION + /* Define if you can safely include both and (which you can't on SCO ODT 3.0). */ #undef SYS_SELECT_WITH_SYS_TIME From 5593f21d0c6ed791213eb786ebb2be676e0eee49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Fri, 15 Sep 2023 11:22:48 +0200 Subject: [PATCH 2/7] declare sethostname in socketmodule.c for Solaris 10 --- Modules/socketmodule.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 90592ffc152fc1..9abbe9652f3aa4 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) && 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 From bc5523ece485594dc651c9209c8962e3a3ec7a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Thu, 5 Oct 2023 17:02:58 +0200 Subject: [PATCH 3/7] rename SUNOS_VERSION to Py_SUNOS_VERSION (PEP 7 naming conventions) --- Modules/socketmodule.c | 2 +- configure | 2 +- configure.ac | 2 +- pyconfig.h.in | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 9abbe9652f3aa4..d9edefa24c453a 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5652,7 +5652,7 @@ socket_sethostname(PyObject *self, PyObject *args) Py_buffer buf; int res, flag = 0; -#if defined(_AIX) || (defined(__sun) && defined(__SVR4) && SUNOS_VERSION == 510) +#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); diff --git a/configure b/configure index 6c6404dc017f7a..c8ddcb834ad507 100755 --- a/configure +++ b/configure @@ -4290,7 +4290,7 @@ then # in most compilers, so we define one here. SUNOS_VERSION=`echo $ac_sys_release | tr -d '.'` -printf "%s\n" "#define SUNOS_VERSION $SUNOS_VERSION" >>confdefs.h +printf "%s\n" "#define Py_SUNOS_VERSION $SUNOS_VERSION" >>confdefs.h fi fi diff --git a/configure.ac b/configure.ac index feb06e24249797..5d20bcb09f12d2 100644 --- a/configure.ac +++ b/configure.ac @@ -595,7 +595,7 @@ 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 | tr -d '.'` - AC_DEFINE_UNQUOTED([SUNOS_VERSION], [$SUNOS_VERSION], + AC_DEFINE_UNQUOTED([Py_SUNOS_VERSION], [$SUNOS_VERSION], [The version of SunOS/Solaris as reported by `uname -r' without the dot.]) fi fi diff --git a/pyconfig.h.in b/pyconfig.h.in index 0c3a9c2f097da7..fbd06ebfad0664 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1612,6 +1612,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 @@ -1681,9 +1684,6 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* The version of SunOS/Solaris as reported by `uname -r' without the dot. */ -#undef SUNOS_VERSION - /* Define if you can safely include both and (which you can't on SCO ODT 3.0). */ #undef SYS_SELECT_WITH_SYS_TIME From 3a96e294ca75786d594b0190b9d03d443b4e91b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Fri, 6 Oct 2023 14:15:15 +0200 Subject: [PATCH 4/7] Update configure.ac Co-authored-by: Victor Stinner --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 5d20bcb09f12d2..6f31bfc217267c 100644 --- a/configure.ac +++ b/configure.ac @@ -594,7 +594,7 @@ then 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 | tr -d '.'` + 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 From 691441c0eb0363c12c2427bc36f4843106bc9459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Fri, 6 Oct 2023 14:15:55 +0200 Subject: [PATCH 5/7] Update configure --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index c8ddcb834ad507..c27a04c1462aac 100755 --- a/configure +++ b/configure @@ -4288,7 +4288,7 @@ then 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 | tr -d '.'` + 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 From f8f49e473883f22e51b29a6dd13a587399ab2bfd Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 6 Oct 2023 15:49:38 +0200 Subject: [PATCH 6/7] Run make regen-configure --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index c27a04c1462aac..adaa1fc0b117f4 100755 --- a/configure +++ b/configure @@ -4288,7 +4288,7 @@ then 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 '.'` + 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 From 5970802fc5f7cd9bbcbf777d7f09d15359fbb06a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 6 Oct 2023 15:52:04 +0200 Subject: [PATCH 7/7] Update Modules/socketmodule.c --- Modules/socketmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d9edefa24c453a..3d099d41d1e761 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -5652,7 +5652,7 @@ socket_sethostname(PyObject *self, PyObject *args) Py_buffer buf; int res, flag = 0; -#if defined(_AIX) || (defined(__sun) && defined(__SVR4) && Py_SUNOS_VERSION == 510) +#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);