9 #define GFILE_NEED_STDIO_MUST_BE_OFF
11 #include "../../gfx.h"
17 static HANDLE SystemMutex;
24 void _gosPostInit(
void)
35 fprintf(stderr,
"%s\n", msg);
41 static LARGE_INTEGER pcfreq;
43 LARGE_INTEGER t1, t2, tdiff;
56 QueryPerformanceFrequency(&pcfreq);
59 tdiff.QuadPart = pcfreq.QuadPart * ms / 1000000;
61 QueryPerformanceCounter(&t1);
63 QueryPerformanceCounter(&t2);
64 }
while (t2.QuadPart - t1.QuadPart < tdiff.QuadPart);
69 SystemMutex = CreateMutex(0, FALSE, 0);
70 WaitForSingleObject(SystemMutex, INFINITE);
74 ReleaseMutex(SystemMutex);
78 return WaitForSingleObject(*psem, ms) == WAIT_OBJECT_0;
81 typedef LONG (__stdcall *_NtQuerySemaphore)(
82 HANDLE SemaphoreHandle,
83 DWORD SemaphoreInformationClass,
84 PVOID SemaphoreInformation,
85 ULONG SemaphoreInformationLength,
86 PULONG ReturnLength OPTIONAL
110 if (!(thd = CreateThread(0, stacksz, fn, param, CREATE_SUSPENDED, 0)))
113 SetThreadPriority(thd, prio);
122 WaitForSingleObject(thread, INFINITE);
123 GetExitCodeThread(thread, &ret);
gThreadreturn gfxThreadWait(gThread thread)
Wait for a thread to finish.
void * gThread
A thread handle.
#define GFX_THREAD_FUNCTION(fnName, param)
Declare a thread function.
gBool gfxSemWait(gSem *psem, gDelay ms)
Wait on a semaphore.
void gfxSystemUnlock(void)
Unlock the operating system previous locked by gfxSystemLock()
void gfxSleepMicroseconds(gDelay us)
Put the current thread to sleep for the specified period in microseconds.
void gfxSystemLock(void)
Lock the operating system to protect a sequence of code.
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn), p), void *param)
Start a new thread.
void gfxHalt(const char *msg)
Halt the GFX application due to an error.