mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Fix sysctl() usage.
This fixes build on *BSDs and Darwin. Thanks to Jukka Salmi for the patches. Richard Koch reported the problem too.
This commit is contained in:
parent
43f44160b1
commit
27414daadf
4 changed files with 4 additions and 4 deletions
|
@ -43,7 +43,7 @@ main(void)
|
||||||
int name[2] = { CTL_HW, HW_NCPU };
|
int name[2] = { CTL_HW, HW_NCPU };
|
||||||
int cpus;
|
int cpus;
|
||||||
size_t cpus_size = sizeof(cpus);
|
size_t cpus_size = sizeof(cpus);
|
||||||
sysctl(name, 2, &cpus, &cpus_size, NULL, NULL);
|
sysctl(name, 2, &cpus, &cpus_size, NULL, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])], [
|
]])], [
|
||||||
|
|
|
@ -45,7 +45,7 @@ main(void)
|
||||||
int name[2] = { CTL_HW, HW_PHYSMEM };
|
int name[2] = { CTL_HW, HW_PHYSMEM };
|
||||||
unsigned long mem;
|
unsigned long mem;
|
||||||
size_t mem_ptr_size = sizeof(mem);
|
size_t mem_ptr_size = sizeof(mem);
|
||||||
sysctl(name, 2, &mem, &mem_ptr_size, NULL, NULL);
|
sysctl(name, 2, &mem, &mem_ptr_size, NULL, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
]])], [
|
]])], [
|
||||||
|
|
|
@ -40,7 +40,7 @@ cpucores(void)
|
||||||
int name[2] = { CTL_HW, HW_NCPU };
|
int name[2] = { CTL_HW, HW_NCPU };
|
||||||
int cpus;
|
int cpus;
|
||||||
size_t cpus_size = sizeof(cpus);
|
size_t cpus_size = sizeof(cpus);
|
||||||
if (!sysctl(name, &cpus, &cpus_size, NULL, NULL)
|
if (!sysctl(name, 2, &cpus, &cpus_size, NULL, 0)
|
||||||
&& cpus_size == sizeof(cpus) && cpus > 0)
|
&& cpus_size == sizeof(cpus) && cpus > 0)
|
||||||
ret = (uint32_t)(cpus);
|
ret = (uint32_t)(cpus);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -104,7 +104,7 @@ physmem(void)
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
} mem;
|
} mem;
|
||||||
size_t mem_ptr_size = sizeof(mem.u64);
|
size_t mem_ptr_size = sizeof(mem.u64);
|
||||||
if (!sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, NULL)) {
|
if (!sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, 0)) {
|
||||||
// IIRC, 64-bit "return value" is possible on some 64-bit
|
// IIRC, 64-bit "return value" is possible on some 64-bit
|
||||||
// BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64),
|
// BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64),
|
||||||
// so support both.
|
// so support both.
|
||||||
|
|
Loading…
Reference in a new issue