aboutsummaryrefslogtreecommitdiff
path: root/lib/std/process.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-06-22 18:46:56 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-06-24 16:56:39 -0700
commitf26dda21171e26f44aeec8c59a75bbb3331eeb2e (patch)
treec935248861ae2693b314f2c8bc78fe38d9961b6d /lib/std/process.zig
parent447ca4e3fff021f471b748187b53f0a4744ad0bc (diff)
downloadzig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.tar.gz
zig-f26dda21171e26f44aeec8c59a75bbb3331eeb2e.zip
all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
Diffstat (limited to 'lib/std/process.zig')
-rw-r--r--lib/std/process.zig18
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;