diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-16 10:51:58 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-16 10:51:58 -0400 |
| commit | a2abdb185f9e47b663edce1bdfa3fa525502f321 (patch) | |
| tree | 9027e6f6886937afa463563dae176e5757cf006e /std/os | |
| parent | a6bf37f8ca5a2eabc7cacb22696d2a2c622a993d (diff) | |
| parent | 780e5674467ebac4534cd3d3f2199ccaf1d0922c (diff) | |
| download | zig-a2abdb185f9e47b663edce1bdfa3fa525502f321.tar.gz zig-a2abdb185f9e47b663edce1bdfa3fa525502f321.zip | |
Merge remote-tracking branch 'origin/master' into llvm7
Diffstat (limited to 'std/os')
| -rw-r--r-- | std/os/child_process.zig | 12 | ||||
| -rw-r--r-- | std/os/index.zig | 38 | ||||
| -rw-r--r-- | std/os/windows/kernel32.zig | 1 | ||||
| -rw-r--r-- | std/os/windows/util.zig | 7 |
4 files changed, 35 insertions, 23 deletions
diff --git a/std/os/child_process.zig b/std/os/child_process.zig index a8f307f3b6..8b76a3cb9e 100644 --- a/std/os/child_process.zig +++ b/std/os/child_process.zig @@ -658,8 +658,16 @@ fn windowsCreateProcess(app_name: [*]u16, cmd_line: [*]u16, envp_ptr: ?[*]u16, c // environment variables to programs that were not, which seems unlikely. // More investigation is needed. if (windows.CreateProcessW( - app_name, cmd_line, null, null, windows.TRUE, windows.CREATE_UNICODE_ENVIRONMENT, - @ptrCast(?*c_void, envp_ptr), cwd_ptr, lpStartupInfo, lpProcessInformation, + app_name, + cmd_line, + null, + null, + windows.TRUE, + windows.CREATE_UNICODE_ENVIRONMENT, + @ptrCast(?*c_void, envp_ptr), + cwd_ptr, + lpStartupInfo, + lpProcessInformation, ) == 0) { const err = windows.GetLastError(); switch (err) { diff --git a/std/os/index.zig b/std/os/index.zig index 3ab73a79ac..d4110bd759 100644 --- a/std/os/index.zig +++ b/std/os/index.zig @@ -6,7 +6,7 @@ const is_posix = switch (builtin.os) { builtin.Os.linux, builtin.Os.macosx => true, else => false, }; -const os = this; +const os = @This(); test "std.os" { _ = @import("child_process.zig"); @@ -343,23 +343,25 @@ pub fn posixWrite(fd: i32, bytes: []const u8) !void { const amt_to_write = math.min(bytes.len - index, usize(max_bytes_len)); const rc = posix.write(fd, bytes.ptr + index, amt_to_write); const write_err = posix.getErrno(rc); - if (write_err > 0) { - return switch (write_err) { - posix.EINTR => continue, - posix.EINVAL, posix.EFAULT => unreachable, - posix.EAGAIN => PosixWriteError.WouldBlock, - posix.EBADF => PosixWriteError.FileClosed, - posix.EDESTADDRREQ => PosixWriteError.DestinationAddressRequired, - posix.EDQUOT => PosixWriteError.DiskQuota, - posix.EFBIG => PosixWriteError.FileTooBig, - posix.EIO => PosixWriteError.InputOutput, - posix.ENOSPC => PosixWriteError.NoSpaceLeft, - posix.EPERM => PosixWriteError.AccessDenied, - posix.EPIPE => PosixWriteError.BrokenPipe, - else => unexpectedErrorPosix(write_err), - }; + switch (write_err) { + 0 => { + index += rc; + continue; + }, + posix.EINTR => continue, + posix.EINVAL => unreachable, + posix.EFAULT => unreachable, + posix.EAGAIN => return PosixWriteError.WouldBlock, + posix.EBADF => return PosixWriteError.FileClosed, + posix.EDESTADDRREQ => return PosixWriteError.DestinationAddressRequired, + posix.EDQUOT => return PosixWriteError.DiskQuota, + posix.EFBIG => return PosixWriteError.FileTooBig, + posix.EIO => return PosixWriteError.InputOutput, + posix.ENOSPC => return PosixWriteError.NoSpaceLeft, + posix.EPERM => return PosixWriteError.AccessDenied, + posix.EPIPE => return PosixWriteError.BrokenPipe, + else => return unexpectedErrorPosix(write_err), } - index += rc; } } @@ -1614,7 +1616,7 @@ pub const Dir = struct { return null; } const name_utf16le = mem.toSlice(u16, self.handle.find_file_data.cFileName[0..].ptr); - if (mem.eql(u16, name_utf16le, []u16{'.'}) or mem.eql(u16, name_utf16le, []u16{'.', '.'})) + if (mem.eql(u16, name_utf16le, []u16{'.'}) or mem.eql(u16, name_utf16le, []u16{ '.', '.' })) continue; // Trust that Windows gives us valid UTF-16LE const name_utf8_len = std.unicode.utf16leToUtf8(self.handle.name_data[0..], name_utf16le) catch unreachable; diff --git a/std/os/windows/kernel32.zig b/std/os/windows/kernel32.zig index 1a7b28eac2..94b339fa6e 100644 --- a/std/os/windows/kernel32.zig +++ b/std/os/windows/kernel32.zig @@ -206,7 +206,6 @@ pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2; pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1; pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4; - pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct { dwSize: COORD, dwCursorPosition: COORD, diff --git a/std/os/windows/util.zig b/std/os/windows/util.zig index a489cca163..6534d16f5e 100644 --- a/std/os/windows/util.zig +++ b/std/os/windows/util.zig @@ -52,7 +52,8 @@ pub const WriteError = error{ }; pub fn windowsWrite(handle: windows.HANDLE, bytes: []const u8) WriteError!void { - if (windows.WriteFile(handle, bytes.ptr, @intCast(u32, bytes.len), null, null) == 0) { + var bytes_written: windows.DWORD = undefined; + if (windows.WriteFile(handle, bytes.ptr, @intCast(u32, bytes.len), &bytes_written, null) == 0) { const err = windows.GetLastError(); return switch (err) { windows.ERROR.INVALID_USER_BUFFER => WriteError.SystemResources, @@ -222,7 +223,7 @@ pub fn windowsFindFirstFile( dir_path: []const u8, find_file_data: *windows.WIN32_FIND_DATAW, ) !windows.HANDLE { - const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, []u16{'\\', '*', 0}); + const dir_path_w = try sliceToPrefixedSuffixedFileW(dir_path, []u16{ '\\', '*', 0 }); const handle = windows.FindFirstFileW(&dir_path_w, find_file_data); if (handle == windows.INVALID_HANDLE_VALUE) { @@ -277,6 +278,7 @@ pub const WindowsWaitResult = enum { Normal, Aborted, Cancelled, + EOF, }; pub fn windowsGetQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_transferred_count: *windows.DWORD, lpCompletionKey: *usize, lpOverlapped: *?*windows.OVERLAPPED, dwMilliseconds: windows.DWORD) WindowsWaitResult { @@ -285,6 +287,7 @@ pub fn windowsGetQueuedCompletionStatus(completion_port: windows.HANDLE, bytes_t switch (err) { windows.ERROR.ABANDONED_WAIT_0 => return WindowsWaitResult.Aborted, windows.ERROR.OPERATION_ABORTED => return WindowsWaitResult.Cancelled, + windows.ERROR.HANDLE_EOF => return WindowsWaitResult.EOF, else => { if (std.debug.runtime_safety) { std.debug.panic("unexpected error: {}\n", err); |
