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/c | |
| 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/c')
| -rw-r--r-- | lib/std/c/darwin.zig | 68 | ||||
| -rw-r--r-- | lib/std/c/dragonfly.zig | 20 | ||||
| -rw-r--r-- | lib/std/c/freebsd.zig | 22 | ||||
| -rw-r--r-- | lib/std/c/haiku.zig | 10 | ||||
| -rw-r--r-- | lib/std/c/linux.zig | 2 | ||||
| -rw-r--r-- | lib/std/c/netbsd.zig | 16 | ||||
| -rw-r--r-- | lib/std/c/openbsd.zig | 14 | ||||
| -rw-r--r-- | lib/std/c/solaris.zig | 28 |
8 files changed, 90 insertions, 90 deletions
diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index 6dd517eada..0f60c2f841 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -1177,10 +1177,10 @@ pub const sigset_t = u32; pub const empty_sigset: sigset_t = 0; pub const SIG = struct { - pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); - pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); - pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); - pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 5); + pub const ERR = @as(?Sigaction.handler_fn, @ptrFromInt(maxInt(usize))); + pub const DFL = @as(?Sigaction.handler_fn, @ptrFromInt(0)); + pub const IGN = @as(?Sigaction.handler_fn, @ptrFromInt(1)); + pub const HOLD = @as(?Sigaction.handler_fn, @ptrFromInt(5)); /// block specified signal set pub const _BLOCK = 1; @@ -1411,7 +1411,7 @@ pub const MAP = struct { pub const NOCACHE = 0x0400; /// don't reserve needed swap area pub const NORESERVE = 0x0040; - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); }; pub const MSF = struct { @@ -1879,7 +1879,7 @@ pub const W = struct { pub const UNTRACED = 0x00000002; pub fn EXITSTATUS(x: u32) u8 { - return @intCast(u8, x >> 8); + return @as(u8, @intCast(x >> 8)); } pub fn TERMSIG(x: u32) u32 { return status(x); @@ -2463,7 +2463,7 @@ pub const KernE = enum(u32) { pub const mach_msg_return_t = kern_return_t; pub fn getMachMsgError(err: mach_msg_return_t) MachMsgE { - return @enumFromInt(MachMsgE, @truncate(u32, @intCast(usize, err))); + return @as(MachMsgE, @enumFromInt(@as(u32, @truncate(@as(usize, @intCast(err)))))); } /// All special error code bits defined below. @@ -2665,10 +2665,10 @@ pub const RTLD = struct { pub const NODELETE = 0x80; pub const FIRST = 0x100; - pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); - pub const MAIN_ONLY = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -5))); + pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); + pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); + pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); + pub const MAIN_ONLY = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -5))))); }; pub const F = struct { @@ -3238,14 +3238,14 @@ pub const PosixSpawn = struct { pub fn get(self: Attr) Error!u16 { var flags: c_short = undefined; switch (errno(posix_spawnattr_getflags(&self.attr, &flags))) { - .SUCCESS => return @bitCast(u16, flags), + .SUCCESS => return @as(u16, @bitCast(flags)), .INVAL => unreachable, else => |err| return unexpectedErrno(err), } } pub fn set(self: *Attr, flags: u16) Error!void { - switch (errno(posix_spawnattr_setflags(&self.attr, @bitCast(c_short, flags)))) { + switch (errno(posix_spawnattr_setflags(&self.attr, @as(c_short, @bitCast(flags))))) { .SUCCESS => return, .INVAL => unreachable, else => |err| return unexpectedErrno(err), @@ -3281,7 +3281,7 @@ pub const PosixSpawn = struct { } pub fn openZ(self: *Actions, fd: fd_t, path: [*:0]const u8, flags: u32, mode: mode_t) Error!void { - switch (errno(posix_spawn_file_actions_addopen(&self.actions, fd, path, @bitCast(c_int, flags), mode))) { + switch (errno(posix_spawn_file_actions_addopen(&self.actions, fd, path, @as(c_int, @bitCast(flags)), mode))) { .SUCCESS => return, .BADF => return error.InvalidFileDescriptor, .NOMEM => return error.SystemResources, @@ -3402,11 +3402,11 @@ pub const PosixSpawn = struct { pub fn waitpid(pid: pid_t, flags: u32) Error!std.os.WaitPidResult { var status: c_int = undefined; while (true) { - const rc = waitpid(pid, &status, @intCast(c_int, flags)); + const rc = waitpid(pid, &status, @as(c_int, @intCast(flags))); switch (errno(rc)) { .SUCCESS => return std.os.WaitPidResult{ - .pid = @intCast(pid_t, rc), - .status = @bitCast(u32, status), + .pid = @as(pid_t, @intCast(rc)), + .status = @as(u32, @bitCast(status)), }, .INTR => continue, .CHILD => return error.ChildExecFailed, @@ -3418,7 +3418,7 @@ pub const PosixSpawn = struct { }; pub fn getKernError(err: kern_return_t) KernE { - return @enumFromInt(KernE, @truncate(u32, @intCast(usize, err))); + return @as(KernE, @enumFromInt(@as(u32, @truncate(@as(usize, @intCast(err)))))); } pub fn unexpectedKernError(err: KernE) std.os.UnexpectedError { @@ -3585,9 +3585,9 @@ pub const MachTask = extern struct { .top => VM_REGION_TOP_INFO, }, switch (tag) { - .basic => @ptrCast(vm_region_info_t, &info.info.basic), - .extended => @ptrCast(vm_region_info_t, &info.info.extended), - .top => @ptrCast(vm_region_info_t, &info.info.top), + .basic => @as(vm_region_info_t, @ptrCast(&info.info.basic)), + .extended => @as(vm_region_info_t, @ptrCast(&info.info.extended)), + .top => @as(vm_region_info_t, @ptrCast(&info.info.top)), }, &count, &objname, @@ -3640,8 +3640,8 @@ pub const MachTask = extern struct { &base_len, &nesting, switch (tag) { - .short => @ptrCast(vm_region_recurse_info_t, &info.info.short), - .full => @ptrCast(vm_region_recurse_info_t, &info.info.full), + .short => @as(vm_region_recurse_info_t, @ptrCast(&info.info.short)), + .full => @as(vm_region_recurse_info_t, @ptrCast(&info.info.full)), }, &count, ))) { @@ -3701,7 +3701,7 @@ pub const MachTask = extern struct { task.port, curr_addr, @intFromPtr(out_buf.ptr), - @intCast(mach_msg_type_number_t, curr_size), + @as(mach_msg_type_number_t, @intCast(curr_size)), ))) { .SUCCESS => {}, .FAILURE => return error.PermissionDenied, @@ -3752,7 +3752,7 @@ pub const MachTask = extern struct { else => |err| return unexpectedKernError(err), } - @memcpy(out_buf[0..curr_bytes_read], @ptrFromInt([*]const u8, vm_memory)); + @memcpy(out_buf[0..curr_bytes_read], @as([*]const u8, @ptrFromInt(vm_memory))); _ = vm_deallocate(mach_task_self(), vm_memory, curr_bytes_read); out_buf = out_buf[curr_bytes_read..]; @@ -3782,10 +3782,10 @@ pub const MachTask = extern struct { switch (getKernError(task_info( task.port, TASK_VM_INFO, - @ptrCast(task_info_t, &vm_info), + @as(task_info_t, @ptrCast(&vm_info)), &info_count, ))) { - .SUCCESS => return @intCast(usize, vm_info.page_size), + .SUCCESS => return @as(usize, @intCast(vm_info.page_size)), else => {}, } } @@ -3802,7 +3802,7 @@ pub const MachTask = extern struct { switch (getKernError(task_info( task.port, MACH_TASK_BASIC_INFO, - @ptrCast(task_info_t, &info), + @as(task_info_t, @ptrCast(&info)), &count, ))) { .SUCCESS => return info, @@ -3832,7 +3832,7 @@ pub const MachTask = extern struct { _ = vm_deallocate( self_task.port, @intFromPtr(list.buf.ptr), - @intCast(vm_size_t, list.buf.len * @sizeOf(mach_port_t)), + @as(vm_size_t, @intCast(list.buf.len * @sizeOf(mach_port_t))), ); } }; @@ -3841,7 +3841,7 @@ pub const MachTask = extern struct { var thread_list: mach_port_array_t = undefined; var thread_count: mach_msg_type_number_t = undefined; switch (getKernError(task_threads(task.port, &thread_list, &thread_count))) { - .SUCCESS => return ThreadList{ .buf = @ptrCast([*]MachThread, thread_list)[0..thread_count] }, + .SUCCESS => return ThreadList{ .buf = @as([*]MachThread, @ptrCast(thread_list))[0..thread_count] }, else => |err| return unexpectedKernError(err), } } @@ -3860,7 +3860,7 @@ pub const MachThread = extern struct { switch (getKernError(thread_info( thread.port, THREAD_BASIC_INFO, - @ptrCast(thread_info_t, &info), + @as(thread_info_t, @ptrCast(&info)), &count, ))) { .SUCCESS => return info, @@ -3874,7 +3874,7 @@ pub const MachThread = extern struct { switch (getKernError(thread_info( thread.port, THREAD_IDENTIFIER_INFO, - @ptrCast(thread_info_t, &info), + @as(thread_info_t, @ptrCast(&info)), &count, ))) { .SUCCESS => return info, @@ -3962,7 +3962,7 @@ pub const thread_affinity_policy_t = [*]thread_affinity_policy; pub const THREAD_AFFINITY = struct { pub const POLICY = 0; - pub const POLICY_COUNT = @intCast(mach_msg_type_number_t, @sizeOf(thread_affinity_policy_data_t) / @sizeOf(integer_t)); + pub const POLICY_COUNT = @as(mach_msg_type_number_t, @intCast(@sizeOf(thread_affinity_policy_data_t) / @sizeOf(integer_t))); }; /// cpu affinity api @@ -4041,7 +4041,7 @@ pub const host_preferred_user_arch_data_t = host_preferred_user_arch; pub const host_preferred_user_arch_t = *host_preferred_user_arch; fn HostCount(comptime HT: type) mach_msg_type_number_t { - return @intCast(mach_msg_type_number_t, @sizeOf(HT) / @sizeOf(integer_t)); + return @as(mach_msg_type_number_t, @intCast(@sizeOf(HT) / @sizeOf(integer_t))); } pub const HOST = struct { diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index 912bb99056..6782aa098a 100644 --- a/lib/std/c/dragonfly.zig +++ b/lib/std/c/dragonfly.zig @@ -172,7 +172,7 @@ pub const PROT = struct { pub const MAP = struct { pub const FILE = 0; - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); pub const ANONYMOUS = ANON; pub const COPY = PRIVATE; pub const SHARED = 1; @@ -208,7 +208,7 @@ pub const W = struct { pub const TRAPPED = 0x0020; pub fn EXITSTATUS(s: u32) u8 { - return @intCast(u8, (s & 0xff00) >> 8); + return @as(u8, @intCast((s & 0xff00) >> 8)); } pub fn TERMSIG(s: u32) u32 { return s & 0x7f; @@ -220,7 +220,7 @@ pub const W = struct { return TERMSIG(s) == 0; } pub fn IFSTOPPED(s: u32) bool { - return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; + return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; } pub fn IFSIGNALED(s: u32) bool { return (s & 0xffff) -% 1 < 0xff; @@ -620,9 +620,9 @@ pub const S = struct { pub const BADSIG = SIG.ERR; pub const SIG = struct { - pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); - pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); - pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @as(?Sigaction.handler_fn, @ptrFromInt(0)); + pub const IGN = @as(?Sigaction.handler_fn, @ptrFromInt(1)); + pub const ERR = @as(?Sigaction.handler_fn, @ptrFromInt(maxInt(usize))); pub const BLOCK = 1; pub const UNBLOCK = 2; @@ -871,10 +871,10 @@ pub const RTLD = struct { pub const NODELETE = 0x01000; pub const NOLOAD = 0x02000; - pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); - pub const ALL = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -4))); + pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); + pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); + pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); + pub const ALL = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -4))))); }; pub const dl_phdr_info = extern struct { diff --git a/lib/std/c/freebsd.zig b/lib/std/c/freebsd.zig index 7a265ac2b3..deec41493d 100644 --- a/lib/std/c/freebsd.zig +++ b/lib/std/c/freebsd.zig @@ -20,11 +20,11 @@ fn __BIT_COUNT(bits: []const c_long) c_long { fn __BIT_MASK(s: usize) c_long { var x = s % CPU_SETSIZE; - return @bitCast(c_long, @intCast(c_ulong, 1) << @intCast(u6, x)); + return @as(c_long, @bitCast(@as(c_ulong, @intCast(1)) << @as(u6, @intCast(x)))); } pub fn CPU_COUNT(set: cpuset_t) c_int { - return @intCast(c_int, __BIT_COUNT(set.__bits[0..])); + return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..]))); } pub fn CPU_ZERO(set: *cpuset_t) void { @@ -529,7 +529,7 @@ pub const cap_rights_t = extern struct { pub const CAP = struct { pub fn RIGHT(idx: u6, bit: u64) u64 { - return (@intCast(u64, 1) << (57 + idx)) | bit; + return (@as(u64, @intCast(1)) << (57 + idx)) | bit; } pub const READ = CAP.RIGHT(0, 0x0000000000000001); pub const WRITE = CAP.RIGHT(0, 0x0000000000000002); @@ -961,7 +961,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const FIXED = 0x0010; @@ -1013,7 +1013,7 @@ pub const W = struct { pub const TRAPPED = 32; pub fn EXITSTATUS(s: u32) u8 { - return @intCast(u8, (s & 0xff00) >> 8); + return @as(u8, @intCast((s & 0xff00) >> 8)); } pub fn TERMSIG(s: u32) u32 { return s & 0x7f; @@ -1025,7 +1025,7 @@ pub const W = struct { return TERMSIG(s) == 0; } pub fn IFSTOPPED(s: u32) bool { - return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; + return @as(u16, @truncate((((s & 0xffff) *% 0x10001) >> 8))) > 0x7f00; } pub fn IFSIGNALED(s: u32) bool { return (s & 0xffff) -% 1 < 0xff; @@ -1086,9 +1086,9 @@ pub const SIG = struct { pub const UNBLOCK = 2; pub const SETMASK = 3; - pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); - pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); - pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @as(?Sigaction.handler_fn, @ptrFromInt(0)); + pub const IGN = @as(?Sigaction.handler_fn, @ptrFromInt(1)); + pub const ERR = @as(?Sigaction.handler_fn, @ptrFromInt(maxInt(usize))); pub const WORDS = 4; pub const MAXSIG = 128; @@ -2626,7 +2626,7 @@ pub const domainset_t = extern struct { }; pub fn DOMAINSET_COUNT(set: domainset_t) c_int { - return @intCast(c_int, __BIT_COUNT(set.__bits[0..])); + return @as(c_int, @intCast(__BIT_COUNT(set.__bits[0..]))); } pub const domainset = extern struct { @@ -2650,7 +2650,7 @@ const ioctl_cmd = enum(u32) { }; fn ioImpl(cmd: ioctl_cmd, op: u8, nr: u8, comptime IT: type) u32 { - return @bitCast(u32, @intFromEnum(cmd) | @intCast(u32, @truncate(u8, @sizeOf(IT))) << 16 | @intCast(u32, op) << 8 | nr); + return @as(u32, @bitCast(@intFromEnum(cmd) | @as(u32, @intCast(@as(u8, @truncate(@sizeOf(IT))))) << 16 | @as(u32, @intCast(op)) << 8 | nr)); } pub fn IO(op: u8, nr: u8) u32 { diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index 2f9917a0f3..c47ceeb003 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -414,7 +414,7 @@ pub const CLOCK = struct { pub const MAP = struct { /// mmap() error return code - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); /// changes are seen by others pub const SHARED = 0x01; /// changes are only seen by caller @@ -443,7 +443,7 @@ pub const W = struct { pub const NOWAIT = 0x20; pub fn EXITSTATUS(s: u32) u8 { - return @intCast(u8, s & 0xff); + return @as(u8, @intCast(s & 0xff)); } pub fn TERMSIG(s: u32) u32 { @@ -481,9 +481,9 @@ pub const SA = struct { }; pub const SIG = struct { - pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); - pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); - pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); + pub const ERR = @as(?Sigaction.handler_fn, @ptrFromInt(maxInt(usize))); + pub const DFL = @as(?Sigaction.handler_fn, @ptrFromInt(0)); + pub const IGN = @as(?Sigaction.handler_fn, @ptrFromInt(1)); pub const HUP = 1; pub const INT = 2; diff --git a/lib/std/c/linux.zig b/lib/std/c/linux.zig index d3a3bfdeba..ddc488e115 100644 --- a/lib/std/c/linux.zig +++ b/lib/std/c/linux.zig @@ -32,7 +32,7 @@ pub const MADV = linux.MADV; pub const MAP = struct { pub usingnamespace linux.MAP; /// Only used by libc to communicate failure. - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); }; pub const MSF = linux.MSF; pub const MMAP2_UNIT = linux.MMAP2_UNIT; diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig index 2c7c236ed0..1fc0784287 100644 --- a/lib/std/c/netbsd.zig +++ b/lib/std/c/netbsd.zig @@ -172,9 +172,9 @@ pub const RTLD = struct { pub const NODELETE = 0x01000; pub const NOLOAD = 0x02000; - pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); + pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); + pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); + pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); }; pub const dl_phdr_info = extern struct { @@ -597,7 +597,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const REMAPDUP = 0x0004; @@ -653,7 +653,7 @@ pub const W = struct { pub const TRAPPED = 0x00000040; pub fn EXITSTATUS(s: u32) u8 { - return @intCast(u8, (s >> 8) & 0xff); + return @as(u8, @intCast((s >> 8) & 0xff)); } pub fn TERMSIG(s: u32) u32 { return s & 0x7f; @@ -1106,9 +1106,9 @@ pub const winsize = extern struct { const NSIG = 32; pub const SIG = struct { - pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); - pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); - pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); + pub const DFL = @as(?Sigaction.handler_fn, @ptrFromInt(0)); + pub const IGN = @as(?Sigaction.handler_fn, @ptrFromInt(1)); + pub const ERR = @as(?Sigaction.handler_fn, @ptrFromInt(maxInt(usize))); pub const WORDS = 4; pub const MAXSIG = 128; diff --git a/lib/std/c/openbsd.zig b/lib/std/c/openbsd.zig index 47c1aec862..06085903e4 100644 --- a/lib/std/c/openbsd.zig +++ b/lib/std/c/openbsd.zig @@ -449,7 +449,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const FIXED = 0x0010; @@ -488,7 +488,7 @@ pub const W = struct { pub const CONTINUED = 8; pub fn EXITSTATUS(s: u32) u8 { - return @intCast(u8, (s >> 8) & 0xff); + return @as(u8, @intCast((s >> 8) & 0xff)); } pub fn TERMSIG(s: u32) u32 { return (s & 0x7f); @@ -1000,11 +1000,11 @@ pub const winsize = extern struct { const NSIG = 33; pub const SIG = struct { - pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); - pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); - pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); - pub const CATCH = @ptrFromInt(?Sigaction.handler_fn, 2); - pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 3); + pub const DFL = @as(?Sigaction.handler_fn, @ptrFromInt(0)); + pub const IGN = @as(?Sigaction.handler_fn, @ptrFromInt(1)); + pub const ERR = @as(?Sigaction.handler_fn, @ptrFromInt(maxInt(usize))); + pub const CATCH = @as(?Sigaction.handler_fn, @ptrFromInt(2)); + pub const HOLD = @as(?Sigaction.handler_fn, @ptrFromInt(3)); pub const HUP = 1; pub const INT = 2; diff --git a/lib/std/c/solaris.zig b/lib/std/c/solaris.zig index 511bf9ccc5..cbca1805bb 100644 --- a/lib/std/c/solaris.zig +++ b/lib/std/c/solaris.zig @@ -111,10 +111,10 @@ pub const RTLD = struct { pub const FIRST = 0x02000; pub const CONFGEN = 0x10000; - pub const NEXT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -1))); - pub const DEFAULT = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -2))); - pub const SELF = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -3))); - pub const PROBE = @ptrFromInt(*anyopaque, @bitCast(usize, @as(isize, -4))); + pub const NEXT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -1))))); + pub const DEFAULT = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -2))))); + pub const SELF = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -3))))); + pub const PROBE = @as(*anyopaque, @ptrFromInt(@as(usize, @bitCast(@as(isize, -4))))); }; pub const Flock = extern struct { @@ -524,7 +524,7 @@ pub const CLOCK = struct { }; pub const MAP = struct { - pub const FAILED = @ptrFromInt(*anyopaque, maxInt(usize)); + pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize))); pub const SHARED = 0x0001; pub const PRIVATE = 0x0002; pub const TYPE = 0x000f; @@ -583,7 +583,7 @@ pub const W = struct { pub const NOWAIT = 0o200; pub fn EXITSTATUS(s: u32) u8 { - return @intCast(u8, (s >> 8) & 0xff); + return @as(u8, @intCast((s >> 8) & 0xff)); } pub fn TERMSIG(s: u32) u32 { return s & 0x7f; @@ -886,10 +886,10 @@ pub const winsize = extern struct { const NSIG = 75; pub const SIG = struct { - pub const DFL = @ptrFromInt(?Sigaction.handler_fn, 0); - pub const ERR = @ptrFromInt(?Sigaction.handler_fn, maxInt(usize)); - pub const IGN = @ptrFromInt(?Sigaction.handler_fn, 1); - pub const HOLD = @ptrFromInt(?Sigaction.handler_fn, 2); + pub const DFL = @as(?Sigaction.handler_fn, @ptrFromInt(0)); + pub const ERR = @as(?Sigaction.handler_fn, @ptrFromInt(maxInt(usize))); + pub const IGN = @as(?Sigaction.handler_fn, @ptrFromInt(1)); + pub const HOLD = @as(?Sigaction.handler_fn, @ptrFromInt(2)); pub const WORDS = 4; pub const MAXSIG = 75; @@ -1441,7 +1441,7 @@ pub const AT = struct { /// Magic value that specify the use of the current working directory /// to determine the target of relative file paths in the openat() and /// similar syscalls. - pub const FDCWD = @bitCast(fd_t, @as(u32, 0xffd19553)); + pub const FDCWD = @as(fd_t, @bitCast(@as(u32, 0xffd19553))); /// Do not follow symbolic links pub const SYMLINK_NOFOLLOW = 0x1000; @@ -1907,9 +1907,9 @@ const IoCtlCommand = enum(u32) { }; fn ioImpl(cmd: IoCtlCommand, io_type: u8, nr: u8, comptime IOT: type) i32 { - const size = @intCast(u32, @truncate(u8, @sizeOf(IOT))) << 16; - const t = @intCast(u32, io_type) << 8; - return @bitCast(i32, @intFromEnum(cmd) | size | t | nr); + const size = @as(u32, @intCast(@as(u8, @truncate(@sizeOf(IOT))))) << 16; + const t = @as(u32, @intCast(io_type)) << 8; + return @as(i32, @bitCast(@intFromEnum(cmd) | size | t | nr)); } pub fn IO(io_type: u8, nr: u8) i32 { |
