mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 13:40:13 +00:00
timespec_get compat
macOS 10.11 which we still use for backward-compatible mac builds doesn't have timespec_get function.
This commit is contained in:
@@ -322,6 +322,7 @@ fi
|
||||
|
||||
AC_CHECK_FUNCS(usleep)
|
||||
AC_CHECK_FUNCS(strtok_r)
|
||||
AC_CHECK_FUNCS(timespec_get)
|
||||
|
||||
AC_CHECK_FUNCS(drand48)
|
||||
if test $ac_cv_func_drand48 = no
|
||||
|
||||
6
src/tv.h
6
src/tv.h
@@ -72,9 +72,15 @@ typedef long long time_ns_t;
|
||||
#define NS_IN_SEC 1000000000LL
|
||||
#define NS_IN_US (NS_IN_SEC/US_IN_SEC)
|
||||
static inline time_ns_t get_time_in_ns() {
|
||||
#ifdef HAVE_TIMESPEC_GET
|
||||
struct timespec ts = { 0, 0 };
|
||||
timespec_get(&ts, TIME_UTC);
|
||||
return ts.tv_sec * NS_IN_SEC + ts.tv_nsec;
|
||||
#else
|
||||
struct timeval tv = { 0, 0 };
|
||||
gettimeofday(&tv, NULL);
|
||||
return tv.tv_sec * NS_IN_SEC + tv.tv_usec * NS_IN_US;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user