Libc: use caller integer width for return value of sysctl PHYSMEM
Return a value in the same width as provided by the caller of sysctl for PHYSMEM and USERMEM. This is to ensure that if a caller provides a 64-bit integer, a 64-bit value will be returned for 32-bit machines. issue #3060
This commit is contained in:
parent
98518e39cd
commit
2d17af9f28
|
@ -129,8 +129,16 @@ extern "C" int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
||||||
|
|
||||||
case HW_PHYSMEM:
|
case HW_PHYSMEM:
|
||||||
case HW_USERMEM:
|
case HW_USERMEM:
|
||||||
*(unsigned long*)oldp = _global_env->ram().ram_quota().value;
|
switch (*oldlenp) {
|
||||||
*oldlenp = sizeof(unsigned long);
|
case 4:
|
||||||
|
*(Genode::int32_t*)oldp = _global_env->ram().ram_quota().value;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
*(Genode::int64_t*)oldp = _global_env->ram().ram_quota().value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return Libc::Errno(EINVAL);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case HW_PAGESIZE:
|
case HW_PAGESIZE:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user