Skip to content

Commit

Permalink
gh-108765: Remove old prototypes from pyport.h (#108782)
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
vstinner authored Sep 2, 2023
1 parent 5141b1e commit 1f3e797
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
26 changes: 0 additions & 26 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/types.h> /* 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 <sys/termio.h>
#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
Expand Down
7 changes: 7 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
#include <stdio.h> // ctermid()
#include <stdlib.h> // system()

// SGI apparently needs this forward declaration
#ifdef HAVE__GETPTY
# include <sys/types.h> // 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
Expand Down
6 changes: 5 additions & 1 deletion Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sanitizer/msan_interface.h>
# include <sanitizer/msan_interface.h>
#endif

/* Socket object documentation */
Expand Down
13 changes: 10 additions & 3 deletions Modules/termios.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/termio.h>
#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)
Expand Down

0 comments on commit 1f3e797

Please sign in to comment.