Skip to content

configure: include <time.h> unconditionally when detecting time functions - #6859

Closed
michaelforney wants to merge 1 commit into
curl:masterfrom
michaelforney:AC_HEADER_TIME
Closed

michaelforney wants to merge 1 commit into
curl:masterfrom
michaelforney:AC_HEADER_TIME

Conversation

@michaelforney

Copy link
Copy Markdown
Contributor

In 2682e5f, several instances of AC_HEADER_TIME were removed since it is a deprecated autoconf macro. However, this was the macro that defined TIME_WITH_SYS_TIME, which was used to indicate that <time.h> can be included alongside <sys/time.h>. TIME_WITH_SYS_TIME is still used in the configure test body and since it is no longer defined, <time.h> is not included on systems that have <sys/time.h>.

In particular, at least on musl libc and glibc, <sys/time.h> does not implicitly include <time.h> and does not declare clock_gettime, gmtime_r, or localtime_r. This causes configure to fail to detect those functions.

The AC_HEADER_TIME macro deprecation text says

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.

So, to fix this issue, simply include <time.h> unconditionally when testing for time-related functions and in libcurl, and don't bother checking for it.

…ions

In 2682e5f, several instances of AC_HEADER_TIME were removed since
it is a deprecated autoconf macro. However, this was the macro that
defined TIME_WITH_SYS_TIME, which was used to indicate that <time.h>
can be included alongside <sys/time.h>. TIME_WITH_SYS_TIME is still
used in the configure test body and since it is no longer defined,
<time.h> is *not* included on systems that have <sys/time.h>.

In particular, at least on musl libc and glibc, <sys/time.h> does
not implicitly include <time.h> and does not declare clock_gettime,
gmtime_r, or localtime_r. This causes configure to fail to detect
those functions.

The AC_HEADER_TIME macro deprecation text says

> 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.

So, to fix this issue, simply include <time.h> unconditionally when
testing for time-related functions and in libcurl, and don't bother
checking for it.
@lgtm-com

lgtm-com Bot commented Apr 7, 2021

Copy link
Copy Markdown

This pull request fixes 1 alert when merging 3899c60 into 3be5ebf - view on LGTM.com

fixed alerts:

  • 1 for Use of potentially dangerous function

@bagder bagder added the build label Apr 7, 2021
@bagder

bagder commented Apr 7, 2021

Copy link
Copy Markdown
Member

Thanks!

@bagder bagder closed this in eaa1d73 Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants