Skip to content

Commit 4dde7ea

Browse files
author
Jan Philipp Hafer
committed
initial moving of files to CI test things.
1 parent 3f3ec1a commit 4dde7ea

File tree

15 files changed

+617
-600
lines changed

15 files changed

+617
-600
lines changed

lib/std/Thread.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +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-
const mapped = os.mmap(
948+
const mapped = os.posix.mmap(
949949
null,
950950
map_bytes,
951951
os.PROT.NONE,
@@ -959,7 +959,7 @@ const LinuxThreadImpl = struct {
959959
else => |e| return e,
960960
};
961961
assert(mapped.len >= map_bytes);
962-
errdefer os.munmap(mapped);
962+
errdefer os.posix.munmap(mapped);
963963

964964
// map everything but the guard page as read/write
965965
os.mprotect(
@@ -1032,7 +1032,7 @@ const LinuxThreadImpl = struct {
10321032
}
10331033

10341034
fn join(self: Impl) void {
1035-
defer os.munmap(self.thread.mapped);
1035+
defer os.posix.munmap(self.thread.mapped);
10361036

10371037
var spin: u8 = 10;
10381038
while (true) {

lib/std/child_process.zig

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const unicode = std.unicode;
55
const io = std.io;
66
const fs = std.fs;
77
const os = std.os;
8+
const posix = os.posix;
89
const process = std.process;
910
const File = std.fs.File;
1011
const windows = os.windows;
@@ -63,7 +64,7 @@ pub const ChildProcess = struct {
6364
/// Darwin-only. Start child process in suspended state as if SIGSTOP was sent.
6465
start_suspended: bool = false,
6566

66-
pub const Arg0Expand = os.Arg0Expand;
67+
pub const Arg0Expand = os.posix.Arg0Expand;
6768

6869
pub const SpawnError = error{
6970
OutOfMemory,
@@ -79,8 +80,8 @@ pub const ChildProcess = struct {
7980
/// Windows-only. `cwd` was provided, but the path did not exist when spawning the child process.
8081
CurrentWorkingDirectoryUnlinked,
8182
} ||
82-
os.ExecveError ||
83-
os.SetIdError ||
83+
os.posix.ExecveError ||
84+
os.posix.SetIdError ||
8485
os.ChangeCurDirError ||
8586
windows.CreateProcessError ||
8687
windows.WaitForSingleObjectError ||
@@ -177,7 +178,7 @@ pub const ChildProcess = struct {
177178
self.cleanupStreams();
178179
return term;
179180
}
180-
try os.kill(self.pid, os.SIG.TERM);
181+
try posix.kill(self.pid, os.SIG.TERM);
181182
try self.waitUnwrapped();
182183
return self.term.?;
183184
}
@@ -299,7 +300,7 @@ pub const ChildProcess = struct {
299300
return term;
300301
}
301302

302-
try self.waitUnwrapped();
303+
try self.waitUnwrappedPosix();
303304
return self.term.?;
304305
}
305306

@@ -321,11 +322,11 @@ pub const ChildProcess = struct {
321322
return result;
322323
}
323324

324-
fn waitUnwrapped(self: *ChildProcess) !void {
325-
const res: os.WaitPidResult = if (comptime builtin.target.isDarwin())
325+
fn waitUnwrappedPosix(self: *ChildProcess) !void {
326+
const res: os.posix.WaitPidResult = if (comptime builtin.target.isDarwin())
326327
try os.posix_spawn.waitpid(self.pid, 0)
327328
else
328-
os.waitpid(self.pid, 0);
329+
os.posix.waitpid(self.pid, 0);
329330
const status = res.status;
330331
self.cleanupStreams();
331332
self.handleWaitResult(status);
@@ -403,13 +404,13 @@ pub const ChildProcess = struct {
403404

404405
fn spawnMacos(self: *ChildProcess) SpawnError!void {
405406
const pipe_flags = if (io.is_async) os.O.NONBLOCK else 0;
406-
const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
407+
const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.posix.pipe2(pipe_flags) else undefined;
407408
errdefer if (self.stdin_behavior == StdIo.Pipe) destroyPipe(stdin_pipe);
408409

409-
const stdout_pipe = if (self.stdout_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
410+
const stdout_pipe = if (self.stdout_behavior == StdIo.Pipe) try os.posix.pipe2(pipe_flags) else undefined;
410411
errdefer if (self.stdout_behavior == StdIo.Pipe) destroyPipe(stdout_pipe);
411412

412-
const stderr_pipe = if (self.stderr_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
413+
const stderr_pipe = if (self.stderr_behavior == StdIo.Pipe) try os.posix.pipe2(pipe_flags) else undefined;
413414
errdefer if (self.stderr_behavior == StdIo.Pipe) destroyPipe(stderr_pipe);
414415

415416
const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore);
@@ -518,17 +519,17 @@ pub const ChildProcess = struct {
518519

519520
fn spawnPosix(self: *ChildProcess) SpawnError!void {
520521
const pipe_flags = if (io.is_async) os.O.NONBLOCK else 0;
521-
const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
522+
const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.posix.pipe2(pipe_flags) else undefined;
522523
errdefer if (self.stdin_behavior == StdIo.Pipe) {
523524
destroyPipe(stdin_pipe);
524525
};
525526

526-
const stdout_pipe = if (self.stdout_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
527+
const stdout_pipe = if (self.stdout_behavior == StdIo.Pipe) try os.posix.pipe2(pipe_flags) else undefined;
527528
errdefer if (self.stdout_behavior == StdIo.Pipe) {
528529
destroyPipe(stdout_pipe);
529530
};
530531

531-
const stderr_pipe = if (self.stderr_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
532+
const stderr_pipe = if (self.stderr_behavior == StdIo.Pipe) try os.posix.pipe2(pipe_flags) else undefined;
532533
errdefer if (self.stderr_behavior == StdIo.Pipe) {
533534
destroyPipe(stderr_pipe);
534535
};
@@ -593,12 +594,12 @@ pub const ChildProcess = struct {
593594
// end with eventfd
594595
break :blk [2]os.fd_t{ fd, fd };
595596
} else {
596-
break :blk try os.pipe2(os.O.CLOEXEC);
597+
break :blk try os.posix.pipe2(os.O.CLOEXEC);
597598
}
598599
};
599600
errdefer destroyPipe(err_pipe);
600601

601-
const pid_result = try os.fork();
602+
const pid_result = try os.posix.fork();
602603
if (pid_result == 0) {
603604
// we are the child
604605
setUpChildIo(self.stdin_behavior, stdin_pipe[0], os.STDIN_FILENO, dev_null_fd) catch |err| forkChildErrReport(err_pipe[1], err);
@@ -625,16 +626,16 @@ pub const ChildProcess = struct {
625626
}
626627

627628
if (self.gid) |gid| {
628-
os.setregid(gid, gid) catch |err| forkChildErrReport(err_pipe[1], err);
629+
os.posix.setregid(gid, gid) catch |err| forkChildErrReport(err_pipe[1], err);
629630
}
630631

631632
if (self.uid) |uid| {
632-
os.setreuid(uid, uid) catch |err| forkChildErrReport(err_pipe[1], err);
633+
os.posix.setreuid(uid, uid) catch |err| forkChildErrReport(err_pipe[1], err);
633634
}
634635

635636
const err = switch (self.expand_arg0) {
636-
.expand => os.execvpeZ_expandArg0(.expand, argv_buf.ptr[0].?, argv_buf.ptr, envp),
637-
.no_expand => os.execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_buf.ptr, envp),
637+
.expand => os.posix.execvpeZ_expandArg0(.expand, argv_buf.ptr[0].?, argv_buf.ptr, envp),
638+
.no_expand => os.posix.execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_buf.ptr, envp),
638639
};
639640
forkChildErrReport(err_pipe[1], err);
640641
}
@@ -940,10 +941,10 @@ pub const ChildProcess = struct {
940941

941942
fn setUpChildIo(stdio: StdIo, pipe_fd: i32, std_fileno: i32, dev_null_fd: i32) !void {
942943
switch (stdio) {
943-
.Pipe => try os.dup2(pipe_fd, std_fileno),
944+
.Pipe => try os.posix.dup2(pipe_fd, std_fileno),
944945
.Close => os.close(std_fileno),
945946
.Inherit => {},
946-
.Ignore => try os.dup2(dev_null_fd, std_fileno),
947+
.Ignore => try os.posix.dup2(dev_null_fd, std_fileno),
947948
}
948949
}
949950
};

lib/std/crypto/tlcsprng.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn tlsCsprngFill(_: *anyopaque, buffer: []u8) void {
7575
if (want_fork_safety and maybe_have_wipe_on_fork or is_haiku) {
7676
// Allocate a per-process page, madvise operates with page
7777
// granularity.
78-
wipe_mem = os.mmap(
78+
wipe_mem = os.posix.mmap(
7979
null,
8080
@sizeOf(Context),
8181
os.PROT.READ | os.PROT.WRITE,

lib/std/debug.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ pub const StackIterator = struct {
482482

483483
if (native_os != .windows) {
484484
if (native_os != .wasi) {
485-
os.msync(aligned_memory, os.MSF.ASYNC) catch |err| {
485+
os.posix.msync(aligned_memory, os.MSF.ASYNC) catch |err| {
486486
switch (err) {
487-
os.MSyncError.UnmappedMemory => {
487+
os.posix.MSyncError.UnmappedMemory => {
488488
return false;
489489
},
490490
else => unreachable,
@@ -1222,15 +1222,15 @@ fn mapWholeFile(file: File) ![]align(mem.page_size) const u8 {
12221222
defer file.close();
12231223

12241224
const file_len = math.cast(usize, try file.getEndPos()) orelse math.maxInt(usize);
1225-
const mapped_mem = try os.mmap(
1225+
const mapped_mem = try os.posix.mmap(
12261226
null,
12271227
file_len,
12281228
os.PROT.READ,
12291229
os.MAP.SHARED,
12301230
file.handle,
12311231
0,
12321232
);
1233-
errdefer os.munmap(mapped_mem);
1233+
errdefer os.posix.munmap(mapped_mem);
12341234

12351235
return mapped_mem;
12361236
}
@@ -1491,7 +1491,7 @@ pub const ModuleDebugInfo = switch (native_os) {
14911491
}
14921492
self.ofiles.deinit();
14931493
allocator.free(self.symbols);
1494-
os.munmap(self.mapped_memory);
1494+
os.posix.munmap(self.mapped_memory);
14951495
}
14961496

14971497
fn loadOFile(self: *@This(), allocator: mem.Allocator, o_file_path: []const u8) !OFileInfo {
@@ -1798,7 +1798,7 @@ pub const ModuleDebugInfo = switch (native_os) {
17981798

17991799
fn deinit(self: *@This(), allocator: mem.Allocator) void {
18001800
self.dwarf.deinit(allocator);
1801-
os.munmap(self.mapped_memory);
1801+
os.posix.munmap(self.mapped_memory);
18021802
}
18031803

18041804
pub fn getSymbolAtAddress(self: *@This(), allocator: mem.Allocator, address: usize) !SymbolInfo {

lib/std/dynamic_library.zig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ pub const ElfDynLib = struct {
123123

124124
// This one is to read the ELF info. We do more mmapping later
125125
// corresponding to the actual LOAD sections.
126-
const file_bytes = try os.mmap(
126+
const file_bytes = try os.posix.mmap(
127127
null,
128128
mem.alignForward(size, mem.page_size),
129129
os.PROT.READ,
130130
os.MAP.PRIVATE,
131131
fd,
132132
0,
133133
);
134-
defer os.munmap(file_bytes);
134+
defer os.posix.munmap(file_bytes);
135135

136136
const eh = @ptrCast(*elf.Ehdr, file_bytes.ptr);
137137
if (!mem.eql(u8, eh.e_ident[0..4], elf.MAGIC)) return error.NotElfFile;
@@ -161,15 +161,15 @@ pub const ElfDynLib = struct {
161161
const dynv = maybe_dynv orelse return error.MissingDynamicLinkingInformation;
162162

163163
// Reserve the entire range (with no permissions) so that we can do MAP.FIXED below.
164-
const all_loaded_mem = try os.mmap(
164+
const all_loaded_mem = try os.posix.mmap(
165165
null,
166166
virt_addr_end,
167167
os.PROT.NONE,
168168
os.MAP.PRIVATE | os.MAP.ANONYMOUS,
169169
-1,
170170
0,
171171
);
172-
errdefer os.munmap(all_loaded_mem);
172+
errdefer os.posix.munmap(all_loaded_mem);
173173

174174
const base = @ptrToInt(all_loaded_mem.ptr);
175175

@@ -193,7 +193,7 @@ pub const ElfDynLib = struct {
193193
const prot = elfToMmapProt(ph.p_flags);
194194
if ((ph.p_flags & elf.PF_W) == 0) {
195195
// If it does not need write access, it can be mapped from the fd.
196-
_ = try os.mmap(
196+
_ = try os.posix.mmap(
197197
ptr,
198198
extended_memsz,
199199
prot,
@@ -202,7 +202,7 @@ pub const ElfDynLib = struct {
202202
ph.p_offset - extra_bytes,
203203
);
204204
} else {
205-
const sect_mem = try os.mmap(
205+
const sect_mem = try os.posix.mmap(
206206
ptr,
207207
extended_memsz,
208208
prot,
@@ -256,7 +256,7 @@ pub const ElfDynLib = struct {
256256

257257
/// Trusts the file
258258
pub fn close(self: *ElfDynLib) void {
259-
os.munmap(self.memory);
259+
os.posix.munmap(self.memory);
260260
self.* = undefined;
261261
}
262262

lib/std/fs.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ pub const Dir = struct {
11891189
}
11901190

11911191
if (has_flock_open_flags and flags.lock_nonblocking) {
1192-
var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
1192+
var fl_flags = os.posix.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
11931193
error.FileBusy => unreachable,
11941194
error.Locked => unreachable,
11951195
error.PermissionDenied => unreachable,
@@ -1198,7 +1198,7 @@ pub const Dir = struct {
11981198
else => |e| return e,
11991199
};
12001200
fl_flags &= ~@as(usize, os.O.NONBLOCK);
1201-
_ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
1201+
_ = os.posix.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
12021202
error.FileBusy => unreachable,
12031203
error.Locked => unreachable,
12041204
error.PermissionDenied => unreachable,
@@ -1345,7 +1345,7 @@ pub const Dir = struct {
13451345
}
13461346

13471347
if (has_flock_open_flags and flags.lock_nonblocking) {
1348-
var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
1348+
var fl_flags = os.posix.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
13491349
error.FileBusy => unreachable,
13501350
error.Locked => unreachable,
13511351
error.PermissionDenied => unreachable,
@@ -1354,7 +1354,7 @@ pub const Dir = struct {
13541354
else => |e| return e,
13551355
};
13561356
fl_flags &= ~@as(usize, os.O.NONBLOCK);
1357-
_ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
1357+
_ = os.posix.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
13581358
error.FileBusy => unreachable,
13591359
error.Locked => unreachable,
13601360
error.PermissionDenied => unreachable,

lib/std/fs/file.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ pub const File = struct {
411411
/// any group of which the owner is a member. If the owner or group is
412412
/// specified as `null`, the ID is not changed.
413413
pub fn chown(self: File, owner: ?Uid, group: ?Gid) ChownError!void {
414-
try os.fchown(self.handle, owner, group);
414+
try os.posix.fchown(self.handle, owner, group);
415415
}
416416

417417
/// Cross-platform representation of permissions on a file.

lib/std/heap/PageAllocator.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 {
3131
}
3232

3333
const hint = @atomicLoad(@TypeOf(std.heap.next_mmap_addr_hint), &std.heap.next_mmap_addr_hint, .Unordered);
34-
const slice = os.mmap(
34+
const slice = os.posix.mmap(
3535
hint,
3636
aligned_len,
3737
os.PROT.READ | os.PROT.WRITE,
@@ -87,7 +87,7 @@ fn resize(
8787
if (new_size_aligned < buf_aligned_len) {
8888
const ptr = @alignCast(mem.page_size, buf_unaligned.ptr + new_size_aligned);
8989
// TODO: if the next_mmap_addr_hint is within the unmapped range, update it
90-
os.munmap(ptr[0 .. buf_aligned_len - new_size_aligned]);
90+
os.posix.munmap(ptr[0 .. buf_aligned_len - new_size_aligned]);
9191
return true;
9292
}
9393

@@ -105,6 +105,6 @@ fn free(_: *anyopaque, slice: []u8, log2_buf_align: u8, return_address: usize) v
105105
} else {
106106
const buf_aligned_len = mem.alignForward(slice.len, mem.page_size);
107107
const ptr = @alignCast(mem.page_size, slice.ptr);
108-
os.munmap(ptr[0..buf_aligned_len]);
108+
os.posix.munmap(ptr[0..buf_aligned_len]);
109109
}
110110
}

0 commit comments

Comments
 (0)