Commit ff4d14e5 authored by Vinson Lee's avatar Vinson Lee
Browse files

util/u_thread: Check for pthread_getcpuclockid.



pthread_getcpuclockid is not available on macOS.
Suggested-by: Eric Engestrom's avatarEric Engestrom <eric.engestrom@intel.com>
Fixes: 4913215d

 ("util/u_thread: don't restrict u_thread_get_time_nano() to __linux__")
Signed-off-by: Vinson Lee's avatarVinson Lee <vlee@freedesktop.org>
parent dcb4230e
Pipeline #88018 passed with stages
in 17 minutes and 59 seconds
...@@ -68,6 +68,7 @@ LOCAL_CFLAGS += \ ...@@ -68,6 +68,7 @@ LOCAL_CFLAGS += \
-DHAVE___BUILTIN_CLZLL \ -DHAVE___BUILTIN_CLZLL \
-DHAVE___BUILTIN_UNREACHABLE \ -DHAVE___BUILTIN_UNREACHABLE \
-DHAVE_PTHREAD=1 \ -DHAVE_PTHREAD=1 \
-DHAVE_PTHREAD_GETCPUCLOCKID \
-DHAVE_DLADDR \ -DHAVE_DLADDR \
-DHAVE_DL_ITERATE_PHDR \ -DHAVE_DL_ITERATE_PHDR \
-DHAVE_LINUX_FUTEX_H \ -DHAVE_LINUX_FUTEX_H \
......
...@@ -1154,7 +1154,7 @@ foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h' ...@@ -1154,7 +1154,7 @@ foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h', 'dlfcn.h'
endif endif
endforeach endforeach
foreach f : ['strtof', 'mkostemp', 'timespec_get', 'memfd_create', 'random_r', 'flock', 'strtok_r'] foreach f : ['strtof', 'mkostemp', 'timespec_get', 'memfd_create', 'random_r', 'flock', 'strtok_r', 'pthread_getcpuclockid']
if cc.has_function(f) if cc.has_function(f)
pre_args += '-DHAVE_@0@'.format(f.to_upper()) pre_args += '-DHAVE_@0@'.format(f.to_upper())
endif endif
......
...@@ -384,6 +384,9 @@ def generate(env): ...@@ -384,6 +384,9 @@ def generate(env):
if check_functions(env, ['strtok_r']): if check_functions(env, ['strtok_r']):
cppdefines += ['HAVE_STRTOK_R'] cppdefines += ['HAVE_STRTOK_R']
if check_functions(env, ['pthread_getcpuclockid']):
cppdefines += ['HAVE_PTHREAD_GETCPUCLOCKID']
#FIXME: we should really be checking for the major()/minor() #FIXME: we should really be checking for the major()/minor()
# functions/macros in these headers, but check_functions()'s # functions/macros in these headers, but check_functions()'s
# SConf.CheckFunc() doesn't seem to support macros. # SConf.CheckFunc() doesn't seem to support macros.
......
...@@ -149,7 +149,7 @@ util_get_L3_for_pinned_thread(thrd_t thread, unsigned cores_per_L3) ...@@ -149,7 +149,7 @@ util_get_L3_for_pinned_thread(thrd_t thread, unsigned cores_per_L3)
static inline int64_t static inline int64_t
u_thread_get_time_nano(thrd_t thread) u_thread_get_time_nano(thrd_t thread)
{ {
#if defined(HAVE_PTHREAD) && !defined(__APPLE__) #if defined(HAVE_PTHREAD_GETCPUCLOCKID)
struct timespec ts; struct timespec ts;
clockid_t cid; clockid_t cid;
......
Supports Markdown
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