14 #ifndef GFX_USE_POSIX_SEMAPHORES
15 #define GFX_USE_POSIX_SEMAPHORES GFXON
18 #include <sys/types.h>
22 #if GFX_USE_POSIX_SEMAPHORES
23 #include <semaphore.h>
26 typedef unsigned long gTicks;
27 typedef void * gThreadreturn;
28 typedef unsigned long gDelay;
30 typedef int gThreadpriority;
31 typedef gU32 gSemcount;
32 typedef pthread_mutex_t
gMutex;
34 #define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
35 #define GFX_THREAD_STACK(name, sz) gU8 name[0];
36 #define gfxThreadReturn(retval) return retval
38 #define gfxExit() exit(0)
39 #define gfxAlloc(sz) malloc(sz)
40 #define gfxRealloc(p,osz,nsz) realloc(p, nsz)
41 #define gfxFree(ptr) free(ptr)
42 #define gfxMillisecondsToTicks(ms) (ms)
43 #define gfxThreadMe() pthread_self()
44 #define gfxThreadClose(th) (void)th
45 #define gfxMutexInit(pmtx) pthread_mutex_init(pmtx, 0)
46 #define gfxMutexDestroy(pmtx) pthread_mutex_destroy(pmtx)
47 #define gfxMutexEnter(pmtx) pthread_mutex_lock(pmtx)
48 #define gfxMutexExit(pmtx) pthread_mutex_unlock(pmtx)
49 #define gfxSemWaitI(psem) gfxSemWait(psem, gDelayNone)
50 #define gfxSemSignalI(psem) gfxSemSignal(psem)
53 #define gDelayForever ((gDelay)-1)
54 #define gSemMaxCount ((gSemcount)-1)
55 #define gThreadpriorityLow 10
56 #define gThreadpriorityNormal 0
57 #define gThreadpriorityHigh -10
59 #if GFX_USE_POSIX_SEMAPHORES
gThreadreturn gfxThreadWait(gThread thread)
Wait for a thread to finish.
void gfxSemSignal(gSem *psem)
Signal a semaphore.
void * gThread
A thread handle.
gTicks gfxSystemTicks(void)
Get the current operating system tick time.
void gfxYield(void)
Yield the current thread.
#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.
void gfxSemDestroy(gSem *psem)
Destroy a Counted Semaphore.
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
Initialise a Counted Semaphore.
void gfxSleepMilliseconds(gDelay ms)
Put the current thread to sleep for the specified period in milliseconds.