Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-78469: Declare missing sethostname for Solaris 10 #109447

Merged
merged 8 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, that's very spefic. It was available before and after, but not at 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

Expand Down
9 changes: 9 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 '.'`
kulikjak marked this conversation as resolved.
Show resolved Hide resolved
AC_DEFINE_UNQUOTED([SUNOS_VERSION], [$SUNOS_VERSION],
[The version of SunOS/Solaris as reported by `uname -r' without the dot.])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you distinguish Solaris 5.10 and Solaris 51.0?

Maybe multiply the major version by 100 or 1000? or use a shift of 8 bits? The usage would be:

major = VERSION >> 8
minor = VERSION & 255

The disavantage is the need to write versions in hexadecimal :-(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erlend-aasland: Should we prefix new pyconfig.h constants by Py_ ? see: capi-workgroup/problems#46

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should follow the PEP-7 recommendations: https://peps.python.org/pep-0007/#naming-conventions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you distinguish Solaris 5.10 and Solaris 51.0?

I see what you mean, but that's not happening. The leading 5 was dropped from the name 25 years ago and while e.g. uname and compilation targets still use it, nobody today calls it Solaris/SunOS 5.10; only Solaris 10. If we ever release Solaris 51, uname -r should report it as 5.51.

That said, I am not strongly against changing it if you still prefer your suggestion.

I think we should follow the PEP-7 recommendations: https://peps.python.org/pep-0007/#naming-conventions

Thanks, I missed that. It's fixed now.

fi
fi
AC_MSG_RESULT(["$MACHDEP"])

Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/select.h> and <sys/time.h>
(which you can't on SCO ODT 3.0). */
#undef SYS_SELECT_WITH_SYS_TIME
Expand Down
Loading