aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-10-07 00:46:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-10-07 00:46:05 -0700
commitb5a36f676b1fd69f195d9f1eb6e35f3eb2f15946 (patch)
tree92ce1ffa64bc2d32d5ef73dce66daf3c8e893ee6 /lib/std/os/linux.zig
parentd6d05fc84d33c71434a1f8bae51ca5956e08cdf0 (diff)
parentf2d374e8465042fa5cb6bf2be7b9b086948f3a94 (diff)
downloadzig-b5a36f676b1fd69f195d9f1eb6e35f3eb2f15946.tar.gz
zig-b5a36f676b1fd69f195d9f1eb6e35f3eb2f15946.zip
Merge remote-tracking branch 'origin/master' into llvm11
Conflicts: cmake/Findllvm.cmake The llvm11 branch changed 10's to 11's and master branch added the "using LLVM_CONFIG_EXE" help message, so the resolution was to merge these changes together. I also added a check to make sure LLVM is built with AVR enabled, which is no longer an experimental target.
Diffstat (limited to 'lib/std/os/linux.zig')
-rw-r--r--lib/std/os/linux.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index 50d1e4ae78..e38d9bc10d 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -1263,6 +1263,26 @@ pub fn prctl(option: i32, arg2: usize, arg3: usize, arg4: usize, arg5: usize) us
return syscall5(.prctl, @bitCast(usize, @as(isize, option)), arg2, arg3, arg4, arg5);
}
+pub fn getrlimit(resource: rlimit_resource, rlim: *rlimit) usize {
+ // use prlimit64 to have 64 bit limits on 32 bit platforms
+ return prlimit(0, resource, null, rlim);
+}
+
+pub fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) usize {
+ // use prlimit64 to have 64 bit limits on 32 bit platforms
+ return prlimit(0, resource, rlim, null);
+}
+
+pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit, old_limit: ?*rlimit) usize {
+ return syscall4(
+ .prlimit64,
+ @bitCast(usize, @as(isize, pid)),
+ @bitCast(usize, @as(isize, @enumToInt(resource))),
+ @ptrToInt(new_limit),
+ @ptrToInt(old_limit)
+ );
+}
+
test "" {
if (builtin.os.tag == .linux) {
_ = @import("linux/test.zig");