diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-06-24 16:58:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-24 16:58:19 -0700 |
| commit | 146b79af153bbd5dafda0ba12a040385c7fc58f8 (patch) | |
| tree | 67e3db8b444d65c667e314770fc983a7fc8ba293 /lib/std/process.zig | |
| parent | 13853bef0df3c90633021850cc6d6abaeea03282 (diff) | |
| parent | 21ac0beb436f49fe49c6982a872f2dc48e4bea5e (diff) | |
| download | zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.tar.gz zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.zip | |
Merge pull request #16163 from mlugg/feat/builtins-infer-dest-ty
Infer destination type of cast builtins using result type
Diffstat (limited to 'lib/std/process.zig')
| -rw-r--r-- | lib/std/process.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/std/process.zig b/lib/std/process.zig index 05066fa436..28d4bfcb25 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -68,7 +68,7 @@ pub const EnvMap = struct { pub const EnvNameHashContext = struct { fn upcase(c: u21) u21 { if (c <= std.math.maxInt(u16)) - return std.os.windows.ntdll.RtlUpcaseUnicodeChar(@intCast(u16, c)); + return std.os.windows.ntdll.RtlUpcaseUnicodeChar(@as(u16, @intCast(c))); return c; } @@ -80,9 +80,9 @@ pub const EnvMap = struct { while (it.nextCodepoint()) |cp| { const cp_upper = upcase(cp); h.update(&[_]u8{ - @intCast(u8, (cp_upper >> 16) & 0xff), - @intCast(u8, (cp_upper >> 8) & 0xff), - @intCast(u8, (cp_upper >> 0) & 0xff), + @as(u8, @intCast((cp_upper >> 16) & 0xff)), + @as(u8, @intCast((cp_upper >> 8) & 0xff)), + @as(u8, @intCast((cp_upper >> 0) & 0xff)), }); } return h.final(); @@ -872,8 +872,8 @@ pub fn argsFree(allocator: Allocator, args_alloc: []const [:0]u8) void { for (args_alloc) |arg| { total_bytes += @sizeOf([]u8) + arg.len + 1; } - const unaligned_allocated_buf = @ptrCast([*]const u8, args_alloc.ptr)[0..total_bytes]; - const aligned_allocated_buf = @alignCast(@alignOf([]u8), unaligned_allocated_buf); + const unaligned_allocated_buf = @as([*]const u8, @ptrCast(args_alloc.ptr))[0..total_bytes]; + const aligned_allocated_buf: []align(@alignOf([]u8)) const u8 = @alignCast(unaligned_allocated_buf); return allocator.free(aligned_allocated_buf); } @@ -1143,7 +1143,7 @@ pub fn execve( } else if (builtin.output_mode == .Exe) { // Then we have Zig start code and this works. // TODO type-safety for null-termination of `os.environ`. - break :m @ptrCast([*:null]const ?[*:0]const u8, os.environ.ptr); + break :m @as([*:null]const ?[*:0]const u8, @ptrCast(os.environ.ptr)); } else { // TODO come up with a solution for this. @compileError("missing std lib enhancement: std.process.execv implementation has no way to collect the environment variables to forward to the child process"); @@ -1175,7 +1175,7 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize { error.NameTooLong, error.UnknownName => unreachable, else => return error.UnknownTotalSystemMemory, }; - return @intCast(usize, physmem); + return @as(usize, @intCast(physmem)); }, .openbsd => { const mib: [2]c_int = [_]c_int{ @@ -1192,7 +1192,7 @@ pub fn totalSystemMemory() TotalSystemMemoryError!usize { else => return error.UnknownTotalSystemMemory, }; assert(physmem >= 0); - return @bitCast(usize, physmem); + return @as(usize, @bitCast(physmem)); }, .windows => { var sbi: std.os.windows.SYSTEM_BASIC_INFORMATION = undefined; |
