mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 16:58:30 +00:00
Simplify memory manager
This commit is contained in:
parent
5a9a08d1cf
commit
01587de761
40 changed files with 451 additions and 311 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "libc/calls/struct/rlimit.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -77,6 +78,7 @@
|
|||
*/
|
||||
int setrlimit(int resource, const struct rlimit *rlim) {
|
||||
int rc;
|
||||
int olde = errno;
|
||||
if (resource == 127) {
|
||||
rc = einval();
|
||||
} else if (!rlim) {
|
||||
|
@ -85,18 +87,16 @@ int setrlimit(int resource, const struct rlimit *rlim) {
|
|||
rc = _sysret(__syslib->__setrlimit(resource, rlim));
|
||||
} else if (!IsWindows()) {
|
||||
rc = sys_setrlimit(resource, rlim);
|
||||
if (IsXnu() && !rc && resource == RLIMIT_AS) {
|
||||
// TODO(jart): What's up with XNU and NetBSD?
|
||||
__virtualmax = rlim->rlim_cur;
|
||||
}
|
||||
} else if (resource == RLIMIT_STACK) {
|
||||
rc = enotsup();
|
||||
} else if (resource == RLIMIT_AS) {
|
||||
__virtualmax = rlim->rlim_cur;
|
||||
rc = 0;
|
||||
} else {
|
||||
rc = einval();
|
||||
}
|
||||
if (resource == RLIMIT_AS) {
|
||||
__virtualmax = rlim->rlim_cur;
|
||||
errno = olde;
|
||||
rc = 0;
|
||||
}
|
||||
STRACE("setrlimit(%s, %s) → %d% m", DescribeRlimitName(resource),
|
||||
DescribeRlimit(0, rlim), rc);
|
||||
return rc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue