From: Victor Stinner Date: Sat, 2 Sep 2023 13:46:43 +0000 (+0200) Subject: gh-108765: Remove old prototypes from pyport.h (#108782) X-Git-Tag: v3.13.0a1~648 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1f3e797dc0451f48e649bcab2c9fd80224ffdac0;p=thirdparty%2FPython%2Fcpython.git gh-108765: Remove old prototypes from pyport.h (#108782) Move prototypes of gethostname(), _getpty() and struct termios from pyport.h to the C code using them: posixmodule.c, socketmodule.c and termios.c. Replace "#ifdef SOLARIS" with "#ifdef __sun". --- diff --git a/Include/pyport.h b/Include/pyport.h index 511c3fda1a40..67164328d295 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -417,32 +417,6 @@ extern "C" { # define Py_NO_INLINE #endif -/************************************************************************** -Prototypes that are missing from the standard include files on some systems -(and possibly only some versions of such systems.) - -Please be conservative with adding new ones, document them and enclose them -in platform-specific #ifdefs. -**************************************************************************/ - -#ifdef SOLARIS -/* Unchecked */ -extern int gethostname(char *, int); -#endif - -#ifdef HAVE__GETPTY -#include /* we need to import mode_t */ -extern char * _getpty(int *, int, mode_t, int); -#endif - -/* On QNX 6, struct termio must be declared by including sys/termio.h - if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must - be included before termios.h or it will generate an error. */ -#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux) -#include -#endif - - /* On 4.4BSD-descendants, ctype functions serves the whole range of * wchar_t character set rather than single byte code points only. * This characteristic can break some operations of string object diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 0436571abc90..761542866d8f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -58,6 +58,13 @@ #include // ctermid() #include // system() +// SGI apparently needs this forward declaration +#ifdef HAVE__GETPTY +# include // mode_t + extern char * _getpty(int *, int, mode_t, int); +#endif + + /* * A number of APIs are available on macOS from a certain macOS version. * To support building with a new SDK while deploying to older versions diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index e3681853dad0..2f12c9cedbd8 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -111,9 +111,13 @@ Local naming conventions: #include "pycore_fileutils.h" // _Py_set_inheritable() #include "pycore_moduleobject.h" // _PyModule_GetState +// gethostname() prototype missing from Solaris standard header files +#ifdef __sun +extern int gethostname(char *, int); +#endif #ifdef _Py_MEMORY_SANITIZER -# include +# include #endif /* Socket object documentation */ diff --git a/Modules/termios.c b/Modules/termios.c index 21d3541c177b..a0613837ef97 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -6,10 +6,17 @@ #include "Python.h" -/* Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE - is defined, so we define it here. */ +// On QNX 6, struct termio must be declared by including sys/termio.h +// if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must +// be included before termios.h or it will generate an error. +#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux) +# include +#endif + +// Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE +// is defined, so we define it here. #if defined(__sgi) -#define CTRL(c) ((c)&037) +# define CTRL(c) ((c)&037) #endif #if defined(__sun)