pulseaudio: fix dependencies for openssl-3
[oi-userland.git] / components / x11 / mesa / patches / patch-src_util_u__thread.h.patch
blobfd5ef535cd928201833800904efe48efbac521dc
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)
16 - cpu_set_t cpuset;
17 +# if defined(__NetBSD__)
18 + cpu_set_t *cpuset;
19 + cpuset = cpuset_create();
20 + if (cpuset == NULL)
21 + return;
22 + if (old_mask) {
23 + if (pthread_getaffinity_np(thread, cpuset_size(cpuset), cpuset) != 0)
24 + return false;
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);
30 + }
31 + }
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);
37 + }
38 + int err = pthread_setaffinity_np(thread, cpuset_size(cpuset), cpuset);
39 + cpuset_destroy(cpuset);
40 + return err == 0;
41 +# else
42 + cpu_set_t cpuset;
43 if (old_mask) {
44 if (pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset) != 0)
45 return false;
46 @@ -188,7 +212,7 @@ util_set_thread_affinity(thrd_t thread,
47 CPU_SET(i, &cpuset);
49 return pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset) == 0;
51 +# endif
52 #elif defined(_WIN32) && !defined(__CYGWIN__)
53 DWORD_PTR m = mask[0];
55 @@ -242,7 +266,7 @@ util_set_current_thread_affinity(const u
56 static inline int64_t
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)
61 struct timespec ts;
62 clockid_t cid;