authorgravatar for vincent@rischmann.frVincent Rischmann <vincent@rischmann.fr> 2021-04-19 23:14:55+02:00
committergravatar for vincent@rischmann.frVincent Rischmann <vincent@rischmann.fr> 2021-07-29 10:57:08+02:00
logaccde7fe2d8966ed181af4e819dc73e4d11caef9
tree2fb3fb1a5f60e3fc87b331570e135a80d526446e
parent0be1e74902e9bfb7dd35d2a3ba927db76f6d67c7

windows: add wrappers for LocalFree, SetThreadDescription and GetThreadDescription


1 files changed, 19 insertions(+), 0 deletions(-)

lib/std/os/windows.zig+19
......@@ -1631,6 +1631,10 @@ pub fn HeapDestroy(hHeap: HANDLE) void {
16311631 assert(kernel32.HeapDestroy(hHeap) != 0);
16321632}
16331633
1634pub fn LocalFree(hMem: HLOCAL) void {
1635 assert(kernel32.LocalFree(hMem) == null);
1636}
1637
16341638pub const GetFileInformationByHandleError = error{Unexpected};
16351639
16361640pub fn GetFileInformationByHandle(
......@@ -2011,6 +2015,21 @@ pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError {
20112015 return error.Unexpected;
20122016}
20132017
2018pub fn SetThreadDescription(hThread: HANDLE, lpThreadDescription: LPCWSTR) !void {
2019 if (kernel32.SetThreadDescription(hThread, lpThreadDescription) == 0) {
2020 switch (kernel32.GetLastError()) {
2021 else => |err| return unexpectedError(err),
2022 }
2023 }
2024}
2025pub fn GetThreadDescription(hThread: HANDLE, ppszThreadDescription: *LPWSTR) !void {
2026 if (kernel32.GetThreadDescription(hThread, ppszThreadDescription) == 0) {
2027 switch (kernel32.GetLastError()) {
2028 else => |err| return unexpectedError(err),
2029 }
2030 }
2031}
2032
20142033test "" {
20152034 if (builtin.os.tag == .windows) {
20162035 _ = @import("windows/test.zig");