From 0e36f73a72507d8e6afe9a4842d38f6c8f5562a1 Mon Sep 17 00:00:00 2001 From: barbieri Date: Sat, 20 Jun 2009 06:34:20 +0000 Subject: [PATCH] improve sched_getaffinity() usage. * handle error code and print out error message, this should remove invalid access traces from valgrind. * give "0" as pid to get self affinity, this is documented in the man page. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@41118 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/engines/common/evas_cpu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/engines/common/evas_cpu.c b/src/lib/engines/common/evas_cpu.c index d4b00a0..3e323a3 100644 --- a/src/lib/engines/common/evas_cpu.c +++ b/src/lib/engines/common/evas_cpu.c @@ -11,6 +11,7 @@ #ifndef _WIN32 #include #include +#include static sigjmp_buf detect_buf; #endif @@ -255,7 +256,11 @@ evas_common_cpu_count(void) if (cpus != 0) return cpus; - sched_getaffinity(getpid(), sizeof(cpu), &cpu); + if (sched_getaffinity(0, sizeof(cpu), &cpu) != 0) + { + printf("[Evas] could not get cpu affinity: %s\n", strerror(errno)); + return 1; + } for (i = 0; i < TH_MAX; i++) { if (CPU_ISSET(i, &cpu)) cpus = i + 1; -- 2.7.4