Commit a52459b3 authored by Jan Beich's avatar Jan Beich Committed by Jean-Baptiste Kempf

checkasm: replace gettimeofday with clock_gettime

tests/checkasm/checkasm.c:55:5: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
    gettimeofday(&tv, NULL);
    ^
parent cf4b381a
......@@ -113,11 +113,23 @@ if host_machine.system() == 'windows'
# On Windows, we use a compatibility layer to emulate pthread
thread_dependency = []
thread_compat_dep = declare_dependency(sources : files('src/win32/thread.c'))
rt_dependency = []
else
thread_dependency = dependency('threads')
thread_compat_dep = []
endif
rt_dependency = []
if cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args)
cdata.set('HAVE_CLOCK_GETTIME', 1)
else
rt_dependency = cc.find_library('rt', required: false)
if not cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args, dependencies : rt_dependency)
error('clock_gettime not found')
endif
cdata.set('HAVE_CLOCK_GETTIME', 1)
endif
endif
# Header checks
......
......@@ -45,15 +45,24 @@ static unsigned get_seed(void) {
#else
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#ifdef __APPLE__
#include <mach/mach_time.h>
#endif
#define COLOR_RED 1
#define COLOR_GREEN 2
#define COLOR_YELLOW 3
static unsigned get_seed(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return (unsigned) (tv.tv_usec + tv.tv_sec * 1000000);
#ifdef __APPLE__
mach_timebase_info_data_t info;
mach_timebase_info(&info);
return (unsigned) (mach_absolute_time() * info.numer / info.denom);
#elif defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (unsigned) (1000000000ULL * ts.tv_sec + ts.tv_nsec);
#endif
}
#endif
......
......@@ -90,7 +90,7 @@ if is_asm_enabled
include_directories: dav1d_inc_dirs,
c_args: [stackalign_flag, stackrealign_flag],
build_by_default: false,
dependencies : [thread_dependency, m_lib],
dependencies : [thread_dependency, rt_dependency, m_lib],
)
test('checkasm', checkasm, is_parallel: false)
......
......@@ -69,19 +69,6 @@ endif
# Configuratin data for cli_config.h
cli_cdata = configuration_data()
rt_dependency = []
if host_machine.system() != 'windows'
if cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args)
cli_cdata.set('HAVE_CLOCK_GETTIME', 1)
else
rt_dependency = cc.find_library('rt', required: false)
if not cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args, dependencies : rt_dependency)
error('clock_gettime not found')
endif
cli_cdata.set('HAVE_CLOCK_GETTIME', 1)
endif
endif
cli_config_h_target = configure_file(output: 'cli_config.h', configuration: cli_cdata)
# dav1d cli tool sources
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment