On Wed, Feb 28, 2018 at 08:22:57AM -0700, Brian Paul wrote: > On 02/28/2018 03:19 AM, Jonathan Gray wrote: > > OpenBSD, FreeBSD, NetBSD and DragonFlyBSD all have clock_gettime() > > so use it when PIPE_OS_BSD is defined. > > > > Signed-off-by: Jonathan Gray <[email protected]> > > --- > > src/util/os_time.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/util/os_time.c b/src/util/os_time.c > > index 72dc7e49c0..ac488b2287 100644 > > --- a/src/util/os_time.c > > +++ b/src/util/os_time.c > > @@ -55,7 +55,7 @@ > > int64_t > > os_time_get_nano(void) > > { > > -#if defined(PIPE_OS_LINUX) > > +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) > > struct timespec tv; > > clock_gettime(CLOCK_MONOTONIC, &tv); > > > > LGTM. > Reviewed-by: Brian Paul <[email protected]>
Thanks, there is also u_thread_get_time_nano(). I tried having autoconf do AC_CHECK_FUNC for pthread_getcpuclockid() and setting a define if it was found but couldn't seem to get the pthread linkage in the test to work properly. So for now in my local tree I have the diff below. pthread_getcpuclockid() is available on OpenBSD https://man.openbsd.org/pthread_getcpuclockid FreeBSD https://www.freebsd.org/cgi/man.cgi?query=pthread_getcpuclockid NetBSD http://netbsd.gw.com/cgi-bin/man-cgi?pthread_getcpuclockid++NetBSD-current DragonFly https://leaf.dragonflybsd.org/cgi/web-man?command=pthread_getcpuclockid§ion=ANY Cygwin https://cygwin.com/cygwin-api/compatibility.html#std-susv4 but not macos and solaris? diff --git a/src/util/u_thread.h b/src/util/u_thread.h index 8c6e0bdc59..4f559e5c8f 100644 --- a/src/util/u_thread.h +++ b/src/util/u_thread.h @@ -71,21 +71,21 @@ static inline void u_thread_setname( const char *name ) } /* * Thread statistics. */ /* Return the time of a thread's CPU time clock. */ static inline int64_t u_thread_get_time_nano(thrd_t thread) { -#if defined(__linux__) && defined(HAVE_PTHREAD) +#if defined(HAVE_PTHREAD) struct timespec ts; clockid_t cid; pthread_getcpuclockid(thread, &cid); clock_gettime(cid, &ts); return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec; #else return 0; #endif } _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
