Skip to content

Commit 6375287

Browse files
[3.12] gh-89886: Rely on HAVE_SYS_TIME_H (GH-105058) (#105192)
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 <[email protected]>
1 parent dbd7d7c commit 6375287

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
@@ -5375,12 +5375,6 @@ fi
53755375

53765376
AC_CHECK_FUNCS([getnameinfo])
53775377

5378-
dnl autoconf 2.71 deprecates AC_HEADER_TIME, keep for backwards compatibility
5379-
dnl TIME_WITH_SYS_TIME works on all supported systems that have sys/time.h
5380-
AS_VAR_IF([ac_cv_header_sys_time_h], [yes], [
5381-
AC_DEFINE([TIME_WITH_SYS_TIME], 1, [Define to 1 if you can safely include both <sys/time.h> and <time.h>.])
5382-
])
5383-
53845378
# checks for structures
53855379
AC_STRUCT_TM
53865380
AC_STRUCT_TIMEZONE
@@ -7375,7 +7369,9 @@ PY_STDLIB_MOD([syslog], [], [test "$ac_cv_header_syslog_h" = yes])
73757369
PY_STDLIB_MOD([termios], [], [test "$ac_cv_header_termios_h" = yes])
73767370

73777371
dnl _elementtree loads libexpat via CAPI hook in pyexpat
7378-
PY_STDLIB_MOD([pyexpat], [], [], [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS])
7372+
PY_STDLIB_MOD([pyexpat],
7373+
[], [test "$ac_cv_header_sys_time_h" = "yes"],
7374+
[$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS])
73797375
PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], [])
73807376
PY_STDLIB_MOD_SIMPLE([_codecs_cn])
73817377
PY_STDLIB_MOD_SIMPLE([_codecs_hk])

pyconfig.h.in

-3
Original file line numberDiff line numberDiff line change
@@ -1691,9 +1691,6 @@
16911691
/* Library needed by timemodule.c: librt may be needed for clock_gettime() */
16921692
#undef TIMEMODULE_LIB
16931693

1694-
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
1695-
#undef TIME_WITH_SYS_TIME
1696-
16971694
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
16981695
#undef TM_IN_SYS_TIME
16991696

0 commit comments

Comments
 (0)