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
This commit is contained in:
Gustavo Sverzut Barbieri 2009-06-20 06:34:20 +00:00
parent 3871aed422
commit 0567fd7bf2
1 changed files with 6 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#ifndef _WIN32
#include <signal.h>
#include <setjmp.h>
#include <errno.h>
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;