From 0567fd7bf2028058d1ad9bbd027d1ed45ed990a5 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut 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. SVN revision: 41118 --- legacy/evas/src/lib/engines/common/evas_cpu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/legacy/evas/src/lib/engines/common/evas_cpu.c b/legacy/evas/src/lib/engines/common/evas_cpu.c index d4b00a06ec..3e323a3e1e 100644 --- a/legacy/evas/src/lib/engines/common/evas_cpu.c +++ b/legacy/evas/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;