Skip to content

Commit

Permalink
util: drop HAVE_CLOCK_GETRES_MONOTONIC configure constant
Browse files Browse the repository at this point in the history
It doesn't provide a significant benefit over just trying the call.
It was added by 6bd3f08 for Hurd support.
  • Loading branch information
kgaillot authored and chrissie-c committed Feb 14, 2022
1 parent 1e67908 commit 354c0c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
15 changes: 1 addition & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -236,25 +236,12 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
]
)

# Checks for library functions
AX_SAVE_FLAGS
LIBS="$LIBS $rt_LIBS"
AC_MSG_CHECKING(for a working clock_getres(CLOCK_MONOTONIC, &ts))
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <time.h>]],
[[struct timespec ts; if(clock_getres(CLOCK_MONOTONIC, &ts)) return -1;]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([HAVE_CLOCK_GETRES_MONOTONIC], 1, [Define to 1 if clock_getres(CLOCK_MONOTONIC, &ts) works])
],
[
AC_MSG_RESULT([no])
]
)
AC_CHECK_FUNCS([clock_gettime])
AX_RESTORE_FLAGS


# Checks for library functions
AC_FUNC_CHOWN
AC_FUNC_FORK
AC_FUNC_MMAP
Expand Down
10 changes: 4 additions & 6 deletions lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,10 @@ qb_util_nano_monotonic_hz(void)
uint64_t nano_monotonic_hz;
struct timespec ts;

#if HAVE_CLOCK_GETRES_MONOTONIC
clock_getres(CLOCK_MONOTONIC, &ts);
#else
if (clock_getres(CLOCK_REALTIME, &ts) != 0)
qb_util_perror(LOG_ERR,"CLOCK_REALTIME");
#endif
if ((clock_getres(CLOCK_MONOTONIC, &ts) != 0)
&& (clock_getres(CLOCK_REALTIME, &ts) != 0)) {
qb_util_perror(LOG_ERR, "couldn't get clock resolution");
}

nano_monotonic_hz =
QB_TIME_NS_IN_SEC / ((ts.tv_sec * QB_TIME_NS_IN_SEC) + ts.tv_nsec);
Expand Down

0 comments on commit 354c0c2

Please sign in to comment.