version 2.8
gos_qt.h
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.org/license.html
6  */
7 
8 #ifndef _GOS_QT_H
9 #define _GOS_QT_H
10 
11 #if GFX_USE_OS_QT
12 
13 #include <stdint.h>
14 #include <stddef.h>
15 #include <stdbool.h>
16 
17 #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
18 #define DECLARE_THREAD_STACK(name, sz) uint8_t name[0]
19 #define THREAD_RETURN(retval) return retval
20 
21 #define TIME_IMMEDIATE 0
22 #define TIME_INFINITE ((delaytime_t)-1)
23 #define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
24 #define LOW_PRIORITY 2
25 #define NORMAL_PRIORITY 3
26 #define HIGH_PRIORITY 4
27 
28 typedef bool bool_t;
29 typedef int systemticks_t;
30 typedef int delaytime_t;
31 typedef void* gfxMutex;
32 typedef void* gfxSem;
33 typedef int semcount_t;
34 typedef int threadreturn_t;
35 typedef int threadpriority_t;
36 typedef void* gfxThreadHandle;
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 void _gosInit();
43 void _gosDeinit();
44 
45 void gfxHalt(const char* msg);
46 void gfxExit(void);
47 void* gfxAlloc(size_t sz);
48 void gfxFree(void* ptr);
49 void gfxYield(void);
50 void gfxSleepMilliseconds(delaytime_t ms);
51 void gfxSleepMicroseconds(delaytime_t us);
52 systemticks_t gfxSystemTicks(void);
53 systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
54 void gfxSystemLock(void);
55 void gfxSystemUnlock(void);
56 void gfxMutexInit(gfxMutex *pmutex);
57 void gfxMutexDestroy(gfxMutex *pmutex);
58 void gfxMutexEnter(gfxMutex *pmutex);
59 void gfxMutexExit(gfxMutex *pmutex);
60 void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
61 void gfxSemDestroy(gfxSem *psem);
62 bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
63 bool_t gfxSemWaitI(gfxSem *psem);
64 void gfxSemSignal(gfxSem *psem);
65 void gfxSemSignalI(gfxSem *psem);
66 gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
67 threadreturn_t gfxThreadWait(gfxThreadHandle thread);
69 void gfxThreadClose(gfxThreadHandle thread);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif /* GFX_USE_OS_QT */
76 #endif /* _GOS_QT_H */
void * gfxThreadHandle
A thread handle.
Definition: gos.h:117
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
Initialise a Counted Semaphore.
systemticks_t gfxSystemTicks(void)
Get the current operating system tick time.
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
Convert a given number of millseconds to a number of operating system ticks.
void gfxSemDestroy(gfxSem *psem)
Destroy a Counted Semaphore.
void * gfxAlloc(size_t sz)
Allocate memory.
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms)
Wait on a semaphore.
void gfxSemSignalI(gfxSem *psem)
Signal a semaphore.
A semaphore.
Definition: gos.h:105
void gfxMutexExit(gfxMutex *pmutex)
Exit the critical code region protected by the mutex.
void gfxSystemLock(void)
Lock the operating system to protect a sequence of code.
#define DECLARE_THREAD_FUNCTION(fnName, param)
Declare a thread function.
Definition: gos.h:62
void gfxExit(void)
Exit the GFX application.
void gfxFree(void *ptr)
Free memory.
void gfxHalt(const char *msg)
Halt the GFX application due to an error.
void gfxMutexEnter(gfxMutex *pmutex)
Enter the critical code region protected by the mutex.
void gfxSemSignal(gfxSem *psem)
Signal a semaphore.
void gfxSleepMicroseconds(delaytime_t us)
Put the current thread to sleep for the specified period in microseconds.
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn), p), void *param)
Start a new thread.
A mutex.
Definition: gos.h:111
threadreturn_t gfxThreadWait(gfxThreadHandle thread)
Wait for a thread to finish.
void gfxThreadClose(gfxThreadHandle thread)
Close the thread handle.
void gfxMutexInit(gfxMutex *pmutex)
Initialise a mutex to protect a region of code from other threads.
void gfxYield(void)
Yield the current thread.
void gfxMutexDestroy(gfxMutex *pmutex)
Destroy a Mutex.
gfxThreadHandle gfxThreadMe(void)
Get the current thread handle.
void gfxSleepMilliseconds(delaytime_t ms)
Put the current thread to sleep for the specified period in milliseconds.
bool_t gfxSemWaitI(gfxSem *psem)
Test if a wait on a semaphore can be satisfied immediately.
void gfxSystemUnlock(void)
Unlock the operating system previous locked by gfxSystemLock()