Create a new section of pyport.h to hold all external function declarations
for systems that are missing those declarations from system include files. Start by moving a pointy-haired ones from their previous locations to the new section. (The gethostname() one, for instance, breaks on several systems, because some define it as (char *, size_t) and some as (char *, int).) I purposely decided not to include the summary of used #defines like Tim did in the first section of pyport.h. In my opinion, the number of #defines likedly to be used by this section would make such an overview unwieldy. I would suggest documenting the non-obvious ones, though.
This commit is contained in:
parent
332c59c4ef
commit
1e0c2f4bee
|
@ -74,6 +74,68 @@ extern "C" {
|
||||||
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
|
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
|
||||||
#endif
|
#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 __BEOS__
|
||||||
|
/* Unchecked */
|
||||||
|
/* It's in the libs, but not the headers... - [cjh] */
|
||||||
|
int shutdown( int, int );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE__GETPTY
|
||||||
|
/* Unchecked */
|
||||||
|
extern char * _getpty(int *, int, mode_t, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
|
||||||
|
#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H)
|
||||||
|
/* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
|
||||||
|
functions, even though they are included in libutil. */
|
||||||
|
#include <termios.h>
|
||||||
|
extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
|
||||||
|
extern int forkpty(int *, char *, struct termios *, struct winsize *);
|
||||||
|
#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
|
||||||
|
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
|
||||||
|
|
||||||
|
|
||||||
|
/* These are pulled from various places. It isn't obvious on what platforms
|
||||||
|
they are necessary, nor what the exact prototype should look like (which
|
||||||
|
is likely to vary between platforms!) If you find you need one of these
|
||||||
|
declarations, please move them to a platform-specific block and include
|
||||||
|
proper prototypes. */
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
/* From Modules/resource.c */
|
||||||
|
extern int getrusage();
|
||||||
|
extern int getpagesize();
|
||||||
|
|
||||||
|
/* From Python/sysmodule.c and Modules/posixmodule.c */
|
||||||
|
extern int fclose(FILE *);
|
||||||
|
|
||||||
|
/* From Modules/posixmodule.c */
|
||||||
|
extern int fdatasync(int);
|
||||||
|
/* XXX These are supposedly for SunOS4.1.3 but "shouldn't hurt elsewhere" */
|
||||||
|
extern int rename(const char *, const char *);
|
||||||
|
extern int pclose(FILE *);
|
||||||
|
extern int lstat(const char *, struct stat *);
|
||||||
|
extern int symlink(const char *, const char *);
|
||||||
|
extern int fsync(int fd);
|
||||||
|
|
||||||
|
#endif /* 0 */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -128,14 +128,7 @@ corresponding Unix manual entries for more information on calls.";
|
||||||
#define UNION_WAIT /* This should really be checked for by autoconf */
|
#define UNION_WAIT /* This should really be checked for by autoconf */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifndef HAVE_UNISTD_H
|
||||||
/* XXX These are for SunOS4.1.3 but shouldn't hurt elsewhere */
|
|
||||||
extern int rename(const char *, const char *);
|
|
||||||
extern int pclose(FILE *);
|
|
||||||
extern int lstat(const char *, struct stat *);
|
|
||||||
extern int symlink(const char *, const char *);
|
|
||||||
extern int fsync(int fd);
|
|
||||||
#else /* !HAVE_UNISTD_H */
|
|
||||||
#if defined(PYCC_VACPP)
|
#if defined(PYCC_VACPP)
|
||||||
extern int mkdir(char *);
|
extern int mkdir(char *);
|
||||||
#else
|
#else
|
||||||
|
@ -721,8 +714,6 @@ static char posix_fdatasync__doc__[] =
|
||||||
force write of file with filedescriptor to disk.\n\
|
force write of file with filedescriptor to disk.\n\
|
||||||
does not force update of metadata.";
|
does not force update of metadata.";
|
||||||
|
|
||||||
extern int fdatasync(int); /* Prototype just in case */
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
posix_fdatasync(PyObject *self, PyObject *args)
|
posix_fdatasync(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
@ -1680,12 +1671,6 @@ posix_fork(PyObject *self, PyObject *args)
|
||||||
#else
|
#else
|
||||||
#ifdef HAVE_LIBUTIL_H
|
#ifdef HAVE_LIBUTIL_H
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
#else
|
|
||||||
/* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
|
|
||||||
functions, even though they are included in libutil. */
|
|
||||||
#include <termios.h>
|
|
||||||
extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
|
|
||||||
extern int forkpty(int *, char *, struct termios *, struct winsize *);
|
|
||||||
#endif /* HAVE_LIBUTIL_H */
|
#endif /* HAVE_LIBUTIL_H */
|
||||||
#endif /* HAVE_PTY_H */
|
#endif /* HAVE_PTY_H */
|
||||||
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
|
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
|
||||||
|
@ -1701,8 +1686,6 @@ posix_openpty(PyObject *self, PyObject *args)
|
||||||
int master_fd, slave_fd;
|
int master_fd, slave_fd;
|
||||||
#ifndef HAVE_OPENPTY
|
#ifndef HAVE_OPENPTY
|
||||||
char * slave_name;
|
char * slave_name;
|
||||||
/* SGI apparently needs this forward declaration */
|
|
||||||
extern char * _getpty(int *, int, mode_t, int);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, ":openpty"))
|
if (!PyArg_ParseTuple(args, ":openpty"))
|
||||||
|
@ -1719,7 +1702,7 @@ posix_openpty(PyObject *self, PyObject *args)
|
||||||
slave_fd = open(slave_name, O_RDWR);
|
slave_fd = open(slave_name, O_RDWR);
|
||||||
if (slave_fd < 0)
|
if (slave_fd < 0)
|
||||||
return posix_error();
|
return posix_error();
|
||||||
#endif /* defined(HAVE_OPENPTY) */
|
#endif /* HAVE_OPENPTY */
|
||||||
|
|
||||||
return Py_BuildValue("(ii)", master_fd, slave_fd);
|
return Py_BuildValue("(ii)", master_fd, slave_fd);
|
||||||
|
|
||||||
|
@ -3286,7 +3269,6 @@ Return an open file object connected to a file descriptor.";
|
||||||
static PyObject *
|
static PyObject *
|
||||||
posix_fdopen(PyObject *self, PyObject *args)
|
posix_fdopen(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
extern int fclose(FILE *);
|
|
||||||
int fd;
|
int fd;
|
||||||
char *mode = "r";
|
char *mode = "r";
|
||||||
int bufsize = -1;
|
int bufsize = -1;
|
||||||
|
|
|
@ -22,10 +22,6 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
but we can't declare the prototype, to avoid errors
|
but we can't declare the prototype, to avoid errors
|
||||||
when the header files declare it different.
|
when the header files declare it different.
|
||||||
Worse, on some Linuxes, getpagesize() returns a size_t... */
|
Worse, on some Linuxes, getpagesize() returns a size_t... */
|
||||||
#ifndef linux
|
|
||||||
int getrusage();
|
|
||||||
int getpagesize();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
|
#define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,6 @@ Socket methods:
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(MS_WINDOWS) && !defined(PYOS_OS2) && !defined(__BEOS__)
|
|
||||||
extern int gethostname(char *, size_t); /* For Solaris, at least */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PYCC_VACPP)
|
#if defined(PYCC_VACPP)
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
@ -129,11 +125,6 @@ extern int gethostname(char *, size_t); /* For Solaris, at least */
|
||||||
#include <os2.h>
|
#include <os2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__BEOS__)
|
|
||||||
/* It's in the libs, but not the headers... - [cjh] */
|
|
||||||
int shutdown( int, int );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "mytime.h"
|
#include "mytime.h"
|
||||||
|
|
||||||
|
@ -2407,9 +2398,9 @@ shutdown() -- shut down traffic in one or both directions\n\
|
||||||
|
|
||||||
DL_EXPORT(void)
|
DL_EXPORT(void)
|
||||||
#if defined(MS_WINDOWS) || defined(PYOS_OS2) || defined(__BEOS__)
|
#if defined(MS_WINDOWS) || defined(PYOS_OS2) || defined(__BEOS__)
|
||||||
init_socket()
|
init_socket(void)
|
||||||
#else
|
#else
|
||||||
initsocket()
|
initsocket(void)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
PyObject *m, *d;
|
PyObject *m, *d;
|
||||||
|
|
|
@ -385,7 +385,6 @@ settrace() -- set the global debug tracing function\n\
|
||||||
PyObject *
|
PyObject *
|
||||||
_PySys_Init(void)
|
_PySys_Init(void)
|
||||||
{
|
{
|
||||||
extern int fclose(FILE *);
|
|
||||||
PyObject *m, *v, *sysdict;
|
PyObject *m, *v, *sysdict;
|
||||||
PyObject *sysin, *sysout, *syserr;
|
PyObject *sysin, *sysout, *syserr;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
Loading…
Reference in New Issue