Skip to content

Commit 1a8d41e

Browse files
gh-89886: Rely on HAVE_SYS_TIME_H
Quoting autoconf (v2.71): All current systems provide time.h; it need not be checked for. Not all systems provide sys/time.h, but those that do, all allow you to include it and time.h simultaneously.
1 parent bfd20d2 commit 1a8d41e

File tree

6 files changed

+11
-19
lines changed

6 files changed

+11
-19
lines changed

Modules/expat/xmlparse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#ifdef _WIN32
8686
# define getpid GetCurrentProcessId
8787
#else
88+
// HAVE_SYS_TIME_H is enforced by configure
8889
# include <sys/time.h> /* gettimeofday() */
8990
# include <sys/types.h> /* getpid() */
9091
# include <unistd.h> /* getpid() */

Modules/readline.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
#include <signal.h>
1212
#include <stddef.h>
1313
#include <stdlib.h> // free()
14+
#ifdef HAVE_SYS_TIME_H
1415
#include <sys/time.h>
16+
#endif
17+
#include <time.h>
1518

1619
#if defined(HAVE_SETLOCALE)
1720
/* GNU readline() mistakenly sets the LC_CTYPE locale.

Modules/resource.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11

22
#include "Python.h"
33
#include <sys/resource.h>
4+
#ifdef HAVE_SYS_TIME_H
45
#include <sys/time.h>
6+
#endif
7+
#include <time.h>
58
#include <string.h>
69
#include <errno.h>
710
#include <unistd.h>

configure

Lines changed: 1 addition & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5236,12 +5236,6 @@ fi
52365236

52375237
AC_CHECK_FUNCS(getnameinfo)
52385238

5239-
dnl autoconf 2.71 deprecates AC_HEADER_TIME, keep for backwards compatibility
5240-
dnl TIME_WITH_SYS_TIME works on all supported systems that have sys/time.h
5241-
AS_VAR_IF([ac_cv_header_sys_time_h], [yes], [
5242-
AC_DEFINE([TIME_WITH_SYS_TIME], 1, [Define to 1 if you can safely include both <sys/time.h> and <time.h>.])
5243-
])
5244-
52455239
# checks for structures
52465240
AC_STRUCT_TM
52475241
AC_STRUCT_TIMEZONE
@@ -7201,7 +7195,9 @@ PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes])
72017195

72027196
dnl _elementtree loads libexpat via CAPI hook in pyexpat
72037197
PY_STDLIB_MOD([pyexpat], [], [], [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS])
7204-
PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], [])
7198+
PY_STDLIB_MOD([_elementtree],
7199+
[], [test "$ac_cv_header_sys_time_h" = "yes"],
7200+
[$LIBEXPAT_CFLAGS], [])
72057201
PY_STDLIB_MOD_SIMPLE([_codecs_cn])
72067202
PY_STDLIB_MOD_SIMPLE([_codecs_hk])
72077203
PY_STDLIB_MOD_SIMPLE([_codecs_iso2022])

pyconfig.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,9 +1682,6 @@
16821682
/* Library needed by timemodule.c: librt may be needed for clock_gettime() */
16831683
#undef TIMEMODULE_LIB
16841684

1685-
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
1686-
#undef TIME_WITH_SYS_TIME
1687-
16881685
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
16891686
#undef TM_IN_SYS_TIME
16901687

0 commit comments

Comments
 (0)