aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-01-27 20:25:48 +0200
committerVeikka Tuominen <git@vexu.eu>2023-01-30 18:55:57 +0200
commitf16c10a86b7183e99e54a70344f4681211cd52bb (patch)
treeaa6c1f3510696eb5ee63dd4ddb17c96cc6dce45b /lib
parentfe4ea31f7e9e1c8caea6a1df107b91e8ea1a7b8a (diff)
downloadzig-f16c10a86b7183e99e54a70344f4681211cd52bb.tar.gz
zig-f16c10a86b7183e99e54a70344f4681211cd52bb.zip
implement `@qualCast`
Diffstat (limited to 'lib')
-rw-r--r--lib/std/child_process.zig4
-rw-r--r--lib/std/fs.zig2
-rw-r--r--lib/std/os.zig2
-rw-r--r--lib/std/os/windows.zig14
-rw-r--r--lib/std/zig/c_translation.zig2
5 files changed, 12 insertions, 12 deletions
diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig
index 4a816c8318..21d7b4fe3e 100644
--- a/lib/std/child_process.zig
+++ b/lib/std/child_process.zig
@@ -1164,7 +1164,7 @@ fn windowsCreateProcessPathExt(
var app_name_unicode_string = windows.UNICODE_STRING{
.Length = app_name_len_bytes,
.MaximumLength = app_name_len_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(app_name_wildcard.ptr)),
+ .Buffer = @qualCast([*:0]u16, app_name_wildcard.ptr),
};
const rc = windows.ntdll.NtQueryDirectoryFile(
dir.fd,
@@ -1261,7 +1261,7 @@ fn windowsCreateProcessPathExt(
var app_name_unicode_string = windows.UNICODE_STRING{
.Length = app_name_len_bytes,
.MaximumLength = app_name_len_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(app_name_appended.ptr)),
+ .Buffer = @qualCast([*:0]u16, app_name_appended.ptr),
};
// Re-use the directory handle but this time we call with the appended app name
diff --git a/lib/std/fs.zig b/lib/std/fs.zig
index 244f3a38ce..2300ad044a 100644
--- a/lib/std/fs.zig
+++ b/lib/std/fs.zig
@@ -1763,7 +1763,7 @@ pub const Dir = struct {
var nt_name = w.UNICODE_STRING{
.Length = path_len_bytes,
.MaximumLength = path_len_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(sub_path_w)),
+ .Buffer = @qualCast([*:0]u16, sub_path_w),
};
var attr = w.OBJECT_ATTRIBUTES{
.Length = @sizeOf(w.OBJECT_ATTRIBUTES),
diff --git a/lib/std/os.zig b/lib/std/os.zig
index 32463aa30e..3cee30c32d 100644
--- a/lib/std/os.zig
+++ b/lib/std/os.zig
@@ -4513,7 +4513,7 @@ pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32
var nt_name = windows.UNICODE_STRING{
.Length = path_len_bytes,
.MaximumLength = path_len_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(sub_path_w)),
+ .Buffer = @qualCast([*:0]u16, sub_path_w),
};
var attr = windows.OBJECT_ATTRIBUTES{
.Length = @sizeOf(windows.OBJECT_ATTRIBUTES),
diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig
index e53387b27c..93e762827b 100644
--- a/lib/std/os/windows.zig
+++ b/lib/std/os/windows.zig
@@ -85,7 +85,7 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
var nt_name = UNICODE_STRING{
.Length = path_len_bytes,
.MaximumLength = path_len_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(sub_path_w.ptr)),
+ .Buffer = @qualCast([*]u16, sub_path_w.ptr),
};
var attr = OBJECT_ATTRIBUTES{
.Length = @sizeOf(OBJECT_ATTRIBUTES),
@@ -634,7 +634,7 @@ pub fn SetCurrentDirectory(path_name: []const u16) SetCurrentDirectoryError!void
var nt_name = UNICODE_STRING{
.Length = path_len_bytes,
.MaximumLength = path_len_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(path_name.ptr)),
+ .Buffer = @qualCast([*]u16, path_name.ptr),
};
const rc = ntdll.RtlSetCurrentDirectory_U(&nt_name);
@@ -766,7 +766,7 @@ pub fn ReadLink(dir: ?HANDLE, sub_path_w: []const u16, out_buffer: []u8) ReadLin
var nt_name = UNICODE_STRING{
.Length = path_len_bytes,
.MaximumLength = path_len_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(sub_path_w.ptr)),
+ .Buffer = @qualCast([*]u16, sub_path_w.ptr),
};
var attr = OBJECT_ATTRIBUTES{
.Length = @sizeOf(OBJECT_ATTRIBUTES),
@@ -876,7 +876,7 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil
.Length = path_len_bytes,
.MaximumLength = path_len_bytes,
// The Windows API makes this mutable, but it will not mutate here.
- .Buffer = @intToPtr([*]u16, @ptrToInt(sub_path_w.ptr)),
+ .Buffer = @qualCast([*]u16, sub_path_w.ptr),
};
if (sub_path_w[0] == '.' and sub_path_w[1] == 0) {
@@ -1414,7 +1414,7 @@ pub fn sendmsg(
}
pub fn sendto(s: ws2_32.SOCKET, buf: [*]const u8, len: usize, flags: u32, to: ?*const ws2_32.sockaddr, to_len: ws2_32.socklen_t) i32 {
- var buffer = ws2_32.WSABUF{ .len = @truncate(u31, len), .buf = @intToPtr([*]u8, @ptrToInt(buf)) };
+ var buffer = ws2_32.WSABUF{ .len = @truncate(u31, len), .buf = @qualCast([*]u8, buf) };
var bytes_send: DWORD = undefined;
if (ws2_32.WSASendTo(s, @ptrCast([*]ws2_32.WSABUF, &buffer), 1, &bytes_send, flags, to, @intCast(i32, to_len), null, null) == ws2_32.SOCKET_ERROR) {
return ws2_32.SOCKET_ERROR;
@@ -1876,13 +1876,13 @@ pub fn eqlIgnoreCaseWTF16(a: []const u16, b: []const u16) bool {
const a_string = UNICODE_STRING{
.Length = a_bytes,
.MaximumLength = a_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(a.ptr)),
+ .Buffer = @qualCast([*]u16, a.ptr),
};
const b_bytes = @intCast(u16, b.len * 2);
const b_string = UNICODE_STRING{
.Length = b_bytes,
.MaximumLength = b_bytes,
- .Buffer = @intToPtr([*]u16, @ptrToInt(b.ptr)),
+ .Buffer = @qualCast([*]u16, b.ptr),
};
return ntdll.RtlEqualUnicodeString(&a_string, &b_string, TRUE) == TRUE;
}
diff --git a/lib/std/zig/c_translation.zig b/lib/std/zig/c_translation.zig
index a050e592a2..d33c74d777 100644
--- a/lib/std/zig/c_translation.zig
+++ b/lib/std/zig/c_translation.zig
@@ -75,7 +75,7 @@ fn castPtr(comptime DestType: type, target: anytype) DestType {
const source = ptrInfo(@TypeOf(target));
if (source.is_const and !dest.is_const or source.is_volatile and !dest.is_volatile)
- return @intToPtr(DestType, @ptrToInt(target))
+ return @qualCast(DestType, target)
else if (@typeInfo(dest.child) == .Opaque)
// dest.alignment would error out
return @ptrCast(DestType, target)