aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan O'Rear <sorear@fastmail.com>2020-09-03 03:31:05 -0400
committerRich Felker <dalias@aerifal.cx>2022-05-01 23:25:21 -0400
commit41149ea8c7a6f28a1c60478fe7f6b9552aa39e3b (patch)
treef9fe8f74a892ce6b5b77ba8eb3e704da8ed703e5 /src
parent8910efd0e474fab85bf00657a6eeae4d69a87f63 (diff)
downloadmusl-41149ea8c7a6f28a1c60478fe7f6b9552aa39e3b.tar.gz
musl-41149ea8c7a6f28a1c60478fe7f6b9552aa39e3b.tar.xz
musl-41149ea8c7a6f28a1c60478fe7f6b9552aa39e3b.zip
only use getrlimit/setrlimit syscalls if they exist
riscv32 and future architectures only provide prlimit64.
Diffstat (limited to 'src')
-rw-r--r--src/misc/getrlimit.c6
-rw-r--r--src/misc/setrlimit.c6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/misc/getrlimit.c b/src/misc/getrlimit.c
index 2ab2f0f4..bf676307 100644
--- a/src/misc/getrlimit.c
+++ b/src/misc/getrlimit.c
@@ -6,12 +6,13 @@
int getrlimit(int resource, struct rlimit *rlim)
{
- unsigned long k_rlim[2];
int ret = syscall(SYS_prlimit64, 0, resource, 0, rlim);
if (!ret) {
FIX(rlim->rlim_cur);
FIX(rlim->rlim_max);
}
+#ifdef SYS_getrlimit
+ unsigned long k_rlim[2];
if (!ret || errno != ENOSYS)
return ret;
if (syscall(SYS_getrlimit, resource, k_rlim) < 0)
@@ -21,6 +22,9 @@ int getrlimit(int resource, struct rlimit *rlim)
FIX(rlim->rlim_cur);
FIX(rlim->rlim_max);
return 0;
+#else
+ return ret;
+#endif
}
weak_alias(getrlimit, getrlimit64);
diff --git a/src/misc/setrlimit.c b/src/misc/setrlimit.c
index 8340aee0..5b713cf3 100644
--- a/src/misc/setrlimit.c
+++ b/src/misc/setrlimit.c
@@ -12,12 +12,14 @@ struct ctx {
int err;
};
+#ifdef SYS_setrlimit
static void do_setrlimit(void *p)
{
struct ctx *c = p;
if (c->err>0) return;
c->err = -__syscall(SYS_setrlimit, c->res, c->lim);
}
+#endif
int setrlimit(int resource, const struct rlimit *rlim)
{
@@ -29,6 +31,7 @@ int setrlimit(int resource, const struct rlimit *rlim)
rlim = &tmp;
}
int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0);
+#ifdef SYS_setrlimit
if (ret != -ENOSYS) return __syscall_ret(ret);
struct ctx c = {
@@ -42,6 +45,9 @@ int setrlimit(int resource, const struct rlimit *rlim)
return -1;
}
return 0;
+#else
+ return __syscall_ret(ret);
+#endif
}
weak_alias(setrlimit, setrlimit64);