Add detached threads impl, make init order more robust, print to console with UTF16

This commit is contained in:
2026-07-15 21:48:41 +10:00
parent ec5f5e927b
commit a718c600b9
7 changed files with 228 additions and 88 deletions
+14 -4
View File
@@ -1,4 +1,4 @@
// Generated by the DN single header generator 2026-07-15 17:58:16
// Generated by the DN single header generator 2026-07-15 21:41:33
#if !defined(DN_H)
#define DN_H
@@ -4387,6 +4387,13 @@ struct DN_OSConditionVariable
typedef DN_I32(DN_OSThreadFunc)(struct DN_OSThread *);
typedef DN_U32 DN_OSThreadFlags;
enum DN_OSThreadFlags_
{
DN_OSThreadFlags_Nil = 0,
DN_OSThreadFlags_Detached = 1 << 0,
};
typedef struct DN_OSThreadInitArgs DN_OSThreadInitArgs;
struct DN_OSThreadInitArgs
{
@@ -4396,7 +4403,8 @@ struct DN_OSThreadInitArgs
// NOTE: Set how much stack space in bytes the thread will have. Leave this value to 0 to defer
// to the OS's default stack size.
DN_USize stack_size;
DN_USize stack_size;
DN_OSThreadFlags flags;
};
typedef struct DN_OSThreadLane DN_OSThreadLane;
@@ -4420,6 +4428,7 @@ struct DN_OSThreadLaneway
typedef struct DN_OSThread DN_OSThread;
struct DN_OSThread
{
DN_OSThreadFlags flags;
DN_Str8x64 name;
DN_TCCore context;
DN_OSThreadLane lane;
@@ -4428,7 +4437,8 @@ struct DN_OSThread
DN_U64 thread_id;
void *user_context;
DN_OSThreadFunc *func;
DN_OSSemaphore init_semaphore;
DN_OSSemaphore thread_exec_wait_for_thread_id_sem;
DN_OSSemaphore caller_wait_for_thread_init_to_finish_sem;
DN_TCInitArgs tc_init_args;
};
@@ -7681,7 +7691,7 @@ DN_NETResponse DN_NET_EmcWaitForAnyResponse(DN_NETCore *net, DN_Arena *aren
// NOTE: consoleapi.h ///////////////////////////////////////////////////////////////////////////
extern "C"
{
__declspec(dllimport) BOOL __stdcall WriteConsoleA(HANDLE hConsoleOutput, const VOID* lpBuffer, DWORD nNumberOfCharsToWrite, DWORD *lpNumberOfCharsWritten, VOID *lpReserved);
__declspec(dllimport) BOOL __stdcall WriteConsoleW(HANDLE hConsoleOutput, const VOID* lpBuffer, DWORD nNumberOfCharsToWrite, DWORD *lpNumberOfCharsWritten, VOID *lpReserved);
__declspec(dllimport) BOOL __stdcall AllocConsole(VOID);
__declspec(dllimport) BOOL __stdcall FreeConsole(VOID);
__declspec(dllimport) BOOL __stdcall AttachConsole(DWORD dwProcessId);