Skip to content

Commit a6a8cc2

Browse files
authored
Fix errors in cpu enumeration with glibc 2.6
for #2114
1 parent 91943b7 commit a6a8cc2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

driver/others/init.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ int gotoblas_set_affinity(int pos) {
765765

766766
int mynode = 1;
767767

768-
/* if number of threads is larger than inital condition */
768+
/* if number of threads is larger than initial condition */
769769
if (pos < 0) {
770770
sched_setaffinity(0, sizeof(cpu_orig_mask), &cpu_orig_mask[0]);
771771
return 0;
@@ -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)