13 #include <sys/types.h>
17 typedef unsigned long gTicks;
18 typedef void * gThreadreturn;
19 typedef unsigned long gDelay;
21 typedef int gThreadpriority;
22 typedef gU32 gSemcount;
23 typedef pthread_mutex_t
gMutex;
25 #define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
26 #define GFX_THREAD_STACK(name, sz) gU8 name[0];
27 #define gfxThreadReturn(retval) return retval
29 #define gfxExit() exit(0)
30 #define gfxAlloc(sz) malloc(sz)
31 #define gfxRealloc(p,osz,nsz) realloc(p, nsz)
32 #define gfxFree(ptr) free(ptr)
33 #define gfxMillisecondsToTicks(ms) (ms)
34 #define gfxYield() sched_yield()
35 #define gfxThreadMe() pthread_self()
36 #define gfxThreadClose(th) (void)th
37 #define gfxMutexInit(pmtx) pthread_mutex_init(pmtx, 0)
38 #define gfxMutexDestroy(pmtx) pthread_mutex_destroy(pmtx)
39 #define gfxMutexEnter(pmtx) pthread_mutex_lock(pmtx)
40 #define gfxMutexExit(pmtx) pthread_mutex_unlock(pmtx)
41 #define gfxSemWaitI(psem) gfxSemWait(psem, gDelayNone)
42 #define gfxSemSignalI(psem) gfxSemSignal(psem)
45 #define gDelayForever ((gDelay)-1)
46 #define gSemMaxCount ((gSemcount)-1)
47 #define gThreadpriorityLow 10
48 #define gThreadpriorityNormal 0
49 #define gThreadpriorityHigh -10
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.
#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.