OSDN Git Service

util: try to fix the Android and MacOS build
authorMarek Olšák <marek.olsak@amd.com>
Sun, 9 Sep 2018 01:02:18 +0000 (21:02 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 10 Sep 2018 18:49:07 +0000 (14:49 -0400)
Bionic does not have pthread_setaffinity_np.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107869
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/util/u_thread.h

index ec0d9a7..eee6f3c 100644 (file)
@@ -36,6 +36,9 @@
 #include <signal.h>
 #endif
 
+#if defined(HAVE_PTHREAD) && !defined(ANDROID) && !defined(__APPLE__)
+#define HAVE_PTHREAD_SETAFFINITY
+#endif
 
 static inline thrd_t u_thread_create(int (*routine)(void *), void *param)
 {
@@ -83,7 +86,7 @@ static inline void u_thread_setname( const char *name )
 static inline void
 util_pin_thread_to_L3(thrd_t thread, unsigned L3_index, unsigned cores_per_L3)
 {
-#if defined(HAVE_PTHREAD)
+#if defined(HAVE_PTHREAD_SETAFFINITY)
    cpu_set_t cpuset;
 
    CPU_ZERO(&cpuset);
@@ -103,7 +106,7 @@ util_pin_thread_to_L3(thrd_t thread, unsigned L3_index, unsigned cores_per_L3)
 static inline int
 util_get_L3_for_pinned_thread(thrd_t thread, unsigned cores_per_L3)
 {
-#if defined(HAVE_PTHREAD)
+#if defined(HAVE_PTHREAD_SETAFFINITY)
    cpu_set_t cpuset;
 
    if (pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset) == 0) {