Fix declarations of cpuset(p)
This commit is contained in:
parent
aab2aaa360
commit
cd6425add2
|
@ -198,40 +198,48 @@ int get_num_procs(void);
|
||||||
#else
|
#else
|
||||||
int get_num_procs(void) {
|
int get_num_procs(void) {
|
||||||
static int nums = 0;
|
static int nums = 0;
|
||||||
cpu_set_t *cpusetp;
|
cpu_set_t cpuset,*cpusetp;
|
||||||
size_t size;
|
size_t size;
|
||||||
int ret;
|
int ret;
|
||||||
int i,n;
|
#if !__GLIBC_PREREQ(2, 7)
|
||||||
|
int i;
|
||||||
|
#if !__GLIBC_PREREQ(2, 6)
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF);
|
if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF);
|
||||||
#if !defined(OS_LINUX)
|
#if !defined(OS_LINUX)
|
||||||
return nums;
|
return nums;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__GLIBC_PREREQ)
|
#if !defined(__GLIBC_PREREQ)
|
||||||
return nums;
|
return nums;
|
||||||
#else
|
#else
|
||||||
#if !__GLIBC_PREREQ(2, 3)
|
#if !__GLIBC_PREREQ(2, 3)
|
||||||
return nums;
|
return nums;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !__GLIBC_PREREQ(2, 7)
|
#if !__GLIBC_PREREQ(2, 7)
|
||||||
ret = sched_getaffinity(0,sizeof(cpusetp), cpusetp);
|
ret = sched_getaffinity(0,sizeof(cpuset), &cpuset);
|
||||||
if (ret!=0) return nums;
|
if (ret!=0) return nums;
|
||||||
n=0;
|
n=0;
|
||||||
#if !__GLIBC_PREREQ(2, 6)
|
#if !__GLIBC_PREREQ(2, 6)
|
||||||
for (i=0;i<nums;i++)
|
for (i=0;i<nums;i++)
|
||||||
if (CPU_ISSET(i,cpusetp)) n++;
|
if (CPU_ISSET(i,cpuset)) n++;
|
||||||
nums=n;
|
nums=n;
|
||||||
#else
|
#else
|
||||||
nums = CPU_COUNT(sizeof(cpusetp),cpusetp);
|
nums = CPU_COUNT(sizeof(cpuset),&cpuset);
|
||||||
#endif
|
#endif
|
||||||
return nums;
|
return nums;
|
||||||
#else
|
#else
|
||||||
cpusetp = CPU_ALLOC(nums);
|
cpusetp = CPU_ALLOC(nums);
|
||||||
if (cpusetp == NULL) return nums;
|
if (cpusetp == NULL) {
|
||||||
|
return nums;
|
||||||
|
}
|
||||||
|
cpuset = *cpusetp;
|
||||||
size = CPU_ALLOC_SIZE(nums);
|
size = CPU_ALLOC_SIZE(nums);
|
||||||
ret = sched_getaffinity(0,sizeof(cpusetp),cpusetp);
|
ret = sched_getaffinity(0,sizeof(cpuset),&cpuset);
|
||||||
if (ret!=0) {
|
if (ret!=0) {
|
||||||
CPU_FREE(cpusetp);
|
CPU_FREE(cpusetp);
|
||||||
return nums;
|
return nums;
|
||||||
|
@ -1712,41 +1720,50 @@ void goto_set_num_threads(int num_threads) {};
|
||||||
int get_num_procs(void);
|
int get_num_procs(void);
|
||||||
#else
|
#else
|
||||||
int get_num_procs(void) {
|
int get_num_procs(void) {
|
||||||
|
|
||||||
static int nums = 0;
|
static int nums = 0;
|
||||||
cpu_set_t *cpusetp;
|
cpu_set_t cpuset,*cpusetp;
|
||||||
size_t size;
|
size_t size;
|
||||||
int ret;
|
int ret;
|
||||||
int i,n;
|
#if !__GLIBC_PREREQ(2, 7)
|
||||||
|
int i;
|
||||||
|
#if !__GLIBC_PREREQ(2, 6)
|
||||||
|
int n;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF);
|
if (!nums) nums = sysconf(_SC_NPROCESSORS_CONF);
|
||||||
#if !defined(OS_LINUX)
|
#if !defined(OS_LINUX)
|
||||||
return nums;
|
return nums;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__GLIBC_PREREQ)
|
#if !defined(__GLIBC_PREREQ)
|
||||||
return nums;
|
return nums;
|
||||||
#else
|
#else
|
||||||
#if !__GLIBC_PREREQ(2, 3)
|
#if !__GLIBC_PREREQ(2, 3)
|
||||||
return nums;
|
return nums;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !__GLIBC_PREREQ(2, 7)
|
#if !__GLIBC_PREREQ(2, 7)
|
||||||
ret = sched_getaffinity(0,sizeof(cpusetp), cpusetp);
|
ret = sched_getaffinity(0,sizeof(cpuset), &cpuset);
|
||||||
if (ret!=0) return nums;
|
if (ret!=0) return nums;
|
||||||
n=0;
|
n=0;
|
||||||
#if !__GLIBC_PREREQ(2, 6)
|
#if !__GLIBC_PREREQ(2, 6)
|
||||||
for (i=0;i<nums;i++)
|
for (i=0;i<nums;i++)
|
||||||
if (CPU_ISSET(i,cpusetp)) n++;
|
if (CPU_ISSET(i,cpuset)) n++;
|
||||||
nums=n;
|
nums=n;
|
||||||
#else
|
#else
|
||||||
nums = CPU_COUNT(sizeof(cpusetp),cpusetp);
|
nums = CPU_COUNT(sizeof(cpuset),&cpuset);
|
||||||
#endif
|
#endif
|
||||||
return nums;
|
return nums;
|
||||||
#else
|
#else
|
||||||
cpusetp = CPU_ALLOC(nums);
|
cpusetp = CPU_ALLOC(nums);
|
||||||
if (cpusetp == NULL) return nums;
|
if (cpusetp == NULL) {
|
||||||
|
return nums;
|
||||||
|
}
|
||||||
|
cpuset = *cpusetp;
|
||||||
size = CPU_ALLOC_SIZE(nums);
|
size = CPU_ALLOC_SIZE(nums);
|
||||||
ret = sched_getaffinity(0,sizeof(cpusetp),cpusetp);
|
ret = sched_getaffinity(0,sizeof(cpuset),&cpuset);
|
||||||
if (ret!=0) {
|
if (ret!=0) {
|
||||||
CPU_FREE(cpusetp);
|
CPU_FREE(cpusetp);
|
||||||
return nums;
|
return nums;
|
||||||
|
|
Loading…
Reference in New Issue