summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2022-02-27 02:40:00 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2022-02-27 02:40:00 +0100
commit118e211269fb4f685f2999157eb4aafc8fdd9423 (patch)
tree82b1f32babe338ba7955c39de8de1ab82d24468d /libc/sysdeps/linux
parentebe16ee2ae0e2e20e2950e5ceae179b98f1e4264 (diff)
guard prlimit, reported by Lance Fredrickson
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r--libc/sysdeps/linux/common/bits/kernel-features.h5
-rw-r--r--libc/sysdeps/linux/common/prlimit.c3
2 files changed, 8 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/bits/kernel-features.h b/libc/sysdeps/linux/common/bits/kernel-features.h
index f1ebe0204..2f4f407bd 100644
--- a/libc/sysdeps/linux/common/bits/kernel-features.h
+++ b/libc/sysdeps/linux/common/bits/kernel-features.h
@@ -490,6 +490,11 @@
# define __ASSUME_FALLOCATE 1
#endif
+/* prlimit64 is available in 2.6.36. */
+#if __LINUX_KERNEL_VERSION >= 0x020624
+# define __ASSUME_PRLIMIT64 1
+#endif
+
/* getcpu is a syscall for x86-64 since 3.1. */
#if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
# define __ASSUME_GETCPU_SYSCALL 1
diff --git a/libc/sysdeps/linux/common/prlimit.c b/libc/sysdeps/linux/common/prlimit.c
index cdb64ba0d..f44dc1664 100644
--- a/libc/sysdeps/linux/common/prlimit.c
+++ b/libc/sysdeps/linux/common/prlimit.c
@@ -17,7 +17,9 @@
#include <sys/resource.h>
#include <sysdep.h>
+#include <bits/kernel-features.h>
+#if defined __ASSUME_PRLIMIT64
int
prlimit (__pid_t pid, enum __rlimit_resource resource,
const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
@@ -25,3 +27,4 @@ prlimit (__pid_t pid, enum __rlimit_resource resource,
return INLINE_SYSCALL (prlimit64, 4, pid, resource, new_rlimit,
old_rlimit);
}
+#endif