51 lines
1.0 KiB
Diff
51 lines
1.0 KiB
Diff
--- driver/others/memory.c.orig
|
|
+++ driver/others/memory.c
|
|
@@ -185,47 +185,8 @@
|
|
#else
|
|
int get_num_procs(void) {
|
|
static int nums = 0;
|
|
-cpu_set_t *cpusetp;
|
|
-size_t size;
|
|
-int ret;
|
|
-int i,n;
|
|
-
|
|
if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF);
|
|
-#if !defined(OS_LINUX)
|
|
return nums;
|
|
-#endif
|
|
-
|
|
-#if !defined(__GLIBC_PREREQ)
|
|
- return nums;
|
|
-#else
|
|
- #if !__GLIBC_PREREQ(2, 3)
|
|
- return nums;
|
|
- #endif
|
|
-
|
|
- #if !__GLIBC_PREREQ(2, 7)
|
|
- ret = sched_getaffinity(0,sizeof(cpu_set_t), cpusetp);
|
|
- if (ret!=0) return nums;
|
|
- n=0;
|
|
- #if !__GLIBC_PREREQ(2, 6)
|
|
- for (i=0;i<nums;i++)
|
|
- if (CPU_ISSET(i,cpusetp)) n++;
|
|
- nums=n;
|
|
- #else
|
|
- nums = CPU_COUNT(sizeof(cpu_set_t),cpusetp);
|
|
- #endif
|
|
- return nums;
|
|
- #else
|
|
- cpusetp = CPU_ALLOC(nums);
|
|
- if (cpusetp == NULL) return nums;
|
|
- size = CPU_ALLOC_SIZE(nums);
|
|
- ret = sched_getaffinity(0,size,cpusetp);
|
|
- if (ret!=0) return nums;
|
|
- ret = CPU_COUNT_S(size,cpusetp);
|
|
- if (ret > 0 && ret < nums) nums = ret;
|
|
- CPU_FREE(cpusetp);
|
|
- return nums;
|
|
- #endif
|
|
-#endif
|
|
}
|
|
#endif
|
|
#endif
|