[PATCH:intel-gpu-tools 3/6] Use sched_yield if pthread_yield is not available
Alan Coopersmith
alan.coopersmith at oracle.com
Fri Jan 6 14:37:18 PST 2012
Despite the name implying it's a standard part of the POSIX threads API,
pthread_yield is actually non-standard and not entirely portable. For
systems like Solaris that don't have it, fall back to sched_yield.
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
configure.ac | 1 +
tests/gem_fence_thrash.c | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 197c622..5fe993c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,7 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
# Checks for functions, headers, structures, etc.
+AC_CHECK_FUNCS([pthread_yield])
AC_CHECK_HEADERS([termios.h])
AC_CHECK_MEMBERS([struct sysinfo.totalram],[],[],[AC_INCLUDES_DEFAULT
#include <sys/sysinfo.h>
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 8ed4e08..22c1e4b 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -26,6 +26,8 @@
*
*/
+#include "config.h"
+
#define _GNU_SOURCE
#include <unistd.h>
@@ -110,7 +112,11 @@ bo_copy (void *_arg)
for (n = 0; n < 1000; n++) {
memcpy (a, b, OBJECT_SIZE);
+#ifdef HAVE_PTHREAD_YIELD
pthread_yield ();
+#else
+ sched_yield ();
+#endif
}
return NULL;
--
1.7.3.2
More information about the xorg-devel
mailing list