Skip to content

Commit 5cabda7

Browse files
authored
Merge pull request #2117 from martin-frbg/issue2114
Fix errors in cpu affinity setup with glibc 2.6
2 parents 6a8b426 + a6a8cc2 commit 5cabda7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

driver/others/init.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,14 @@ void gotoblas_affinity_init(void) {
857857
common -> shmid = pshmid;
858858

859859
if (common -> magic != SH_MAGIC) {
860+
861+
#if defined(__GLIBC_PREREQ)
862+
#if __GLIBC_PREREQ(2, 7)
860863
cpu_set_t *cpusetp;
864+
#else
865+
cpu_set_t cpuset;
866+
#endif
867+
#endif
861868
int nums;
862869
int ret;
863870

@@ -890,19 +897,19 @@ void gotoblas_affinity_init(void) {
890897
}
891898
CPU_FREE(cpusetp);
892899
#else
893-
ret = sched_getaffinity(0,sizeof(cpu_set_t), cpusetp);
900+
ret = sched_getaffinity(0,sizeof(cpu_set_t), &cpuset);
894901
if (ret!=0) {
895902
common->num_procs = nums;
896903
} else {
897904
#if !__GLIBC_PREREQ(2, 6)
898905
int i;
899906
int n = 0;
900907
for (i=0;i<nums;i++)
901-
if (CPU_ISSET(i,cpusetp)) n++;
908+
if (CPU_ISSET(i,&cpuset)) n++;
902909
common->num_procs = n;
903910
}
904911
#else
905-
common->num_procs = CPU_COUNT(sizeof(cpu_set_t),cpusetp);
912+
common->num_procs = CPU_COUNT(&cpuset);
906913
}
907914
#endif
908915

0 commit comments

Comments
 (0)