Skip to content

Commit

Permalink
[3.12] gh-89886: Rely on HAVE_SYS_TIME_H (GH-105058) (#105192)
Browse files Browse the repository at this point in the history
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 9ab587b)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
miss-islington and erlend-aasland committed Jun 1, 2023
1 parent dbd7d7c commit 6375287
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
3 changes: 3 additions & 0 deletions Modules/readline.c
Expand Up @@ -11,7 +11,10 @@
#include <signal.h>
#include <stddef.h>
#include <stdlib.h> // free()
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <time.h>

#if defined(HAVE_SETLOCALE)
/* GNU readline() mistakenly sets the LC_CTYPE locale.
Expand Down
3 changes: 3 additions & 0 deletions Modules/resource.c
@@ -1,7 +1,10 @@

#include "Python.h"
#include <sys/resource.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <time.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
Expand Down
10 changes: 1 addition & 9 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions configure.ac
Expand Up @@ -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 <sys/time.h> and <time.h>.])
])

# checks for structures
AC_STRUCT_TM
AC_STRUCT_TIMEZONE
Expand Down Expand Up @@ -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])
Expand Down
3 changes: 0 additions & 3 deletions pyconfig.h.in
Expand Up @@ -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 <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME

/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME

Expand Down

0 comments on commit 6375287

Please sign in to comment.