From 4a4bc4f65440f59cc7d7020b5fef2262df99fad1 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 1 Jun 2023 13:37:40 +0200 Subject: [PATCH] gh-89886: Rely on HAVE_SYS_TIME_H (GH-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. (cherry picked from commit 9ab587b7146618866cee52c220aecf7bd5b44b02) Co-authored-by: Erlend E. Aasland --- Modules/readline.c | 3 +++ Modules/resource.c | 3 +++ configure | 10 +--------- configure.ac | 10 +++------- pyconfig.h.in | 3 --- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Modules/readline.c b/Modules/readline.c index fdb6356e1c84b5..2824105a187586 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -11,7 +11,10 @@ #include #include #include // free() +#ifdef HAVE_SYS_TIME_H #include +#endif +#include #if defined(HAVE_SETLOCALE) /* GNU readline() mistakenly sets the LC_CTYPE locale. diff --git a/Modules/resource.c b/Modules/resource.c index 2a8158c9be5359..3c89468c48c56e 100644 --- a/Modules/resource.c +++ b/Modules/resource.c @@ -1,7 +1,10 @@ #include "Python.h" #include +#ifdef HAVE_SYS_TIME_H #include +#endif +#include #include #include #include diff --git a/configure b/configure index ed80d95ecba022..012dac94feddd6 100755 --- a/configure +++ b/configure @@ -19866,14 +19866,6 @@ fi done -if test "x$ac_cv_header_sys_time_h" = xyes; then : - - -$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h - - -fi - # checks for structures { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } @@ -26736,7 +26728,7 @@ $as_echo_n "checking for stdlib extension module pyexpat... " >&6; } if test "$py_cv_module_pyexpat" != "n/a"; then : if true; then : - if true; then : + if test "$ac_cv_header_sys_time_h" = "yes"; then : py_cv_module_pyexpat=yes else py_cv_module_pyexpat=missing diff --git a/configure.ac b/configure.ac index 2d3f5191fbf3c3..c30fb2a08d104e 100644 --- a/configure.ac +++ b/configure.ac @@ -5375,12 +5375,6 @@ fi AC_CHECK_FUNCS([getnameinfo]) -dnl autoconf 2.71 deprecates AC_HEADER_TIME, keep for backwards compatibility -dnl TIME_WITH_SYS_TIME works on all supported systems that have sys/time.h -AS_VAR_IF([ac_cv_header_sys_time_h], [yes], [ - AC_DEFINE([TIME_WITH_SYS_TIME], 1, [Define to 1 if you can safely include both and .]) -]) - # checks for structures AC_STRUCT_TM AC_STRUCT_TIMEZONE @@ -7375,7 +7369,9 @@ PY_STDLIB_MOD([syslog], [], [test "$ac_cv_header_syslog_h" = yes]) PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes]) dnl _elementtree loads libexpat via CAPI hook in pyexpat -PY_STDLIB_MOD([pyexpat], [], [], [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS]) +PY_STDLIB_MOD([pyexpat], + [], [test "$ac_cv_header_sys_time_h" = "yes"], + [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS]) PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], []) PY_STDLIB_MOD_SIMPLE([_codecs_cn]) PY_STDLIB_MOD_SIMPLE([_codecs_hk]) diff --git a/pyconfig.h.in b/pyconfig.h.in index 2c22b27af65ea3..b33e82c3609c18 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1691,9 +1691,6 @@ /* Library needed by timemodule.c: librt may be needed for clock_gettime() */ #undef TIMEMODULE_LIB -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME