mirror of https://github.com/python/cpython
gh-108765: Python.h no longer includes <sys/time.h> (#108775)
Python.h no longer includes <time.h>, <sys/select.h> and <sys/time.h> standard header files. * Add <time.h> include to xxsubtype.c. * Add <sys/time.h> include to posixmodule.c and semaphore.c. * readline.c includes <sys/select.h> instead of <sys/time.h>. * resource.c no longer includes <time.h> and <sys/time.h>.
This commit is contained in:
parent
bdc3c884cd
commit
e7de0c5901
|
@ -934,6 +934,14 @@ Porting to Python 3.13
|
||||||
functions: ``close()``, ``getpagesize()``, ``getpid()`` and ``sysconf()``.
|
functions: ``close()``, ``getpagesize()``, ``getpid()`` and ``sysconf()``.
|
||||||
(Contributed by Victor Stinner in :gh:`108765`.)
|
(Contributed by Victor Stinner in :gh:`108765`.)
|
||||||
|
|
||||||
|
* ``Python.h`` no longer includes these standard header files: ``<time.h>``,
|
||||||
|
``<sys/select.h>`` and ``<sys/time.h>``. If needed, they should now be
|
||||||
|
included explicitly. For example, ``<time.h>`` provides the ``clock()`` and
|
||||||
|
``gmtime()`` functions, ``<sys/select.h>`` provides the ``select()``
|
||||||
|
function, and ``<sys/time.h>`` provides the ``futimes()``, ``gettimeofday()``
|
||||||
|
and ``setitimer()`` functions.
|
||||||
|
(Contributed by Victor Stinner in :gh:`108765`.)
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
|
@ -184,25 +184,6 @@ typedef Py_ssize_t Py_ssize_clean_t;
|
||||||
# define Py_MEMCPY memcpy
|
# define Py_MEMCPY memcpy
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/********************************************
|
|
||||||
* WRAPPER FOR <time.h> and/or <sys/time.h> *
|
|
||||||
********************************************/
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
/******************************
|
|
||||||
* WRAPPER FOR <sys/select.h> *
|
|
||||||
******************************/
|
|
||||||
|
|
||||||
/* NB caller must include <sys/types.h> */
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SELECT_H
|
|
||||||
#include <sys/select.h>
|
|
||||||
#endif /* !HAVE_SYS_SELECT_H */
|
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* stat() and fstat() fiddling *
|
* stat() and fstat() fiddling *
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
``Python.h`` no longer includes these standard header files: ``<time.h>``,
|
||||||
|
``<sys/select.h>`` and ``<sys/time.h>``. If needed, they should now be included
|
||||||
|
explicitly. For example, ``<time.h>`` provides the ``clock()`` and ``gmtime()``
|
||||||
|
functions, ``<sys/select.h>`` provides the ``select()`` function, and
|
||||||
|
``<sys/time.h>`` provides the ``futimes()``, ``gettimeofday()`` and
|
||||||
|
``setitimer()`` functions. Patch by Victor Stinner.
|
|
@ -9,6 +9,10 @@
|
||||||
|
|
||||||
#include "multiprocessing.h"
|
#include "multiprocessing.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h> // gettimeofday()
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_MP_SEMAPHORE
|
#ifdef HAVE_MP_SEMAPHORE
|
||||||
|
|
||||||
enum { RECURSIVE_MUTEX, SEMAPHORE };
|
enum { RECURSIVE_MUTEX, SEMAPHORE };
|
||||||
|
|
|
@ -57,6 +57,10 @@
|
||||||
|
|
||||||
#include <stdio.h> // ctermid()
|
#include <stdio.h> // ctermid()
|
||||||
#include <stdlib.h> // system()
|
#include <stdlib.h> // system()
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h> // futimes()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// SGI apparently needs this forward declaration
|
// SGI apparently needs this forward declaration
|
||||||
#ifdef HAVE__GETPTY
|
#ifdef HAVE__GETPTY
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pycore_pylifecycle.h" // _Py_SetLocaleFromEnv()
|
#include "pycore_pylifecycle.h" // _Py_SetLocaleFromEnv()
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h> // errno
|
||||||
#include <signal.h>
|
#include <signal.h> // SIGWINCH
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdlib.h> // free()
|
#include <stdlib.h> // free()
|
||||||
#ifdef HAVE_SYS_TIME_H
|
#include <string.h> // strdup()
|
||||||
#include <sys/time.h>
|
#ifdef HAVE_SYS_SELECT_H
|
||||||
|
# include <sys/select.h> // select()
|
||||||
#endif
|
#endif
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#if defined(HAVE_SETLOCALE)
|
#if defined(HAVE_SETLOCALE)
|
||||||
/* GNU readline() mistakenly sets the LC_CTYPE locale.
|
/* GNU readline() mistakenly sets the LC_CTYPE locale.
|
||||||
|
@ -27,7 +26,7 @@
|
||||||
* We must save and restore the locale around the rl_initialize() call.
|
* We must save and restore the locale around the rl_initialize() call.
|
||||||
*/
|
*/
|
||||||
#define SAVE_LOCALE
|
#define SAVE_LOCALE
|
||||||
#include <locale.h>
|
# include <locale.h> // setlocale()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SAVE_LOCALE
|
#ifdef SAVE_LOCALE
|
||||||
|
@ -1333,7 +1332,8 @@ readline_until_enter_or_signal(const char *prompt, int *signal)
|
||||||
int has_input = 0, err = 0;
|
int has_input = 0, err = 0;
|
||||||
|
|
||||||
while (!has_input)
|
while (!has_input)
|
||||||
{ struct timeval timeout = {0, 100000}; /* 0.1 seconds */
|
{
|
||||||
|
struct timeval timeout = {0, 100000}; // 100 ms (0.1 seconds)
|
||||||
|
|
||||||
/* [Bug #1552726] Only limit the pause if an input hook has been
|
/* [Bug #1552726] Only limit the pause if an input hook has been
|
||||||
defined. */
|
defined. */
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
#include <errno.h> // errno
|
#include <errno.h> // errno
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/resource.h> // getrusage()
|
#include <sys/resource.h> // getrusage()
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
# include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h> // getpagesize()
|
#include <unistd.h> // getpagesize()
|
||||||
|
|
||||||
/* On some systems, these aren't in any header file.
|
/* On some systems, these aren't in any header file.
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
#include "pycore_signal.h" // _Py_RestoreSignals()
|
#include "pycore_signal.h" // _Py_RestoreSignals()
|
||||||
|
|
||||||
#ifndef MS_WINDOWS
|
#ifndef MS_WINDOWS
|
||||||
# include "posixmodule.h"
|
# include "posixmodule.h" // _PyLong_FromUid()
|
||||||
#endif
|
#endif
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
# include "socketmodule.h" /* needed for SOCKET_T */
|
# include "socketmodule.h" // SOCKET_T
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
|
@ -29,16 +29,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SIGNAL_H
|
#ifdef HAVE_SIGNAL_H
|
||||||
# include <signal.h>
|
# include <signal.h> // sigaction()
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_SYSCALL_H
|
#ifdef HAVE_SYS_SYSCALL_H
|
||||||
# include <sys/syscall.h>
|
# include <sys/syscall.h> // __NR_pidfd_send_signal
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_STAT_H
|
#ifdef HAVE_SYS_STAT_H
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_TIME_H
|
#ifdef HAVE_SYS_TIME_H
|
||||||
# include <sys/time.h>
|
# include <sys/time.h> // setitimer()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK)
|
#if defined(HAVE_PTHREAD_SIGMASK) && !defined(HAVE_BROKEN_PTHREAD_SIGMASK)
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "pycore_runtime.h" // _Py_ID()
|
#include "pycore_runtime.h" // _Py_ID()
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <time.h> // clock()
|
||||||
#ifdef HAVE_SYS_TIMES_H
|
#ifdef HAVE_SYS_TIMES_H
|
||||||
# include <sys/times.h>
|
# include <sys/times.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
|
||||||
#include <stddef.h> // offsetof()
|
#include <stddef.h> // offsetof()
|
||||||
|
#include <time.h> // clock()
|
||||||
|
|
||||||
|
|
||||||
PyDoc_STRVAR(xxsubtype__doc__,
|
PyDoc_STRVAR(xxsubtype__doc__,
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pycore_time.h" // _PyTime_t
|
#include "pycore_time.h" // _PyTime_t
|
||||||
|
|
||||||
|
#include <time.h> // gmtime_r()
|
||||||
|
#ifdef HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h> // gettimeofday()
|
||||||
|
#endif
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
# include <winsock2.h> // struct timeval
|
# include <winsock2.h> // struct timeval
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue