From e883ea50dd1154294e21e946e391dd38e04d6527 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 23 Oct 2022 12:55:40 -0400 Subject: Split up platform sources This puts more onus on the build system to do things properly, but it's still easy enough to build, even manually: all the files in the appropriate system subdirectory just need to be included in the build. Otherwise, the several nested levels of preprocessor conditionals get confusing, and clang-format doesn't format code properly. --- src/win32/thread_win32.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/win32/thread_win32.c (limited to 'src/win32/thread_win32.c') diff --git a/src/win32/thread_win32.c b/src/win32/thread_win32.c new file mode 100644 index 0000000..e4411b1 --- /dev/null +++ b/src/win32/thread_win32.c @@ -0,0 +1,28 @@ +// Copyright 2012-2022 David Robillard +// SPDX-License-Identifier: ISC + +#include "zix/thread.h" + +#include "zix/status.h" + +#include + +#include + +ZixStatus +zix_thread_create(ZixThread* thread, + size_t stack_size, + ZixThreadFunc function, + void* arg) +{ + *thread = CreateThread(NULL, stack_size, function, arg, 0, NULL); + return *thread ? ZIX_STATUS_SUCCESS : ZIX_STATUS_ERROR; +} + +ZixStatus +zix_thread_join(ZixThread thread) +{ + return (WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0) + ? ZIX_STATUS_SUCCESS + : ZIX_STATUS_ERROR; +} -- cgit v1.2.1