1 $NetBSD: patch-src_util_u__thread.h,v 1.5 2022/03/13 15:50:05 tnn Exp $
3 Oracle Solaris has pthread_setname_np. illumos does not.
4 (actually, newer Illumos does have it, but never mind.)
6 Don't hard error when there's no pthread_setname_np.
8 handle NetBSD-style pthread_setaffinity_np(3)
10 --- src/util/u_thread.h.orig 2021-08-04 18:49:29.374474500 +0000
11 +++ src/util/u_thread.h
12 @@ -169,8 +169,32 @@ util_set_thread_affinity(thrd_t thread,
13 unsigned num_mask_bits)
15 #if defined(HAVE_PTHREAD_SETAFFINITY)
17 +# if defined(__NetBSD__)
19 + cpuset = cpuset_create();
23 + if (pthread_getaffinity_np(thread, cpuset_size(cpuset), cpuset) != 0)
26 + memset(old_mask, 0, num_mask_bits / 8);
27 + for (unsigned i = 0; i < num_mask_bits && i < CPU_SETSIZE; i++) {
28 + if (cpuset_isset(i, cpuset))
29 + old_mask[i / 32] |= 1u << (i % 32);
33 + cpuset_zero(cpuset);
34 + for (unsigned i = 0; i < num_mask_bits && i < CPU_SETSIZE; i++) {
35 + if (mask[i / 32] & (1u << (i % 32)))
36 + cpuset_set(i, cpuset);
38 + int err = pthread_setaffinity_np(thread, cpuset_size(cpuset), cpuset);
39 + cpuset_destroy(cpuset);
44 if (pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset) != 0)
46 @@ -188,7 +212,7 @@ util_set_thread_affinity(thrd_t thread,
49 return pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset) == 0;
52 #elif defined(_WIN32) && !defined(__CYGWIN__)
53 DWORD_PTR m = mask[0];
55 @@ -242,7 +266,7 @@ util_set_current_thread_affinity(const u
57 util_thread_get_time_nano(thrd_t thread)
59 -#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__)
60 +#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__) && !defined(__sun)