mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
util/os_misc: os_get_available_system_memory() for OpenBSD
Return the smallest value of available non-kernel physical memory and the static per process data size limit as the amount of available system memory on OpenBSD. Fixes:b80930a6fe("anv: add support for VK_EXT_memory_budget") Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Acked-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6517> (cherry picked from commitb30bd6fe5f)
This commit is contained in:
parent
b69312343b
commit
8225f619ba
2 changed files with 21 additions and 1 deletions
|
|
@ -3334,7 +3334,7 @@
|
|||
"description": "util/os_misc: os_get_available_system_memory() for OpenBSD",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"master_sha": null,
|
||||
"because_sha": "b80930a6fea075d2ef283ceac5a2a64e65fd7bc4"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "os_misc.h"
|
||||
#include "os_file.h"
|
||||
#include "macros.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
|
@ -57,6 +58,9 @@
|
|||
# include <log/log.h>
|
||||
#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD
|
||||
# include <unistd.h>
|
||||
#elif DETECT_OS_OPENBSD
|
||||
# include <sys/resource.h>
|
||||
# include <sys/sysctl.h>
|
||||
#elif DETECT_OS_APPLE || DETECT_OS_BSD
|
||||
# include <sys/sysctl.h>
|
||||
#elif DETECT_OS_HAIKU
|
||||
|
|
@ -209,6 +213,22 @@ os_get_available_system_memory(uint64_t *size)
|
|||
|
||||
free(meminfo);
|
||||
return false;
|
||||
#elif DETECT_OS_OPENBSD
|
||||
struct rlimit rl;
|
||||
int mib[] = { CTL_HW, HW_USERMEM64 };
|
||||
int64_t mem_available;
|
||||
size_t len = sizeof(mem_available);
|
||||
|
||||
/* physmem - wired */
|
||||
if (sysctl(mib, 2, &mem_available, &len, NULL, 0) == -1)
|
||||
return false;
|
||||
|
||||
/* static login.conf limit */
|
||||
if (getrlimit(RLIMIT_DATA, &rl) == -1)
|
||||
return false;
|
||||
|
||||
*size = MIN2(mem_available, rl.rlim_cur);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue