Skip to content

Commit 1f3e797

Browse files
authored
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".
1 parent 5141b1e commit 1f3e797

File tree

4 files changed

+22
-30
lines changed

4 files changed

+22
-30
lines changed

Include/pyport.h

-26
Original file line numberDiff line numberDiff line change
@@ -417,32 +417,6 @@ extern "C" {
417417
# define Py_NO_INLINE
418418
#endif
419419

420-
/**************************************************************************
421-
Prototypes that are missing from the standard include files on some systems
422-
(and possibly only some versions of such systems.)
423-
424-
Please be conservative with adding new ones, document them and enclose them
425-
in platform-specific #ifdefs.
426-
**************************************************************************/
427-
428-
#ifdef SOLARIS
429-
/* Unchecked */
430-
extern int gethostname(char *, int);
431-
#endif
432-
433-
#ifdef HAVE__GETPTY
434-
#include <sys/types.h> /* we need to import mode_t */
435-
extern char * _getpty(int *, int, mode_t, int);
436-
#endif
437-
438-
/* On QNX 6, struct termio must be declared by including sys/termio.h
439-
if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must
440-
be included before termios.h or it will generate an error. */
441-
#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux)
442-
#include <sys/termio.h>
443-
#endif
444-
445-
446420
/* On 4.4BSD-descendants, ctype functions serves the whole range of
447421
* wchar_t character set rather than single byte code points only.
448422
* This characteristic can break some operations of string object

Modules/posixmodule.c

+7
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@
5858
#include <stdio.h> // ctermid()
5959
#include <stdlib.h> // system()
6060

61+
// SGI apparently needs this forward declaration
62+
#ifdef HAVE__GETPTY
63+
# include <sys/types.h> // mode_t
64+
extern char * _getpty(int *, int, mode_t, int);
65+
#endif
66+
67+
6168
/*
6269
* A number of APIs are available on macOS from a certain macOS version.
6370
* To support building with a new SDK while deploying to older versions

Modules/socketmodule.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ Local naming conventions:
111111
#include "pycore_fileutils.h" // _Py_set_inheritable()
112112
#include "pycore_moduleobject.h" // _PyModule_GetState
113113

114+
// gethostname() prototype missing from Solaris standard header files
115+
#ifdef __sun
116+
extern int gethostname(char *, int);
117+
#endif
114118

115119
#ifdef _Py_MEMORY_SANITIZER
116-
# include <sanitizer/msan_interface.h>
120+
# include <sanitizer/msan_interface.h>
117121
#endif
118122

119123
/* Socket object documentation */

Modules/termios.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66

77
#include "Python.h"
88

9-
/* Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE
10-
is defined, so we define it here. */
9+
// On QNX 6, struct termio must be declared by including sys/termio.h
10+
// if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must
11+
// be included before termios.h or it will generate an error.
12+
#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux)
13+
# include <sys/termio.h>
14+
#endif
15+
16+
// Apparently, on SGI, termios.h won't define CTRL if _XOPEN_SOURCE
17+
// is defined, so we define it here.
1118
#if defined(__sgi)
12-
#define CTRL(c) ((c)&037)
19+
# define CTRL(c) ((c)&037)
1320
#endif
1421

1522
#if defined(__sun)

0 commit comments

Comments
 (0)