summaryrefslogtreecommitdiff
path: root/www/firefox/patches
diff options
context:
space:
mode:
authorryoon <ryoon>2013-11-05 14:20:41 +0000
committerryoon <ryoon>2013-11-05 14:20:41 +0000
commit8fb15a4d804250653c73e8e8ef43177cc39e5736 (patch)
treec88bfd135dec216e6da345a94c145397b38a14db /www/firefox/patches
parent99541d51115325441e2d8c8d397a4f82f3176fe8 (diff)
downloadpkgsrc-8fb15a4d804250653c73e8e8ef43177cc39e5736.tar.gz
Bump PKGREVISION
Fix cpuset(3) usage. The patch is from rmind@. Thank you.
Diffstat (limited to 'www/firefox/patches')
-rw-r--r--www/firefox/patches/patch-gfx_skia_src_utils_SkThreadUtils__pthread__linux.cpp105
1 files changed, 62 insertions, 43 deletions
diff --git a/www/firefox/patches/patch-gfx_skia_src_utils_SkThreadUtils__pthread__linux.cpp b/www/firefox/patches/patch-gfx_skia_src_utils_SkThreadUtils__pthread__linux.cpp
index c2369013213..c5cf9f32fb9 100644
--- a/www/firefox/patches/patch-gfx_skia_src_utils_SkThreadUtils__pthread__linux.cpp
+++ b/www/firefox/patches/patch-gfx_skia_src_utils_SkThreadUtils__pthread__linux.cpp
@@ -1,68 +1,87 @@
-$NetBSD: patch-gfx_skia_src_utils_SkThreadUtils__pthread__linux.cpp,v 1.1 2013/11/02 22:57:55 ryoon Exp $
+$NetBSD: patch-gfx_skia_src_utils_SkThreadUtils__pthread__linux.cpp,v 1.2 2013/11/05 14:20:41 ryoon Exp $
--- gfx/skia/src/utils/SkThreadUtils_pthread_linux.cpp.orig 2013-10-25 22:27:18.000000000 +0000
+++ gfx/skia/src/utils/SkThreadUtils_pthread_linux.cpp
-@@ -21,11 +21,19 @@
+@@ -12,26 +12,47 @@
+ #include "SkThreadUtils.h"
+ #include "SkThreadUtils_pthread.h"
+
++#include <unistd.h>
+ #include <pthread.h>
+ #ifdef __FreeBSD__
+ #include <pthread_np.h>
+ #endif
++#ifdef __NetBSD__
++#include <sched.h>
++#endif
+
+ #if defined(__FreeBSD__) || defined(__NetBSD__)
#define cpu_set_t cpuset_t
#endif
-+#if defined(__NetBSD__)
-+#define CPU_SETSIZE 1024
-+#endif
-+
- #ifndef CPU_COUNT
+-#ifndef CPU_COUNT
++#if !defined(CPU_COUNT) && !defined(__NetBSD__)
static int CPU_COUNT(cpu_set_t *set) {
int count = 0;
for (int i = 0; i < CPU_SETSIZE; i++) {
-+#if defined(__NetBSD__)
-+ if (cpuset_isset(i, set)) {
-+#else
if (CPU_ISSET(i, set)) {
-+#endif
count++;
- }
+- }
++ }
++ }
++ return count;
++}
++#endif
++
++#if defined(__NetBSD__)
++
++#define CPU_ISSET(c, s) cpuset_isset(c, s)
++
++static int CPU_COUNT(cpuset_t *set) {
++ static const int ncpu = sysconf(_SC_NPROCESSORS_CONF);
++ int count = 0;
++
++ for (int i = 0; i < ncpu; i++) {
++ if (cpuset_isset(i, set)) {
++ count++;
++ }
}
-@@ -36,7 +44,11 @@ static int CPU_COUNT(cpu_set_t *set) {
+ return count;
+ }
+-#endif /* !CPU_COUNT */
++#endif
+
static int nth_set_cpu(unsigned int n, cpu_set_t* cpuSet) {
n %= CPU_COUNT(cpuSet);
- for (unsigned int setCpusSeen = 0, currentCpu = 0; true; ++currentCpu) {
-+#if defined(__NetBSD__)
-+ if (cpuset_isset(currentCpu, cpuSet)) {
-+#else
- if (CPU_ISSET(currentCpu, cpuSet)) {
-+#endif
- ++setCpusSeen;
- if (setCpusSeen > n) {
- return currentCpu;
-@@ -51,15 +63,31 @@ bool SkThread::setProcessorAffinity(unsi
+@@ -51,6 +72,7 @@ bool SkThread::setProcessorAffinity(unsi
return false;
}
-+#if defined(__NetBSD__)
-+ cpu_set_t *parentCpuset;
-+ if (0 != pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t *), parentCpuset)) {
-+#else
++#if !defined(__NetBSD__)
cpu_set_t parentCpuset;
if (0 != pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &parentCpuset)) {
-+#endif
return false;
- }
-
-+#if defined(__NetBSD__)
-+ cpu_set_t *cpuset;
-+ cpuset_zero(cpuset);
-+ cpuset_set(nth_set_cpu(processor, parentCpuset), cpuset);
-+#else
- cpu_set_t cpuset;
- CPU_ZERO(&cpuset);
- CPU_SET(nth_set_cpu(processor, &parentCpuset), &cpuset);
-+#endif
+@@ -62,4 +84,23 @@ bool SkThread::setProcessorAffinity(unsi
return 0 == pthread_setaffinity_np(pthreadData->fPThread,
-+#if defined(__NetBSD__)
-+ sizeof(cpu_set_t *),
-+ cpuset);
-+#else
sizeof(cpu_set_t),
&cpuset);
++#else
++ cpuset_t *cpuset = cpuset_create();
++ if (!cpuset) {
++ return false;
++ }
++ size_t csize = cpuset_size(cpuset);
++ if (0 != pthread_getaffinity_np(pthread_self(), csize, cpuset)) {
++ cpuset_destroy(cpuset);
++ return false;
++ }
++
++ int nthcpu = nth_set_cpu(processor, cpuset);
++ cpuset_zero(cpuset);
++ cpuset_set(nthcpu, cpuset);
++
++ bool ok = 0 == pthread_setaffinity_np(pthreadData->fPThread, csize, cpuset);
++ cpuset_destroy(cpuset);
++ return ok;
+#endif
}