mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Build: No longer require HAVE_DECL_CLOCK_MONOTONIC to always be set.
Previously, if threading was enabled HAVE_DECL_CLOCK_MONOTONIC would always be set to 0 or 1. However, this macro was needed in xz so if xz was not built with threading and HAVE_DECL_CLOCK_MONOTONIC was not defined but HAVE_CLOCK_GETTIME was, it caused a warning during build. Now, HAVE_DECL_CLOCK_MONOTONIC has been renamed to HAVE_CLOCK_MONOTONIC and will only be set if it is 1.
This commit is contained in:
parent
6fc3e54679
commit
9e3cb514b5
4 changed files with 11 additions and 11 deletions
|
@ -154,13 +154,11 @@ if(NOT WIN32 AND NOT DEFINED HAVE_CLOCK_GETTIME)
|
||||||
endif()
|
endif()
|
||||||
if(HAVE_CLOCK_GETTIME)
|
if(HAVE_CLOCK_GETTIME)
|
||||||
# Check if CLOCK_MONOTONIC is available for clock_gettime().
|
# Check if CLOCK_MONOTONIC is available for clock_gettime().
|
||||||
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_DECL_CLOCK_MONOTONIC)
|
check_symbol_exists(CLOCK_MONOTONIC time.h HAVE_CLOCK_MONOTONIC)
|
||||||
|
|
||||||
# HAVE_DECL_CLOCK_MONOTONIC should always be defined to 0 or 1
|
|
||||||
# when clock_gettime is available.
|
|
||||||
add_compile_definitions(
|
add_compile_definitions(
|
||||||
HAVE_CLOCK_GETTIME
|
HAVE_CLOCK_GETTIME
|
||||||
HAVE_DECL_CLOCK_MONOTONIC=$<BOOL:"${HAVE_DECL_CLOCK_MONOTONIC}">
|
HAVE_CLOCK_MONOTONIC
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -184,7 +182,7 @@ else()
|
||||||
add_compile_definitions(MYTHREAD_POSIX)
|
add_compile_definitions(MYTHREAD_POSIX)
|
||||||
|
|
||||||
# Check if pthread_condattr_setclock() exists to use CLOCK_MONOTONIC.
|
# Check if pthread_condattr_setclock() exists to use CLOCK_MONOTONIC.
|
||||||
if(HAVE_DECL_CLOCK_MONOTONIC)
|
if(HAVE_CLOCK_MONOTONIC)
|
||||||
list(INSERT CMAKE_REQUIRED_LIBRARIES 0 "${CMAKE_THREAD_LIBS_INIT}")
|
list(INSERT CMAKE_REQUIRED_LIBRARIES 0 "${CMAKE_THREAD_LIBS_INIT}")
|
||||||
check_symbol_exists(pthread_condattr_setclock pthread.h
|
check_symbol_exists(pthread_condattr_setclock pthread.h
|
||||||
HAVE_PTHREAD_CONDATTR_SETCLOCK)
|
HAVE_PTHREAD_CONDATTR_SETCLOCK)
|
||||||
|
|
|
@ -638,7 +638,10 @@ case $enable_threads in
|
||||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||||
AC_SEARCH_LIBS([clock_gettime], [rt])
|
AC_SEARCH_LIBS([clock_gettime], [rt])
|
||||||
AC_CHECK_FUNCS([clock_gettime pthread_condattr_setclock])
|
AC_CHECK_FUNCS([clock_gettime pthread_condattr_setclock])
|
||||||
AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[#include <time.h>]])
|
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)
|
||||||
|
|
|
@ -219,8 +219,8 @@ static inline int
|
||||||
mythread_cond_init(mythread_cond *mycond)
|
mythread_cond_init(mythread_cond *mycond)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_CLOCK_GETTIME
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
// NOTE: HAVE_DECL_CLOCK_MONOTONIC is always defined to 0 or 1.
|
# if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && \
|
||||||
# if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && HAVE_DECL_CLOCK_MONOTONIC
|
defined(HAVE_CLOCK_MONOTONIC)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
pthread_condattr_t condattr;
|
pthread_condattr_t condattr;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include "private.h"
|
#include "private.h"
|
||||||
|
|
||||||
#if !(defined(HAVE_CLOCK_GETTIME) && HAVE_DECL_CLOCK_MONOTONIC)
|
#if !(defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_MONOTONIC))
|
||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -28,8 +28,7 @@ static uint64_t next_flush;
|
||||||
static uint64_t
|
static uint64_t
|
||||||
mytime_now(void)
|
mytime_now(void)
|
||||||
{
|
{
|
||||||
// NOTE: HAVE_DECL_CLOCK_MONOTONIC is always defined to 0 or 1.
|
#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_MONOTONIC)
|
||||||
#if defined(HAVE_CLOCK_GETTIME) && HAVE_DECL_CLOCK_MONOTONIC
|
|
||||||
// If CLOCK_MONOTONIC was available at compile time but for some
|
// If CLOCK_MONOTONIC was available at compile time but for some
|
||||||
// reason isn't at runtime, fallback to CLOCK_REALTIME which
|
// reason isn't at runtime, fallback to CLOCK_REALTIME which
|
||||||
// according to POSIX is mandatory for all implementations.
|
// according to POSIX is mandatory for all implementations.
|
||||||
|
|
Loading…
Reference in a new issue