Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
SYSTEM_FUNCS="
aligned_malloc
+ clock_gettime
closesocket
CommandLineToArgvW
CoTaskMemFree
check_func ${malloc_prefix}memalign && enable memalign
check_func ${malloc_prefix}posix_memalign && enable posix_memalign
+check_cpp_condition unistd.h "defined(_POSIX_MONOTONIC_CLOCK)" &&
+ check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt; }
+
check_func fcntl
check_func fork
check_func gethrtime
#include <stddef.h>
#include <stdint.h>
#include <time.h>
-#if HAVE_GETTIMEOFDAY
+#if HAVE_CLOCK_GETTIME
+#include <time.h>
+#elif HAVE_GETTIMEOFDAY
#include <sys/time.h>
#endif
#if HAVE_UNISTD_H
int64_t av_gettime(void)
{
-#if HAVE_GETTIMEOFDAY
+#if HAVE_CLOCK_GETTIME
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (int64_t)ts.tv_sec * 100000 + ts.tv_nsec / 1000;
+#elif HAVE_GETTIMEOFDAY
struct timeval tv;
gettimeofday(&tv, NULL);
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;