2013-05-24 15:26:52 +00:00
|
|
|
/*
|
2013-06-15 11:37:22 +00:00
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
|
|
|
*
|
2018-10-01 15:32:39 +00:00
|
|
|
* http://ugfx.io/license.html
|
2013-06-15 11:37:22 +00:00
|
|
|
*/
|
2013-05-24 15:26:52 +00:00
|
|
|
|
|
|
|
/**
|
2014-11-15 05:19:46 +00:00
|
|
|
* @file src/gos/gos_win32.h
|
2013-05-24 15:26:52 +00:00
|
|
|
* @brief GOS - Operating System Support header file for WIN32.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GOS_WIN32_H
|
|
|
|
#define _GOS_WIN32_H
|
|
|
|
|
|
|
|
#if GFX_USE_OS_WIN32
|
2013-05-25 16:06:55 +00:00
|
|
|
|
2013-11-15 15:53:00 +00:00
|
|
|
#ifndef _WIN32_WINNT
|
|
|
|
#define _WIN32_WINNT 0x0501 // Windows XP and up
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2013-05-25 16:06:55 +00:00
|
|
|
#include <windows.h>
|
2013-11-15 15:53:00 +00:00
|
|
|
#undef WIN32_LEAN_AND_MEAN
|
|
|
|
|
|
|
|
#include <malloc.h>
|
2013-05-25 16:06:55 +00:00
|
|
|
|
2018-07-08 04:30:31 +00:00
|
|
|
typedef DWORD gDelay;
|
|
|
|
typedef DWORD gTicks;
|
|
|
|
typedef LONG gSemcount;
|
|
|
|
typedef DWORD gThreadreturn;
|
|
|
|
typedef int gThreadpriority;
|
2013-05-25 16:06:55 +00:00
|
|
|
|
2018-11-03 02:29:30 +00:00
|
|
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn (WINAPI fnName)(void *param)
|
|
|
|
#define GFX_THREAD_STACK(name, sz) gU8 name[1];
|
|
|
|
#define gfxThreadReturn(retval) return retval
|
2013-05-25 16:06:55 +00:00
|
|
|
|
2018-07-08 05:15:15 +00:00
|
|
|
#define gDelayNone 0
|
|
|
|
#define gDelayForever INFINITE
|
2018-11-03 02:29:30 +00:00
|
|
|
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
|
|
|
#define gThreadpriorityLow THREAD_PRIORITY_BELOW_NORMAL
|
|
|
|
#define gThreadpriorityNormal THREAD_PRIORITY_NORMAL
|
|
|
|
#define gThreadpriorityHigh THREAD_PRIORITY_ABOVE_NORMAL
|
2013-05-25 16:06:55 +00:00
|
|
|
|
2018-11-03 02:29:30 +00:00
|
|
|
typedef HANDLE gSem;
|
|
|
|
typedef HANDLE gMutex;
|
2018-07-08 05:40:27 +00:00
|
|
|
typedef HANDLE gThread;
|
2013-05-25 16:06:55 +00:00
|
|
|
|
|
|
|
#define gfxExit() ExitProcess(0)
|
|
|
|
#define gfxAlloc(sz) malloc(sz)
|
2013-07-20 11:57:01 +00:00
|
|
|
#define gfxRealloc(p,osz,nsz) realloc(p, nsz)
|
2013-05-25 16:06:55 +00:00
|
|
|
#define gfxFree(ptr) free(ptr)
|
|
|
|
#define gfxSleepMilliseconds(ms) Sleep(ms)
|
|
|
|
#define gfxYield() Sleep(0)
|
|
|
|
#define gfxSystemTicks() GetTickCount()
|
|
|
|
#define gfxMillisecondsToTicks(ms) (ms)
|
2013-12-21 03:21:59 +00:00
|
|
|
#define gfxMutexInit(pmutex) *(pmutex) = CreateMutex(0, FALSE, 0)
|
2014-02-07 03:59:52 +00:00
|
|
|
#define gfxMutexDestroy(pmutex) CloseHandle(*(pmutex))
|
2013-05-25 16:06:55 +00:00
|
|
|
#define gfxMutexEnter(pmutex) WaitForSingleObject(*(pmutex), INFINITE)
|
|
|
|
#define gfxMutexExit(pmutex) ReleaseMutex(*(pmutex))
|
2013-12-21 03:21:59 +00:00
|
|
|
#define gfxSemInit(psem, val, limit) *(psem) = CreateSemaphore(0, val, limit, 0)
|
2014-02-07 03:59:52 +00:00
|
|
|
#define gfxSemDestroy(psem) CloseHandle(*(psem))
|
2018-07-08 05:15:15 +00:00
|
|
|
#define gfxSemWaitI(psem) gfxSemWait((psem), gDelayNone)
|
2013-12-21 03:21:59 +00:00
|
|
|
#define gfxSemSignal(psem) ReleaseSemaphore(*(psem), 1, 0)
|
|
|
|
#define gfxSemSignalI(psem) ReleaseSemaphore(*(psem), 1, 0)
|
2013-06-02 08:57:22 +00:00
|
|
|
#define gfxThreadMe() GetCurrentThread()
|
|
|
|
#define gfxThreadClose(thread) CloseHandle(thread)
|
2013-05-25 16:06:55 +00:00
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Function declarations. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
void gfxHalt(const char *msg);
|
2018-07-08 04:30:31 +00:00
|
|
|
void gfxSleepMicroseconds(gDelay ms);
|
2018-11-03 02:29:30 +00:00
|
|
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
2013-05-25 16:06:55 +00:00
|
|
|
void gfxSystemLock(void);
|
|
|
|
void gfxSystemUnlock(void);
|
2018-11-03 02:29:30 +00:00
|
|
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION(*fn,p), void *param);
|
2018-07-08 05:40:27 +00:00
|
|
|
gThreadreturn gfxThreadWait(gThread thread);
|
2013-05-25 16:06:55 +00:00
|
|
|
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif /* GFX_USE_OS_WIN32 */
|
|
|
|
#endif /* _GOS_WIN32_H */
|
2013-12-07 21:01:57 +00:00
|
|
|
|