Skip to content

Commit bc90850

Browse files
author
Jan Philipp Hafer
committed
fixup usages.
1 parent 5172438 commit bc90850

File tree

8 files changed

+30
-28
lines changed

8 files changed

+30
-28
lines changed

lib/std/Thread.zig

+3
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ const LinuxThreadImpl = struct {
945945

946946
// map all memory needed without read/write permissions
947947
// to avoid committing the whole region right away
948+
// anonymous mapping ensures file descriptor limits are not exceeded
948949
const mapped = os.posix.mmap(
949950
null,
950951
map_bytes,
@@ -956,6 +957,8 @@ const LinuxThreadImpl = struct {
956957
error.MemoryMappingNotSupported => unreachable,
957958
error.AccessDenied => unreachable,
958959
error.PermissionDenied => unreachable,
960+
error.ProcessFdQuotaExceeded => unreachable,
961+
error.SystemFdQuotaExceeded => unreachable,
959962
else => |e| return e,
960963
};
961964
assert(mapped.len >= map_bytes);

lib/std/crypto/tlcsprng.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ fn tlsCsprngFill(_: *anyopaque, buffer: []u8) void {
111111
// Qemu user-mode emulation ignores any valid/invalid madvise
112112
// hint and returns success. Check if this is the case by
113113
// passing bogus parameters, we expect EINVAL as result.
114-
if (os.madvise(wipe_mem.ptr, 0, 0xffffffff)) |_| {
114+
if (os.posix.madvise(wipe_mem.ptr, 0, 0xffffffff)) |_| {
115115
break :wof;
116116
} else |_| {}
117117

118-
if (os.madvise(wipe_mem.ptr, wipe_mem.len, os.MADV.WIPEONFORK)) |_| {
118+
if (os.posix.madvise(wipe_mem.ptr, wipe_mem.len, os.MADV.WIPEONFORK)) |_| {
119119
return initAndFill(buffer);
120120
} else |_| {}
121121
}

lib/std/debug.zig

+4-4
Original file line numberDiff line numberDiff line change
@@ -1880,10 +1880,10 @@ pub fn maybeEnableSegfaultHandler() void {
18801880
var windows_segfault_handle: ?windows.HANDLE = null;
18811881

18821882
pub fn updateSegfaultHandler(act: ?*const os.Sigaction) error{OperationNotSupported}!void {
1883-
try os.sigaction(os.SIG.SEGV, act, null);
1884-
try os.sigaction(os.SIG.ILL, act, null);
1885-
try os.sigaction(os.SIG.BUS, act, null);
1886-
try os.sigaction(os.SIG.FPE, act, null);
1883+
try os.posix.sigaction(os.SIG.SEGV, act, null);
1884+
try os.posix.sigaction(os.SIG.ILL, act, null);
1885+
try os.posix.sigaction(os.SIG.BUS, act, null);
1886+
try os.posix.sigaction(os.SIG.FPE, act, null);
18871887
}
18881888

18891889
/// Attaches a global SIGSEGV handler which calls @panic("segmentation fault");

lib/std/fs/file.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ pub const File = struct {
899899
};
900900
}
901901

902-
pub const UpdateTimesError = os.FutimensError || windows.SetFileTimeError;
902+
pub const UpdateTimesError = os.posix.FutimensError || windows.SetFileTimeError;
903903

904904
/// The underlying file system may have a different granularity than nanoseconds,
905905
/// and therefore this function cannot guarantee any precision will be stored.
@@ -928,7 +928,7 @@ pub const File = struct {
928928
.tv_nsec = math.cast(isize, @mod(mtime, std.time.ns_per_s)) orelse maxInt(isize),
929929
},
930930
};
931-
try os.futimens(self.handle, &times);
931+
try os.posix.futimens(self.handle, &times);
932932
}
933933

934934
/// Reads all the bytes from the current position to the end of the file.

lib/std/os/test.zig

+11-11
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ test "sigaltstack" {
434434
if (native_os == .windows or native_os == .wasi) return error.SkipZigTest;
435435

436436
var st: os.stack_t = undefined;
437-
try os.sigaltstack(null, &st);
437+
try os.posix.sigaltstack(null, &st);
438438
// Setting a stack size less than MINSIGSTKSZ returns ENOMEM
439439
st.flags = 0;
440440
st.size = 1;
441-
try testing.expectError(error.SizeTooSmall, os.sigaltstack(&st, null));
441+
try testing.expectError(error.SizeTooSmall, os.posix.sigaltstack(&st, null));
442442
}
443443

444444
// If the type is not available use void to avoid erroring out when `iter_fn` is
@@ -736,7 +736,7 @@ test "getrlimit and setrlimit" {
736736

737737
inline for (std.meta.fields(os.rlimit_resource)) |field| {
738738
const resource = @intToEnum(os.rlimit_resource, field.value);
739-
const limit = try os.getrlimit(resource);
739+
const limit = try os.posix.getrlimit(resource);
740740

741741
// On 32 bit MIPS musl includes a fix which changes limits greater than -1UL/2 to RLIM_INFINITY.
742742
// See http://git.musl-libc.org/cgit/musl/commit/src/misc/getrlimit.c?id=8258014fd1e34e942a549c88c7e022a00445c352
@@ -745,10 +745,10 @@ test "getrlimit and setrlimit" {
745745
// In that case the following the limit would be RLIM_INFINITY and the following setrlimit fails with EPERM.
746746
if (comptime builtin.cpu.arch.isMIPS() and builtin.link_libc) {
747747
if (limit.cur != os.linux.RLIM.INFINITY) {
748-
try os.setrlimit(resource, limit);
748+
try os.posix.setrlimit(resource, limit);
749749
}
750750
} else {
751-
try os.setrlimit(resource, limit);
751+
try os.posix.setrlimit(resource, limit);
752752
}
753753
}
754754
}
@@ -807,10 +807,10 @@ test "sigaction" {
807807
var old_sa: os.Sigaction = undefined;
808808

809809
// Install the new signal handler.
810-
try os.sigaction(os.SIG.USR1, &sa, null);
810+
try os.posix.sigaction(os.SIG.USR1, &sa, null);
811811

812812
// Check that we can read it back correctly.
813-
try os.sigaction(os.SIG.USR1, null, &old_sa);
813+
try os.posix.sigaction(os.SIG.USR1, null, &old_sa);
814814
try testing.expectEqual(&S.handler, old_sa.handler.sigaction.?);
815815
try testing.expect((old_sa.flags & os.SA.SIGINFO) != 0);
816816

@@ -819,26 +819,26 @@ test "sigaction" {
819819
try testing.expect(S.handler_called_count == 1);
820820

821821
// Check if passing RESETHAND correctly reset the handler to SIG_DFL
822-
try os.sigaction(os.SIG.USR1, null, &old_sa);
822+
try os.posix.sigaction(os.SIG.USR1, null, &old_sa);
823823
try testing.expectEqual(os.SIG.DFL, old_sa.handler.handler);
824824

825825
// Reinstall the signal w/o RESETHAND and re-raise
826826
sa.flags = os.SA.SIGINFO;
827-
try os.sigaction(os.SIG.USR1, &sa, null);
827+
try os.posix.sigaction(os.SIG.USR1, &sa, null);
828828
try os.raise(os.SIG.USR1);
829829
try testing.expect(S.handler_called_count == 2);
830830

831831
// Now set the signal to ignored
832832
sa.handler = .{ .handler = os.SIG.IGN };
833833
sa.flags = 0;
834-
try os.sigaction(os.SIG.USR1, &sa, null);
834+
try os.posix.sigaction(os.SIG.USR1, &sa, null);
835835

836836
// Re-raise to ensure handler is actually ignored
837837
try os.raise(os.SIG.USR1);
838838
try testing.expect(S.handler_called_count == 2);
839839

840840
// Ensure that ignored state is returned when querying
841-
try os.sigaction(os.SIG.USR1, null, &old_sa);
841+
try os.posix.sigaction(os.SIG.USR1, null, &old_sa);
842842
try testing.expectEqual(os.SIG.IGN, old_sa.handler.handler.?);
843843
}
844844

lib/std/start.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ fn expandStackSize(phdrs: []elf.Phdr) void {
471471
const wanted_stack_size = phdr.p_memsz;
472472
assert(wanted_stack_size % std.mem.page_size == 0);
473473

474-
std.os.setrlimit(.STACK, .{
474+
std.os.posix.setrlimit(.STACK, .{
475475
.cur = wanted_stack_size,
476476
.max = wanted_stack_size,
477477
}) catch {

lib/std/zig/system/NativeTargetInfo.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
3939
if (cross_target.os_tag == null) {
4040
switch (builtin.target.os.tag) {
4141
.linux => {
42-
const uts = std.os.uname();
42+
const uts = std.os.posix.uname();
4343
const release = mem.sliceTo(&uts.release, 0);
4444
// The release field sometimes has a weird format,
4545
// `Version.parse` will attempt to find some meaningful interpretation.
@@ -53,7 +53,7 @@ pub fn detect(cross_target: CrossTarget) DetectError!NativeTargetInfo {
5353
}
5454
},
5555
.solaris => {
56-
const uts = std.os.uname();
56+
const uts = std.os.posix.uname();
5757
const release = mem.sliceTo(&uts.release, 0);
5858
if (std.builtin.Version.parse(release)) |ver| {
5959
os.version_range.semver.min = ver;

src/main.zig

+5-6
Original file line numberDiff line numberDiff line change
@@ -5283,9 +5283,8 @@ fn parseCodeModel(arg: []const u8) std.builtin.CodeModel {
52835283
/// zig processes to run concurrently with each other, without clobbering each other.
52845284
fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
52855285
if (!@hasDecl(std.os.system, "rlimit")) return;
5286-
const posix = std.os;
52875286

5288-
var lim = posix.getrlimit(.NOFILE) catch return; // Oh well; we tried.
5287+
var lim = std.os.posix.getrlimit(.NOFILE) catch return; // Oh well; we tried.
52895288
if (comptime builtin.target.isDarwin()) {
52905289
// On Darwin, `NOFILE` is bounded by a hardcoded value `OPEN_MAX`.
52915290
// According to the man pages for setrlimit():
@@ -5297,17 +5296,17 @@ fn gimmeMoreOfThoseSweetSweetFileDescriptors() void {
52975296
if (lim.cur == lim.max) return;
52985297

52995298
// Do a binary search for the limit.
5300-
var min: posix.rlim_t = lim.cur;
5301-
var max: posix.rlim_t = 1 << 20;
5299+
var min: std.os.rlim_t = lim.cur;
5300+
var max: std.os.rlim_t = 1 << 20;
53025301
// But if there's a defined upper bound, don't search, just set it.
5303-
if (lim.max != posix.RLIM.INFINITY) {
5302+
if (lim.max != std.os.RLIM.INFINITY) {
53045303
min = lim.max;
53055304
max = lim.max;
53065305
}
53075306

53085307
while (true) {
53095308
lim.cur = min + @divTrunc(max - min, 2); // on freebsd rlim_t is signed
5310-
if (posix.setrlimit(.NOFILE, lim)) |_| {
5309+
if (std.os.posix.setrlimit(.NOFILE, lim)) |_| {
53115310
min = lim.cur;
53125311
} else |_| {
53135312
max = lim.cur;

0 commit comments

Comments
 (0)