Skip to content

Commit 9ab587b

Browse files
gh-89886: Rely on HAVE_SYS_TIME_H (#105058)
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 76b9c0c commit 9ab587b

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

Modules/readline.c

+3
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

+3
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

+1-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+3-7
Original file line numberDiff line numberDiff line change
@@ -5305,12 +5305,6 @@ fi
53055305

53065306
AC_CHECK_FUNCS([getnameinfo])
53075307

5308-
dnl autoconf 2.71 deprecates AC_HEADER_TIME, keep for backwards compatibility
5309-
dnl TIME_WITH_SYS_TIME works on all supported systems that have sys/time.h
5310-
AS_VAR_IF([ac_cv_header_sys_time_h], [yes], [
5311-
AC_DEFINE([TIME_WITH_SYS_TIME], 1, [Define to 1 if you can safely include both <sys/time.h> and <time.h>.])
5312-
])
5313-
53145308
# checks for structures
53155309
AC_STRUCT_TM
53165310
AC_STRUCT_TIMEZONE
@@ -7296,7 +7290,9 @@ PY_STDLIB_MOD([syslog], [], [test "$ac_cv_header_syslog_h" = yes])
72967290
PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes])
72977291

72987292
dnl _elementtree loads libexpat via CAPI hook in pyexpat
7299-
PY_STDLIB_MOD([pyexpat], [], [], [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS])
7293+
PY_STDLIB_MOD([pyexpat],
7294+
[], [test "$ac_cv_header_sys_time_h" = "yes"],
7295+
[$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS])
73007296
PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], [])
73017297
PY_STDLIB_MOD_SIMPLE([_codecs_cn])
73027298
PY_STDLIB_MOD_SIMPLE([_codecs_hk])

pyconfig.h.in

-3
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)