mirror of https://git.tukaani.org/xz.git
Support HW_PHYSMEM64
This commit is contained in:
parent
ae82dde5d9
commit
b317b218e2
|
@ -59,19 +59,27 @@ physmem(void)
|
||||||
ret = (uint64_t)(pagesize) * (uint64_t)(pages);
|
ret = (uint64_t)(pagesize) * (uint64_t)(pages);
|
||||||
|
|
||||||
#elif defined(HAVE_PHYSMEM_SYSCTL)
|
#elif defined(HAVE_PHYSMEM_SYSCTL)
|
||||||
int name[2] = { CTL_HW, HW_PHYSMEM };
|
int name[2] = {
|
||||||
|
CTL_HW,
|
||||||
|
#ifdef HW_PHYSMEM64
|
||||||
|
HW_PHYSMEM64
|
||||||
|
#else
|
||||||
|
HW_PHYSMEM
|
||||||
|
#endif
|
||||||
|
};
|
||||||
union {
|
union {
|
||||||
unsigned long ul;
|
uint32_t u32;
|
||||||
unsigned int ui;
|
uint64_t u64;
|
||||||
} mem;
|
} mem;
|
||||||
size_t mem_ptr_size = sizeof(mem.ul);
|
size_t mem_ptr_size = sizeof(mem.u64);
|
||||||
if (!sysctl(name, 2, &mem.ul, &mem_ptr_size, NULL, NULL)) {
|
if (!sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, NULL)) {
|
||||||
// Some systems use unsigned int as the "return value".
|
// IIRC, 64-bit "return value" is possible on some 64-bit
|
||||||
// This makes a difference on 64-bit boxes.
|
// BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64),
|
||||||
if (mem_ptr_size == sizeof(mem.ul))
|
// so support both.
|
||||||
ret = mem.ul;
|
if (mem_ptr_size == sizeof(mem.u64))
|
||||||
else if (mem_ptr_size == sizeof(mem.ui))
|
ret = mem.u64;
|
||||||
ret = mem.ui;
|
else if (mem_ptr_size == sizeof(mem.u32))
|
||||||
|
ret = mem.u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_PHYSMEM_SYSINFO)
|
#elif defined(HAVE_PHYSMEM_SYSINFO)
|
||||||
|
|
Loading…
Reference in New Issue