1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Build: Check for clock_gettime() even if not using POSIX threads.

See the new comment in the code.

This also makes the check for clock_gettime() run with MinGW-w64
with which we don't want to use clock_gettime(). The previous
commit already took care of this situation.
This commit is contained in:
Lasse Collin 2023-09-23 03:23:32 +03:00
parent 46fd991cd2
commit 1c1a8c3ee4

View file

@ -622,21 +622,10 @@ AS_CASE([$enable_threads],
AC_DEFINE([MYTHREAD_POSIX], [1], AC_DEFINE([MYTHREAD_POSIX], [1],
[Define to 1 when using POSIX threads (pthreads).]) [Define to 1 when using POSIX threads (pthreads).])
# These are nice to have but not mandatory. # This is nice to have but not mandatory.
#
# FIXME: xz uses clock_gettime if it is available and can do
# it even when threading is disabled. Moving this outside
# of pthread detection may be undesirable because then
# liblzma may get linked against librt even when librt isn't
# needed by liblzma.
OLD_CFLAGS=$CFLAGS OLD_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
AC_SEARCH_LIBS([clock_gettime], [rt]) AC_CHECK_FUNCS([pthread_condattr_setclock])
AC_CHECK_FUNCS([clock_gettime pthread_condattr_setclock])
AC_CHECK_DECL([CLOCK_MONOTONIC], [AC_DEFINE(
[HAVE_CLOCK_MONOTONIC], [1], [Define to 1 if
`CLOCK_MONOTONIC' is declared in <time.h>.])], [],
[[#include <time.h>]])
CFLAGS=$OLD_CFLAGS CFLAGS=$OLD_CFLAGS
], ],
[win95], [ [win95], [
@ -916,6 +905,22 @@ fi
# Gnulib replacements as needed # Gnulib replacements as needed
gl_GETOPT gl_GETOPT
# If clock_gettime() is available, liblzma with pthreads may use it, and
# xz may use it even when threading support is disabled. In XZ Utils 5.4.x
# and older, configure checked for clock_gettime() only when using pthreads.
# This way non-threaded builds of liblzma didn't get a useless dependency on
# librt which further had a dependency on libpthread. Avoiding these was
# useful when a small build was needed, for example, for initramfs use.
#
# The above reasoning is thoroughly obsolete: On GNU/Linux, librt hasn't
# been needed for clock_gettime() since glibc 2.17 (2012-12-25).
# Solaris 10 needs librt but Solaris 11 doesn't anymore.
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_CHECK_FUNCS([clock_gettime])
AC_CHECK_DECL([CLOCK_MONOTONIC], [AC_DEFINE([HAVE_CLOCK_MONOTONIC], [1],
[Define to 1 if 'CLOCK_MONOTONIC' is declared in <time.h>.])], [],
[[#include <time.h>]])
# Find the best function to set timestamps. # Find the best function to set timestamps.
AC_CHECK_FUNCS([futimens futimes futimesat utimes _futime utime], [break]) AC_CHECK_FUNCS([futimens futimes futimesat utimes _futime utime], [break])