zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit accde7fe2d8966ed181af4e819dc73e4d11caef9 (tree)
parent 0be1e74902e9bfb7dd35d2a3ba927db76f6d67c7
Author: Vincent Rischmann <vincent@rischmann.fr>
Date:   Mon, 19 Apr 2021 23:14:55 +0200

windows: add wrappers for LocalFree, SetThreadDescription and GetThreadDescription

Diffstat:
Mlib/std/os/windows.zig | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig @@ -1631,6 +1631,10 @@ pub fn HeapDestroy(hHeap: HANDLE) void { assert(kernel32.HeapDestroy(hHeap) != 0); } +pub fn LocalFree(hMem: HLOCAL) void { + assert(kernel32.LocalFree(hMem) == null); +} + pub const GetFileInformationByHandleError = error{Unexpected}; pub fn GetFileInformationByHandle( @@ -2011,6 +2015,21 @@ pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError { return error.Unexpected; } +pub fn SetThreadDescription(hThread: HANDLE, lpThreadDescription: LPCWSTR) !void { + if (kernel32.SetThreadDescription(hThread, lpThreadDescription) == 0) { + switch (kernel32.GetLastError()) { + else => |err| return unexpectedError(err), + } + } +} +pub fn GetThreadDescription(hThread: HANDLE, ppszThreadDescription: *LPWSTR) !void { + if (kernel32.GetThreadDescription(hThread, ppszThreadDescription) == 0) { + switch (kernel32.GetLastError()) { + else => |err| return unexpectedError(err), + } + } +} + test "" { if (builtin.os.tag == .windows) { _ = @import("windows/test.zig");