Add sched_getcpu implementation for pre-2.6 glibc
Fixes #1210, compilation on RHEL5 with affinity enabled
This commit is contained in:
parent
482015f8d6
commit
c1cf62d2c0
|
@ -354,6 +354,24 @@ static int numa_check(void) {
|
||||||
return common -> num_nodes;
|
return common -> num_nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__GLIBC_PREREQ)
|
||||||
|
#if !__GLIBC_PREREQ(2, 6)
|
||||||
|
int sched_getcpu(void)
|
||||||
|
{
|
||||||
|
int cpu;
|
||||||
|
FILE *fp = NULL;
|
||||||
|
if ( (fp = fopen("/proc/self/stat", "r")) == NULL)
|
||||||
|
return -1;
|
||||||
|
if ( fscanf( fp, "%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%d", &cpu) != 1) {
|
||||||
|
fclose (fp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fclose (fp);
|
||||||
|
return(cpu);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static void numa_mapping(void) {
|
static void numa_mapping(void) {
|
||||||
|
|
||||||
int node, cpu, core;
|
int node, cpu, core;
|
||||||
|
@ -808,7 +826,6 @@ void gotoblas_affinity_init(void) {
|
||||||
common -> shmid = pshmid;
|
common -> shmid = pshmid;
|
||||||
|
|
||||||
if (common -> magic != SH_MAGIC) {
|
if (common -> magic != SH_MAGIC) {
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Shared Memory Initialization.\n");
|
fprintf(stderr, "Shared Memory Initialization.\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue