Browse Source

Tidy u gfxSem, gfxMutex and various Macros by converting to new types gSem, gMutex etc

inmarket 2 years ago
parent
commit
8a9ed5195b
47 changed files with 364 additions and 357 deletions
  1. 5 3
      changelog.txt
  2. 4 4
      demos/3rdparty/notepad-2/notepadApp.c
  3. 3 3
      demos/3rdparty/notepad-2/notepadCore.c
  4. 1 1
      demos/applications/combo/bounce.c
  5. 1 1
      demos/applications/combo/mandelbrot.c
  6. 2 2
      demos/games/justget10/jg10.c
  7. 2 2
      demos/games/minesweeper/mines.c
  8. 1 1
      demos/games/tetris/tetris.c
  9. 2 2
      demos/tools/uGFXnetDisplay/main.c
  10. 2 2
      drivers/multiple/X/gdisp_lld_X.c
  11. 3 3
      drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c
  12. 1 1
      drivers/multiple/uGFXnetESP8266/gdisp_lld_uGFXnetESP8266.cpp
  13. 1 1
      ffconf.h
  14. 1 1
      src/gadc/gadc.c
  15. 2 2
      src/gaudio/gaudio.c
  16. 1 1
      src/gdisp/gdisp_driver.h
  17. 4 4
      src/gevent/gevent.c
  18. 2 2
      src/gevent/gevent.h
  19. 5 5
      src/gfile/gfile_fatfs_wrapper.c
  20. 34 27
      src/gos/gos.h
  21. 7 7
      src/gos/gos_chibios.c
  22. 20 20
      src/gos/gos_chibios.h
  23. 8 8
      src/gos/gos_cmsis.c
  24. 20 20
      src/gos/gos_cmsis.h
  25. 5 5
      src/gos/gos_cmsis2.c
  26. 14 14
      src/gos/gos_cmsis2.h
  27. 9 9
      src/gos/gos_ecos.c
  28. 16 16
      src/gos/gos_ecos.h
  29. 8 8
      src/gos/gos_freertos.c
  30. 15 15
      src/gos/gos_freertos.h
  31. 10 10
      src/gos/gos_linux.c
  32. 20 20
      src/gos/gos_linux.h
  33. 6 6
      src/gos/gos_osx.c
  34. 16 16
      src/gos/gos_osx.h
  35. 11 11
      src/gos/gos_qt.cpp
  36. 22 22
      src/gos/gos_qt.h
  37. 3 3
      src/gos/gos_rawrtos.c
  38. 12 12
      src/gos/gos_rawrtos.h
  39. 3 3
      src/gos/gos_win32.c
  40. 11 11
      src/gos/gos_win32.h
  41. 9 9
      src/gos/gos_x_threads.c
  42. 20 20
      src/gos/gos_x_threads.h
  43. 9 11
      src/gos/gos_zephyr.h
  44. 2 2
      src/gqueue/gqueue.c
  45. 3 3
      src/gqueue/gqueue.h
  46. 6 6
      src/gtimer/gtimer.c
  47. 2 2
      src/gwin/gwin_wm.c

+ 5 - 3
changelog.txt

@@ -18,8 +18,8 @@ CHANGE:		Added types gI8, gU8 .. gI32, gU32 to replace V2.x int8_t etc
18 18
 CHANGE:		Added type gBool           to replace V2.x bool_t,        and values gTrue/gFalse to replace TRUE/FALSE
19 19
 CHANGE:		Added type gDelay          to replace V2.x delaytime_t    and values gDelayNone/gDelayForever to replace TIME_IMMEDIATE/TIME_INFINITE
20 20
 CHANGE:		Added type gTicks          to replace V2.x systemticks_t
21
-CHANGE:		Added type gThread         to replace V2.x gfxThreadHandle
22
-CHANGE:		Added type gThreadreturn   to replace V2.x threadreturn_t
21
+CHANGE:		Added type gThread         to replace V2.x gfxThreadHandle and macros GFX_THREAD_FUNCTION/STACK to replace DECLARE_THREAD_FUNCTION & DECLARE_THREAD_STACK
22
+CHANGE:		Added type gThreadreturn   to replace V2.x threadreturn_t and pseudo function gfxThreadReturn() to replace THREAD_RETURN()
23 23
 CHANGE:		Added type gThreadpriority to replace V2.x threadpriority_t and values gThreadpriorityLow/Normal/High to replace LOW_/NORMAL_/HIGH_PRIORITY
24 24
 CHANGE:		Added type gPoint          to replace V2.x point and point_t
25 25
 CHANGE:		Added type gCoord          to replace V2.x coord_t
@@ -31,7 +31,9 @@ CHANGE:		Added type gPowermode      to replace V2.x powermode_t,   and values gP
31 31
 CHANGE:		Added type gJustify        to replace V2.x justify_t,     and values gJustifyXXX replace justifyXXX
32 32
 CHANGE:		Added type gFontmetric     to replace V2.x fontmetric_t,  and values gFontXXX replace fontXXX
33 33
 CHANGE:		Added type gOrientation    to replace V2.x orientation_t, and values gOrientationX replace GDISP_ROTATE_X
34
-CHANGE:		Added macros JUSTIFYMASK_HORIZONTAL, JUSTIFYMASK_VERTICAL to replace macros JUSTIFYMASK_LEFTRIGHT, JUSTIFYMASK_TOPBOTTOM
34
+CHANGE:		Added type gSem            to replace V2.x gfxSem, and values gSemMaxCount replace MAX_SEMAPHORE_COUNT
35
+CHANGE:		Added type gMutex          to replace V2.x gfxMutex
36
+CHANGE:		Added macros JUSTIFYMASK_HORIZONTAL, JUSTIFYMASK_VERTICAL to replace V2.x macros JUSTIFYMASK_LEFTRIGHT, JUSTIFYMASK_TOPBOTTOM
35 37
 FEATURE:	Added types gPtr, gPtrDiff and gAny
36 38
 FEATURE:	Added type gMemSize and config macro GFX_MEM_LT64K
37 39
 FEATURE:	Added type gFileSize

+ 4 - 4
demos/3rdparty/notepad-2/notepadApp.c

@@ -2,7 +2,7 @@
2 2
  * File: notepadApp.c
3 3
  *
4 4
  * This file is a part of the Notepad demo application for ChibiOS/GFX
5
- * Copyright © 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
5
+ * Copyright 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
6 6
  * All rights reserved.
7 7
  *
8 8
  * Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,7 @@ static int selColorIndex = 0, selPenWidth = 1, tbMode = 1;
70 70
 
71 71
 static NColorScheme nCurColorScheme;
72 72
 
73
-static DECLARE_THREAD_FUNCTION(notepadThread, param);
73
+static GFX_THREAD_FUNCTION(notepadThread, param);
74 74
 
75 75
 // Custom drawing functions for the buttons
76 76
 static void nbtnColorBarDraw(GHandle gh, gBool enabled, gBool isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
@@ -311,8 +311,8 @@ static void drawVButtons(void) {
311 311
   gwinButtonDraw(H(btnFill));
312 312
 }
313 313
 
314
-static DECLARE_THREAD_STACK(waNotepadThread, NPAD_THD_WA_SIZE);
315
-static DECLARE_THREAD_FUNCTION(notepadThread, param) {
314
+static GFX_THREAD_STACK(waNotepadThread, NPAD_THD_WA_SIZE);
315
+static GFX_THREAD_FUNCTION(notepadThread, param) {
316 316
 
317 317
   GEventMouse		*pem;
318 318
   GEventGWinButton	*peb;

+ 3 - 3
demos/3rdparty/notepad-2/notepadCore.c

@@ -2,7 +2,7 @@
2 2
  * File: notepadCore.c
3 3
  *
4 4
  * This file is a part of the Notepad demo application for ChibiOS/GFX
5
- * Copyright © 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
5
+ * Copyright 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
6 6
  * All rights reserved.
7 7
  *
8 8
  * Redistribution and use in source and binary forms, with or without
@@ -43,7 +43,7 @@
43 43
 									 (ev.y >= ncoreDrawingArea->y) && (ev.y <= (ncoreDrawingArea->y + ncoreDrawingArea->height)))
44 44
 
45 45
 /* This is the drawing core */
46
-static DECLARE_THREAD_STACK(waDrawThread, NCORE_THD_STACK_SIZE);
46
+static GFX_THREAD_STACK(waDrawThread, NCORE_THD_STACK_SIZE);
47 47
 
48 48
 static gU8 					nPenWidth = 1;
49 49
 static gU8 					nMode = NCORE_MODE_DRAW;
@@ -127,7 +127,7 @@ static void draw_line(gCoord x0, gCoord y0, gCoord x1, gCoord y1) {
127 127
 }
128 128
 
129 129
 /* Core thread */
130
-static DECLARE_THREAD_FUNCTION(ncoreDrawThread, msg) {
130
+static GFX_THREAD_FUNCTION(ncoreDrawThread, msg) {
131 131
 
132 132
   GEventMouse ev, evPrev;
133 133
   gCoord dx, dy;

+ 1 - 1
demos/applications/combo/bounce.c

@@ -62,7 +62,7 @@ static gThread	thread;
62 62
 #define FLOORCOLOR		HTML2COLOR(0x606060)
63 63
 #define SHADOWALPHA		(255-255*0.2)
64 64
 
65
-static DECLARE_THREAD_FUNCTION(task, param) {
65
+static GFX_THREAD_FUNCTION(task, param) {
66 66
 	gCoord		width, height, x, y, radius, ballx, bally, dx, floor;
67 67
 	gCoord		minx, miny, maxx, maxy, winx, winy;
68 68
 	gCoord		ballcx, ballcy;

+ 1 - 1
demos/applications/combo/mandelbrot.c

@@ -66,7 +66,7 @@ static void mandelbrot(float x1, float y1, float x2, float y2) {
66 66
 	}
67 67
 }
68 68
 
69
-static DECLARE_THREAD_FUNCTION(task, param) {
69
+static GFX_THREAD_FUNCTION(task, param) {
70 70
 	float cx, cy;
71 71
 	float zoom = 1.0f;
72 72
 	(void) param;

+ 2 - 2
demos/games/justget10/jg10.c

@@ -223,7 +223,7 @@ static void printCongrats(void) {
223 223
     gdispDrawString(JG10_TOTAL_FIELD_WIDTH+((gdispGetWidth()-JG10_TOTAL_FIELD_WIDTH)/2)-(gdispGetStringWidth(pps_str, font)/2), (gdispGetHeight()/2)+20, pps_str, font, GFX_RED);
224 224
 }
225 225
 
226
-static DECLARE_THREAD_FUNCTION(thdJg10, msg) {
226
+static GFX_THREAD_FUNCTION(thdJg10, msg) {
227 227
     (void)msg;
228 228
     gU16 x,y;
229 229
     while (!jg10GameOver) {
@@ -273,7 +273,7 @@ static DECLARE_THREAD_FUNCTION(thdJg10, msg) {
273 273
             }
274 274
         }
275 275
     }
276
-    THREAD_RETURN(0);
276
+    gfxThreadReturn(0);
277 277
 }
278 278
 
279 279
 static void initField(void) {

+ 2 - 2
demos/games/minesweeper/mines.c

@@ -192,7 +192,7 @@ static void openEmptyNodes(void)
192 192
     }
193 193
 }
194 194
 
195
-static DECLARE_THREAD_FUNCTION(thdMines, msg)
195
+static GFX_THREAD_FUNCTION(thdMines, msg)
196 196
 {
197 197
     (void)msg;
198 198
     gU16 x,y, delay;
@@ -245,7 +245,7 @@ static DECLARE_THREAD_FUNCTION(thdMines, msg)
245 245
             }
246 246
         }
247 247
     }
248
-    THREAD_RETURN(0);
248
+    gfxThreadReturn(0);
249 249
 }
250 250
 
251 251
 static void printGameOver(void)

+ 1 - 1
demos/games/tetris/tetris.c

@@ -427,7 +427,7 @@ static void goLeft(void) {
427 427
   } 
428 428
 }
429 429
 
430
-static DECLARE_THREAD_FUNCTION(thdTetris, arg) {
430
+static GFX_THREAD_FUNCTION(thdTetris, arg) {
431 431
   (void)arg;
432 432
   gU8 i;
433 433
   while (!tetrisGameOver) {

+ 2 - 2
demos/tools/uGFXnetDisplay/main.c

@@ -182,8 +182,8 @@ static gBool sendpkt(gU16 *pkt, int len) {
182 182
 	 * We do the send in a single transaction to prevent it getting interspersed with
183 183
 	 * any reply we need to send on the main thread.
184 184
 	 */
185
-	static DECLARE_THREAD_STACK(waNetThread, 512);
186
-	static DECLARE_THREAD_FUNCTION(NetThread, param) {
185
+	static GFX_THREAD_STACK(waNetThread, 512);
186
+	static GFX_THREAD_FUNCTION(NetThread, param) {
187 187
 		GEventMouse				*pem;
188 188
 		gU16				cmd[2];
189 189
 		gU16				lbuttons;

+ 2 - 2
drivers/multiple/X/gdisp_lld_X.c

@@ -270,8 +270,8 @@ static void ProcessEvent(GDisplay *g, xPriv *priv) {
270 270
 }
271 271
 
272 272
 /* this is the X11 thread which keeps track of all events */
273
-static DECLARE_THREAD_STACK(waXThread, 1024);
274
-static DECLARE_THREAD_FUNCTION(ThreadX, arg) {
273
+static GFX_THREAD_STACK(waXThread, 1024);
274
+static GFX_THREAD_FUNCTION(ThreadX, arg) {
275 275
 	GDisplay	*g;
276 276
 	(void)arg;
277 277
 

+ 3 - 3
drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c

@@ -168,7 +168,7 @@ typedef struct netPriv {
168 168
 static gThread	hThread;
169 169
 
170 170
 #if GDISP_GFXNET_UNSAFE_SOCKETS
171
-	static gfxMutex	uGFXnetMutex;
171
+	static gMutex	uGFXnetMutex;
172 172
 	#define MUTEX_INIT		gfxMutexInit(&uGFXnetMutex)
173 173
 	#define MUTEX_ENTER		gfxMutexEnter(&uGFXnetMutex)
174 174
 	#define MUTEX_EXIT		gfxMutexExit(&uGFXnetMutex)
@@ -318,8 +318,8 @@ static gBool rxdata(SOCKET_TYPE fd) {
318 318
 	return gTrue;
319 319
 }
320 320
 
321
-static DECLARE_THREAD_STACK(waNetThread, 512);
322
-static DECLARE_THREAD_FUNCTION(NetThread, param) {
321
+static GFX_THREAD_STACK(waNetThread, 512);
322
+static GFX_THREAD_FUNCTION(NetThread, param) {
323 323
 	SOCKET_TYPE			listenfd, fdmax, i, clientfd;
324 324
 	socklen_t			len;
325 325
 	fd_set				master, read_fds;

+ 1 - 1
drivers/multiple/uGFXnetESP8266/gdisp_lld_uGFXnetESP8266.cpp

@@ -126,7 +126,7 @@ typedef struct netPriv {
126 126
 } netPriv;
127 127
 
128 128
 #if GDISP_GFXNET_UNSAFE_SOCKETS
129
-	static gfxMutex	uGFXnetMutex;
129
+	static gMutex	uGFXnetMutex;
130 130
 	#define MUTEX_INIT		gfxMutexInit(&uGFXnetMutex)
131 131
 	#define MUTEX_ENTER		gfxMutexEnter(&uGFXnetMutex)
132 132
 	#define MUTEX_EXIT		gfxMutexExit(&uGFXnetMutex)

+ 1 - 1
ffconf.h

@@ -244,7 +244,7 @@
244 244
 
245 245
 #define FF_FS_REENTRANT	0
246 246
 #define FF_FS_TIMEOUT	1000
247
-#define FF_SYNC_t		gfxSem
247
+#define FF_SYNC_t		gSem
248 248
 /* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
249 249
 /  module itself. Note that regardless of this option, file access to different
250 250
 /  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()

+ 1 - 1
src/gadc/gadc.c

@@ -25,7 +25,7 @@ typedef struct NonTimerData_t {
25 25
 	GADCCallbackFunction	callback;
26 26
 	union {
27 27
 		void				*param;
28
-		gfxSem				sigdone;
28
+		gSem				sigdone;
29 29
 	};
30 30
 	GadcNonTimerJob			job;
31 31
 	} NonTimerData;

+ 2 - 2
src/gaudio/gaudio.c

@@ -13,8 +13,8 @@
13 13
 	#include "gaudio_driver_play.h"
14 14
 
15 15
 	static gfxQueueASync	playList;
16
-	static gfxSem			playComplete;
17
-	static gU16			playFlags;
16
+	static gSem				playComplete;
17
+	static gU16				playFlags;
18 18
 		#define PLAYFLG_USEEVENTS	0x0001
19 19
 		#define PLAYFLG_PLAYING		0x0002
20 20
 		#define PLAYFLG_ISINIT		0x0004

+ 1 - 1
src/gdisp/gdisp_driver.h

@@ -338,7 +338,7 @@ struct GDisplay {
338 338
 
339 339
 	// Multithread Mutex
340 340
 	#if GDISP_NEED_MULTITHREAD
341
-		gfxMutex				mutex;
341
+		gMutex				mutex;
342 342
 	#endif
343 343
 
344 344
 	// Software clipping

+ 4 - 4
src/gevent/gevent.c

@@ -20,7 +20,7 @@
20 20
 #define GLISTENER_WITHSOURCE		0x0002			// The source is currently using the buffer
21 21
 
22 22
 /* This mutex protects access to our tables */
23
-static gfxMutex	geventMutex;
23
+static gMutex	geventMutex;
24 24
 
25 25
 /* Our table of listener/source pairs */
26 26
 static GSourceListener		Assignments[GEVENT_MAX_SOURCE_LISTENERS];
@@ -62,9 +62,9 @@ void _geventDeinit(void)
62 62
 }
63 63
 
64 64
 void geventListenerInit(GListener *pl) {
65
-	gfxSemInit(&pl->waitqueue, 0, MAX_SEMAPHORE_COUNT);		// Next wait'er will block
66
-	pl->callback = 0;										// No callback active
67
-	pl->event.type = GEVENT_NULL;							// Always safety
65
+	gfxSemInit(&pl->waitqueue, 0, gSemMaxCount);		// Next wait'er will block
66
+	pl->callback = 0;									// No callback active
67
+	pl->event.type = GEVENT_NULL;						// Always safety
68 68
 	pl->flags = 0;
69 69
 }
70 70
 

+ 2 - 2
src/gevent/gevent.h

@@ -55,8 +55,8 @@ typedef void (*GEventCallbackFn)(void *param, GEvent *pe);
55 55
 
56 56
 // The Listener Object
57 57
 typedef struct GListener {
58
-	gfxSem				waitqueue;			// Private: Semaphore for the listener to wait on.
59
-	gU16			flags;				// Private: Flags for operation
58
+	gSem				waitqueue;			// Private: Semaphore for the listener to wait on.
59
+	gU16				flags;				// Private: Flags for operation
60 60
 	GEventCallbackFn	callback;			// Private: Call back Function
61 61
 	void				*param;				// Private: Parameter for the callback function.
62 62
 	GEvent				event;				// Public:  The event object into which the event information is stored.

+ 5 - 5
src/gfile/gfile_fatfs_wrapper.c

@@ -20,7 +20,7 @@
20 20
 	/*------------------------------------------------------------------------*/
21 21
 	/* Static array of Synchronization Objects                                */
22 22
 	/*------------------------------------------------------------------------*/
23
-	static gfxSem ff_sem[_VOLUMES];
23
+	static gSem ff_sem[_VOLUMES];
24 24
 
25 25
 	/*------------------------------------------------------------------------*/
26 26
 	/* Create a Synchronization Object                                        */
@@ -28,7 +28,7 @@
28 28
 	int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj)
29 29
 	{
30 30
 		*sobj = ff_sem[vol];
31
-		gfxSemInit(sobj, 1, MAX_SEMAPHORE_COUNT);
31
+		gfxSemInit(sobj, 1, gSemMaxCount);
32 32
 
33 33
 		return 1;
34 34
 	}
@@ -38,7 +38,7 @@
38 38
 	/*------------------------------------------------------------------------*/
39 39
 	int ff_del_syncobj(_SYNC_t sobj)
40 40
 	{
41
-		gfxSemDestroy( (gfxSem*)&sobj );
41
+		gfxSemDestroy( (gSem*)&sobj );
42 42
 
43 43
 		return 1;
44 44
 	}
@@ -48,7 +48,7 @@
48 48
 	/*------------------------------------------------------------------------*/
49 49
 	int ff_req_grant(_SYNC_t sobj)
50 50
 	{
51
-		if (gfxSemWait( (gfxSem*)&sobj, (gDelay)_FS_TIMEOUT) )
51
+		if (gfxSemWait( (gSem*)&sobj, (gDelay)_FS_TIMEOUT) )
52 52
 			return gTrue;
53 53
 		return gFalse;
54 54
 	}
@@ -58,7 +58,7 @@
58 58
 	/*------------------------------------------------------------------------*/
59 59
 	void ff_rel_grant(_SYNC_t sobj)
60 60
 	{
61
-		gfxSemSignal( (gfxSem*)&sobj );
61
+		gfxSemSignal( (gSem*)&sobj );
62 62
 	}
63 63
 #endif /* _FS_REENTRANT */
64 64
 

+ 34 - 27
src/gos/gos.h

@@ -48,7 +48,7 @@
48 48
 	 * @note	GFX_TYPE_64 is set to GFXON or GFXOFF by the compiler detector. It is not a user configuration macro.
49 49
 	 * @{
50 50
 	 */
51
-	typedef long long		gI64;
51
+	typedef long long			gI64;
52 52
 	typedef unsigned long long	gU64;
53 53
 	/** @} */
54 54
 
@@ -70,7 +70,7 @@
70 70
 	 * @param[in] fnName	The name of the function
71 71
 	 * @param[in] param 	A custom parameter that is passed to the function
72 72
 	 */
73
-	#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
73
+	#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
74 74
 
75 75
 	/**
76 76
 	 * @brief	Declare a thread stack
@@ -82,17 +82,7 @@
82 82
 	 * 			Many platforms will round the size to ensure correct stack alignment.
83 83
 	 *			Other platforms may entirely ignore the suggested size.
84 84
 	 */
85
-	#define DECLARE_THREAD_STACK(name, sz)			gU8 name[sz];
86
-
87
-	/*
88
-	 * @brief	Return from a thread
89
-	 *
90
-	 * @details	Some underlying operating systems allow to return a value from a thread while others don't.
91
-	 *			For systems that don't allow to return a value from a thread function this call is simply ignored.
92
-	 *
93
-	 * @param[in] reval		The value which should be returned
94
-	 */
95
-	#define THREAD_RETURN(retval)					return retval
85
+	#define GFX_THREAD_STACK(name, sz)			gU8 name[sz];
96 86
 
97 87
 	/**
98 88
 	 * @name	Various platform (and operating system) constants
@@ -101,7 +91,7 @@
101 91
 	 */
102 92
 	#define gDelayNone					0
103 93
 	#define gDelayForever				((gDelay)-1)
104
-	#define MAX_SEMAPHORE_COUNT			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
94
+	#define gSemMaxCount				((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
105 95
 	#define gThreadpriorityLow			0
106 96
 	#define gThreadpriorityNormal		1
107 97
 	#define gThreadpriorityHigh			2
@@ -111,13 +101,13 @@
111 101
 	 * @brief	A semaphore
112 102
 	 * @note	Your operating system will have a proper definition for this structure
113 103
 	 */
114
-	typedef struct {} gfxSem;
104
+	typedef struct {} gSem;
115 105
 
116 106
 	/**
117 107
 	 * @brief	A mutex
118 108
 	 * @note	Your operating system will have a proper definition for this structure
119 109
 	 */
120
-	typedef struct {} gfxMutex;
110
+	typedef struct {} gMutex;
121 111
 
122 112
 	/**
123 113
 	 * @brief	A thread handle
@@ -297,7 +287,7 @@
297 287
 	 *
298 288
 	 * @api
299 289
 	 */
300
-	void gfxMutexInit(gfxMutex *pmutex);
290
+	void gfxMutexInit(gMutex *pmutex);
301 291
 
302 292
 	/**
303 293
 	 * @brief	Destroy a Mutex.
@@ -306,7 +296,7 @@
306 296
 	 *
307 297
 	 * @api
308 298
 	 */
309
-	void gfxMutexDestroy(gfxMutex *pmutex);
299
+	void gfxMutexDestroy(gMutex *pmutex);
310 300
 
311 301
 	/**
312 302
 	 * @brief	Enter the critical code region protected by the mutex.
@@ -316,7 +306,7 @@
316 306
 	 *
317 307
 	 * @api
318 308
 	 */
319
-	void gfxMutexEnter(gfxMutex *pmutex);
309
+	void gfxMutexEnter(gMutex *pmutex);
320 310
 
321 311
 	/**
322 312
 	 * @brief	Exit the critical code region protected by the mutex.
@@ -326,7 +316,7 @@
326 316
 	 *
327 317
 	 * @api
328 318
 	 */
329
-	void gfxMutexExit(gfxMutex *pmutex);
319
+	void gfxMutexExit(gMutex *pmutex);
330 320
 
331 321
 	/**
332 322
 	 * @brief	Initialise a Counted Semaphore
@@ -344,7 +334,7 @@
344 334
 	 *
345 335
 	 * @api
346 336
 	 */
347
-	void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
337
+	void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
348 338
 
349 339
 	/**
350 340
 	 * @brief	Destroy a Counted Semaphore
@@ -355,7 +345,7 @@
355 345
 	 *
356 346
 	 * @api
357 347
 	 */
358
-	void gfxSemDestroy(gfxSem *psem);
348
+	void gfxSemDestroy(gSem *psem);
359 349
 
360 350
 	/**
361 351
 	 * @brief	Wait on a semaphore
@@ -368,7 +358,7 @@
368 358
 	 *
369 359
 	 * @api
370 360
 	 */
371
-	gBool gfxSemWait(gfxSem *psem, gDelay ms);
361
+	gBool gfxSemWait(gSem *psem, gDelay ms);
372 362
 
373 363
 	/**
374 364
 	 * @brief	Test if a wait on a semaphore can be satisfied immediately
@@ -380,7 +370,7 @@
380 370
 	 * @iclass
381 371
 	 * @api
382 372
 	 */
383
-	gBool gfxSemWaitI(gfxSem *psem);
373
+	gBool gfxSemWaitI(gSem *psem);
384 374
 
385 375
 	/**
386 376
 	 * @brief	Signal a semaphore
@@ -392,7 +382,7 @@
392 382
 	 *
393 383
 	 * @api
394 384
 	 */
395
-	void gfxSemSignal(gfxSem *psem);
385
+	void gfxSemSignal(gSem *psem);
396 386
 
397 387
 	/**
398 388
 	 * @brief	Signal a semaphore
@@ -405,7 +395,7 @@
405 395
 	 * @iclass
406 396
 	 * @api
407 397
 	 */
408
-	void gfxSemSignalI(gfxSem *psem);
398
+	void gfxSemSignalI(gSem *psem);
409 399
 
410 400
 	/**
411 401
 	 * @brief	Start a new thread.
@@ -420,7 +410,7 @@
420 410
 	 *
421 411
 	 * @api
422 412
 	 */
423
-	gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
413
+	gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
424 414
 
425 415
 	/**
426 416
 	 * @brief	Wait for a thread to finish.
@@ -453,6 +443,17 @@
453 443
 	 */
454 444
 	void gfxThreadClose(gThread thread);
455 445
 
446
+	/*
447
+	 * @brief	Return from a thread
448
+	 *
449
+	 * @details	Some underlying operating systems allow to return a value from a thread while others don't.
450
+	 *			For systems that don't allow to return a value from a thread function this call is simply ignored.
451
+	 * @pre		This pseudo function can only be called within the main body of the thread function (not a sub-function)
452
+	 *
453
+	 * @param[in] reval		The value which should be returned
454
+	 */
455
+	#define gfxThreadReturn(retval)				return retval
456
+
456 457
 /**
457 458
  * All the above was just for the doxygen documentation. All the implementation of the above
458 459
  * (without any of the documentation overheads) is in the files below.
@@ -502,11 +503,17 @@
502 503
 		#endif
503 504
 	typedef gTicks			systemticks_t;
504 505
 	typedef gThread			gfxThreadHandle;
506
+		#define DECLARE_THREAD_FUNCTION	GFX_THREAD_FUNCTION
507
+		#define DECLARE_THREAD_STACK	GFX_THREAD_STACK
505 508
 	typedef gThreadreturn	threadreturn_t;
509
+		#define THREAD_RETURN		gfxThreadReturn
506 510
 	typedef gThreadpriority	threadpriority_t;
507 511
 		#define LOW_PRIORITY		gThreadpriorityLow
508 512
 		#define NORMAL_PRIORITY		gThreadpriorityNormal
509 513
 		#define HIGH_PRIORITY		gThreadpriorityHigh
514
+	typedef gSem			gfxSem;
515
+		#define MAX_SEMAPHORE_COUNT	gSemMaxCount
516
+	typedef gMutex			gfxMutex;
510 517
 #endif
511 518
 
512 519
 #endif /* _GOS_H */

+ 7 - 7
src/gos/gos_chibios.c

@@ -99,7 +99,7 @@ void gfxSleepMicroseconds(gDelay ms)
99 99
 	}
100 100
 }
101 101
 
102
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
102
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
103 103
 {
104 104
 	if (val > limit)
105 105
 		val = limit;
@@ -113,12 +113,12 @@ void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
113 113
 	#endif
114 114
 }
115 115
 
116
-void gfxSemDestroy(gfxSem *psem)
116
+void gfxSemDestroy(gSem *psem)
117 117
 {
118 118
 	chSemReset(&psem->sem, 1);
119 119
 }
120 120
 
121
-gBool gfxSemWait(gfxSem *psem, gDelay ms)
121
+gBool gfxSemWait(gSem *psem, gDelay ms)
122 122
 {
123 123
 	#if CH_KERNEL_MAJOR <= 2
124 124
 		switch(ms) {
@@ -135,7 +135,7 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms)
135 135
 	#endif
136 136
 }
137 137
 
138
-gBool gfxSemWaitI(gfxSem *psem)
138
+gBool gfxSemWaitI(gSem *psem)
139 139
 {
140 140
 	#if CH_KERNEL_MAJOR <= 3
141 141
 		if (psem->sem.s_cnt <= 0)
@@ -148,7 +148,7 @@ gBool gfxSemWaitI(gfxSem *psem)
148 148
 	return gTrue;
149 149
 }
150 150
 
151
-void gfxSemSignal(gfxSem *psem)
151
+void gfxSemSignal(gSem *psem)
152 152
 {
153 153
 	chSysLock();
154 154
 
@@ -164,7 +164,7 @@ void gfxSemSignal(gfxSem *psem)
164 164
 	chSysUnlock();
165 165
 }
166 166
 
167
-void gfxSemSignalI(gfxSem *psem)
167
+void gfxSemSignalI(gSem *psem)
168 168
 {
169 169
 	#if CH_KERNEL_MAJOR <= 3
170 170
 		if (psem->sem.s_cnt < psem->limit)
@@ -175,7 +175,7 @@ void gfxSemSignalI(gfxSem *psem)
175 175
 	#endif
176 176
 }
177 177
 
178
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
178
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
179 179
 {
180 180
 	if (!stackarea) {
181 181
 		if (!stacksz) stacksz = 256;

+ 20 - 20
src/gos/gos_chibios.h

@@ -38,33 +38,33 @@ typedef cnt_t		gSemcount;
38 38
 typedef msg_t		gThreadreturn;
39 39
 typedef tprio_t		gThreadpriority;
40 40
 
41
-#define MAX_SEMAPHORE_COUNT			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
42
-#define gThreadpriorityLow				LOWPRIO
43
-#define gThreadpriorityNormal				NORMALPRIO
44
-#define gThreadpriorityHigh				HIGHPRIO
41
+#define gSemMaxCount			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
42
+#define gThreadpriorityLow		LOWPRIO
43
+#define gThreadpriorityNormal	NORMALPRIO
44
+#define gThreadpriorityHigh		HIGHPRIO
45 45
 
46
-#define DECLARE_THREAD_STACK(name, sz)			WORKING_AREA(name, sz)
47
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
48
-#define THREAD_RETURN(retval)					return retval
46
+#define GFX_THREAD_STACK(name, sz)			WORKING_AREA(name, sz)
47
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
48
+#define gfxThreadReturn(retval)				return retval
49 49
 
50 50
 #if CH_KERNEL_MAJOR <= 2
51 51
 	typedef struct {
52 52
 		Semaphore	sem;
53 53
 		gSemcount	limit;
54
-	} gfxSem;
54
+	} gSem;
55 55
 
56
-	typedef Mutex		gfxMutex;
56
+	typedef Mutex		gMutex;
57 57
 	typedef Thread*		gThread;
58 58
 #else
59
-	#undef DECLARE_THREAD_STACK
60
-	#define DECLARE_THREAD_STACK(a, b)  THD_WORKING_AREA(a, b)
59
+	#undef GFX_THREAD_STACK
60
+	#define GFX_THREAD_STACK(a, b)  THD_WORKING_AREA(a, b)
61 61
 
62 62
 	typedef struct {
63 63
 		semaphore_t	sem;
64 64
 		gSemcount	limit;
65
-	} gfxSem;
65
+	} gSem;
66 66
 
67
-	typedef mutex_t		gfxMutex;
67
+	typedef mutex_t		gMutex;
68 68
 	typedef thread_t*	gThread;
69 69
 #endif
70 70
 
@@ -104,13 +104,13 @@ typedef tprio_t		gThreadpriority;
104 104
 void *gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz);
105 105
 void gfxSleepMilliseconds(gDelay ms);
106 106
 void gfxSleepMicroseconds(gDelay ms);
107
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
108
-void gfxSemDestroy(gfxSem *psem);
109
-gBool gfxSemWait(gfxSem *psem, gDelay ms);
110
-gBool gfxSemWaitI(gfxSem *psem);
111
-void gfxSemSignal(gfxSem *psem);
112
-void gfxSemSignalI(gfxSem *psem);
113
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
107
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
108
+void gfxSemDestroy(gSem *psem);
109
+gBool gfxSemWait(gSem *psem, gDelay ms);
110
+gBool gfxSemWaitI(gSem *psem);
111
+void gfxSemSignal(gSem *psem);
112
+void gfxSemSignalI(gSem *psem);
113
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
114 114
 #define gfxThreadWait(thread)		chThdWait(thread)
115 115
 #define gfxThreadMe()				chThdSelf()
116 116
 #define gfxThreadClose(thread)		(void)thread

+ 8 - 8
src/gos/gos_cmsis.c

@@ -38,7 +38,7 @@ void _gosDeinit(void)
38 38
 {
39 39
 }
40 40
 
41
-void gfxMutexInit(gfxMutex* pmutex)
41
+void gfxMutexInit(gMutex* pmutex)
42 42
 {
43 43
 	osMutexDef_t def;
44 44
 	def.mutex = pmutex->mutex;
@@ -46,7 +46,7 @@ void gfxMutexInit(gfxMutex* pmutex)
46 46
 	pmutex->id = osMutexCreate(&def);
47 47
 }
48 48
 
49
-void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
49
+void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
50 50
 {
51 51
 	osSemaphoreDef_t def;
52 52
 	def.semaphore = psem->semaphore;
@@ -56,12 +56,12 @@ void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
56 56
 	psem->id = osSemaphoreCreate(&def, val);
57 57
 }
58 58
 
59
-void gfxSemDestroy(gfxSem* psem)
59
+void gfxSemDestroy(gSem* psem)
60 60
 {
61 61
 	osSemaphoreDelete(psem->id);
62 62
 }
63 63
 
64
-gBool gfxSemWait(gfxSem* psem, gDelay ms)
64
+gBool gfxSemWait(gSem* psem, gDelay ms)
65 65
 {
66 66
 	if (osSemaphoreWait(psem->id, ms) > 0) {
67 67
 		psem->available++;
@@ -70,17 +70,17 @@ gBool gfxSemWait(gfxSem* psem, gDelay ms)
70 70
 	return gFalse;
71 71
 }
72 72
 
73
-gBool gfxSemWaitI(gfxSem* psem)
73
+gBool gfxSemWaitI(gSem* psem)
74 74
 {
75 75
 	return gfxSemWait(psem, 0);
76 76
 }
77 77
 
78
-void gfxSemSignal(gfxSem* psem)
78
+void gfxSemSignal(gSem* psem)
79 79
 {
80 80
 	gfxSemSignalI(psem);
81 81
 }
82 82
 
83
-void gfxSemSignalI(gfxSem* psem)
83
+void gfxSemSignalI(gSem* psem)
84 84
 {
85 85
 	if (psem->available) {
86 86
 		psem->available--;
@@ -88,7 +88,7 @@ void gfxSemSignalI(gfxSem* psem)
88 88
 	}
89 89
 }
90 90
 
91
-gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
91
+gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param)
92 92
 {	
93 93
 	osThreadDef_t def;
94 94
 

+ 20 - 20
src/gos/gos_cmsis.h

@@ -27,33 +27,33 @@
27 27
 
28 28
 #define gDelayNone			0
29 29
 #define gDelayForever		osWaitForever
30
-typedef gU32			gDelay;
31
-typedef gU32			gTicks;
32
-typedef gU16			gSemcount;
30
+typedef gU32				gDelay;
31
+typedef gU32				gTicks;
32
+typedef gU16				gSemcount;
33 33
 typedef void				gThreadreturn;
34 34
 typedef osPriority			gThreadpriority;
35 35
 
36
-#define MAX_SEMAPHORE_COUNT	osFeature_Semaphore
36
+#define gSemMaxCount			osFeature_Semaphore
37 37
 #define gThreadpriorityLow		osPriorityLow
38
-#define gThreadpriorityNormal		osPriorityNormal
38
+#define gThreadpriorityNormal	osPriorityNormal
39 39
 #define gThreadpriorityHigh		osPriorityHigh
40 40
 
41
-typedef struct gfxSem {
41
+typedef struct gSem {
42 42
 	gU32		semaphore[2];
43 43
 	osSemaphoreId	id;
44 44
 	gSemcount		available;
45
-} gfxSem;
45
+} gSem;
46 46
 
47
-typedef struct gfxMutex {
47
+typedef struct gMutex {
48 48
 	gU32 mutex[4];
49 49
 	osMutexId id;
50
-} gfxMutex;
50
+} gMutex;
51 51
 
52 52
 typedef osThreadId			gThread;
53 53
 
54
-#define DECLARE_THREAD_STACK(name, sz)			gU8 name[1];	// Some compilers don't allow zero sized arrays. Let's waste one byte
55
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void* param)
56
-#define THREAD_RETURN(retval)
54
+#define GFX_THREAD_STACK(name, sz)			gU8 name[1];	// Some compilers don't allow zero sized arrays. Let's waste one byte
55
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void* param)
56
+#define gfxThreadReturn(retval)				return
57 57
 
58 58
 /*===========================================================================*/
59 59
 /* Function declarations.                                                    */
@@ -67,19 +67,19 @@ typedef osThreadId			gThread;
67 67
 #define gfxSystemUnlock()			osKernelStart()
68 68
 #define gfxSleepMilliseconds(ms) 	osDelay(ms)
69 69
 
70
-void gfxMutexInit(gfxMutex* pmutex);
70
+void gfxMutexInit(gMutex* pmutex);
71 71
 #define gfxMutexDestroy(pmutex)		osMutexDelete((pmutex)->id)
72 72
 #define gfxMutexEnter(pmutex)		osMutexWait((pmutex)->id, gDelayForever)
73 73
 #define gfxMutexExit(pmutex)		osMutexRelease((pmutex)->id)
74 74
 
75
-void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
76
-void gfxSemDestroy(gfxSem* psem);
77
-gBool gfxSemWait(gfxSem* psem, gDelay ms);
78
-gBool gfxSemWaitI(gfxSem* psem);
79
-void gfxSemSignal(gfxSem* psem);
80
-void gfxSemSignalI(gfxSem* psem);
75
+void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit);
76
+void gfxSemDestroy(gSem* psem);
77
+gBool gfxSemWait(gSem* psem, gDelay ms);
78
+gBool gfxSemWaitI(gSem* psem);
79
+void gfxSemSignal(gSem* psem);
80
+void gfxSemSignalI(gSem* psem);
81 81
 
82
-gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
82
+gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param);
83 83
 #define gfxYield()					osThreadYield()
84 84
 #define gfxThreadMe()				osThreadGetId()
85 85
 #define gfxThreadClose(thread)		{}

+ 5 - 5
src/gos/gos_cmsis2.c

@@ -31,7 +31,7 @@ void _gosInit(void)
31 31
 }
32 32
 
33 33
 #if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
34
-	static DECLARE_THREAD_FUNCTION(startUGFX_CMSIS2, p) {
34
+	static GFX_THREAD_FUNCTION(startUGFX_CMSIS2, p) {
35 35
 		(void) p;
36 36
 		uGFXMain();
37 37
 	}
@@ -59,24 +59,24 @@ void _gosDeinit(void)
59 59
 {
60 60
 }
61 61
 
62
-void gfxMutexInit(gfxMutex* pmutex)
62
+void gfxMutexInit(gMutex* pmutex)
63 63
 {
64 64
 	*pmutex = osMutexNew(NULL);
65 65
 }
66 66
 
67
-void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
67
+void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
68 68
 {
69 69
 	*psem = osSemaphoreNew(limit, val, NULL);
70 70
 }
71 71
 
72
-gBool gfxSemWait(gfxSem* psem, gDelay ms)
72
+gBool gfxSemWait(gSem* psem, gDelay ms)
73 73
 {
74 74
 	if (osSemaphoreAcquire(*psem, gfxMillisecondsToTicks(ms)) == osOK)
75 75
 		return gTrue;
76 76
 	return gFalse;
77 77
 }
78 78
 
79
-gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
79
+gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param)
80 80
 {
81 81
 	osThreadAttr_t def;
82 82
 

+ 14 - 14
src/gos/gos_cmsis2.h

@@ -27,26 +27,26 @@
27 27
 
28 28
 #define gDelayNone			0
29 29
 #define gDelayForever		osWaitForever
30
-typedef gU32			gDelay;
31
-typedef gU32			gTicks;
32
-typedef gU16			gSemcount;
30
+typedef gU32				gDelay;
31
+typedef gU32				gTicks;
32
+typedef gU16				gSemcount;
33 33
 typedef void				gThreadreturn;
34 34
 typedef osPriority_t		gThreadpriority;
35 35
 
36
-#define MAX_SEMAPHORE_COUNT	65535UL
36
+#define gSemMaxCount			65535UL
37 37
 #define gThreadpriorityLow		osPriorityLow
38
-#define gThreadpriorityNormal		osPriorityNormal
38
+#define gThreadpriorityNormal	osPriorityNormal
39 39
 #define gThreadpriorityHigh		osPriorityHigh
40 40
 
41
-typedef osSemaphoreId_t		gfxSem;
41
+typedef osSemaphoreId_t		gSem;
42 42
 
43
-typedef osMutexId_t 		gfxMutex;
43
+typedef osMutexId_t 		gMutex;
44 44
 
45 45
 typedef osThreadId_t		gThread;
46 46
 
47
-#define DECLARE_THREAD_STACK(name, sz)			gU8 name[1];	// Some compilers don't allow zero sized arrays. Let's waste one byte
48
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void* param)
49
-#define THREAD_RETURN(retval)
47
+#define GFX_THREAD_STACK(name, sz)			gU8 name[1];	// Some compilers don't allow zero sized arrays. Let's waste one byte
48
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void* param)
49
+#define gfxThreadReturn(retval)				return
50 50
 
51 51
 /*===========================================================================*/
52 52
 /* Function declarations.                                                    */
@@ -60,19 +60,19 @@ typedef osThreadId_t		gThread;
60 60
 #define gfxSystemUnlock()			osKernelUnlock()
61 61
 #define gfxSleepMilliseconds(ms) 	osDelay(ms)
62 62
 
63
-void gfxMutexInit(gfxMutex* pmutex);
63
+void gfxMutexInit(gMutex* pmutex);
64 64
 #define gfxMutexDestroy(pmutex)		osMutexDelete(*(pmutex))
65 65
 #define gfxMutexEnter(pmutex)		osMutexAcquire(*(pmutex), gDelayForever)
66 66
 #define gfxMutexExit(pmutex)		osMutexRelease(*(pmutex))
67 67
 
68
-void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
68
+void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit);
69 69
 #define gfxSemDestroy(psem)		osSemaphoreDelete(*(psem))
70
-gBool gfxSemWait(gfxSem* psem, gDelay ms);
70
+gBool gfxSemWait(gSem* psem, gDelay ms);
71 71
 #define gfxSemWaitI(psem)		gfxSemWait((psem), 0)
72 72
 #define gfxSemSignal(psem)		osSemaphoreRelease(*(psem))
73 73
 #define gfxSemSignalI(psem)		osSemaphoreRelease(*(psem))
74 74
 
75
-gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
75
+gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param);
76 76
 #define gfxYield()					osThreadYield()
77 77
 #define gfxThreadMe()				osThreadGetId()
78 78
 #define gfxThreadClose(thread)		{}

+ 9 - 9
src/gos/gos_ecos.c

@@ -50,7 +50,7 @@ void gfxSleepMicroseconds(gDelay ms)
50 50
 	}
51 51
 }
52 52
 
53
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
53
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
54 54
 {
55 55
 	if (val > limit)
56 56
 		val = limit;
@@ -59,12 +59,12 @@ void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
59 59
 	cyg_semaphore_init(&psem->sem, val);
60 60
 }
61 61
 
62
-void gfxSemDestroy(gfxSem *psem)
62
+void gfxSemDestroy(gSem *psem)
63 63
 {
64 64
 	cyg_semaphore_destroy(&psem->sem);
65 65
 }
66 66
 
67
-gBool gfxSemWait(gfxSem *psem, gDelay ms)
67
+gBool gfxSemWait(gSem *psem, gDelay ms)
68 68
 {
69 69
 	switch(ms) {
70 70
 	case gDelayNone:	return cyg_semaphore_trywait(&psem->sem);
@@ -73,14 +73,14 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms)
73 73
 	}
74 74
 }
75 75
 
76
-gBool gfxSemWaitI(gfxSem *psem)
76
+gBool gfxSemWaitI(gSem *psem)
77 77
 {
78 78
 	return cyg_semaphore_trywait(&psem->sem);
79 79
 }
80 80
 
81
-void gfxSemSignal(gfxSem *psem)
81
+void gfxSemSignal(gSem *psem)
82 82
 {
83
-	if (psem->limit == MAX_SEMAPHORE_COUNT)
83
+	if (psem->limit == gSemMaxCount)
84 84
 		cyg_semaphore_post(&psem->sem);
85 85
 	else {
86 86
 		cyg_scheduler_lock();
@@ -90,13 +90,13 @@ void gfxSemSignal(gfxSem *psem)
90 90
 	}
91 91
 }
92 92
 
93
-void gfxSemSignalI(gfxSem *psem)
93
+void gfxSemSignalI(gSem *psem)
94 94
 {
95
-	if (psem->limit == MAX_SEMAPHORE_COUNT || cyg_semaphore_peek(&psem->sem, &cnt) < psem->limit)
95
+	if (psem->limit == gSemMaxCount || cyg_semaphore_peek(&psem->sem, &cnt) < psem->limit)
96 96
 		cyg_semaphore_post(&psem->sem);
97 97
 }
98 98
 
99
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
99
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
100 100
 {
101 101
 	gThread		th;
102 102
 

+ 16 - 16
src/gos/gos_ecos.h

@@ -28,21 +28,21 @@ typedef void				gThreadreturn;
28 28
 typedef cyg_addrword_t		gThreadpriority;
29 29
 typedef cyg_handle_t		gThread;
30 30
 
31
-#define MAX_SEMAPHORE_COUNT			0x7FFFFFFF
32
-#define gThreadpriorityLow				(CYGNUM_KERNEL_SCHED_PRIORITIES-2)
33
-#define gThreadpriorityNormal				(CYGNUM_KERNEL_SCHED_PRIORITIES/2)
34
-#define gThreadpriorityHigh				0
31
+#define gSemMaxCount			0x7FFFFFFF
32
+#define gThreadpriorityLow		(CYGNUM_KERNEL_SCHED_PRIORITIES-2)
33
+#define gThreadpriorityNormal	(CYGNUM_KERNEL_SCHED_PRIORITIES/2)
34
+#define gThreadpriorityHigh		0
35 35
 
36
-#define DECLARE_THREAD_STACK(name, sz)			struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1]
37
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(cyg_addrword_t param)
38
-#define THREAD_RETURN(retval)
36
+#define GFX_THREAD_STACK(name, sz)			struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1]
37
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(cyg_addrword_t param)
38
+#define gfxThreadReturn(retval)				return
39 39
 
40 40
 typedef struct {
41 41
 	cyg_sem_t	sem;
42 42
 	gSemcount	limit;
43
-	} gfxSem;
43
+	} gSem;
44 44
 
45
-typedef cyg_mutex_t		gfxMutex;
45
+typedef cyg_mutex_t		gMutex;
46 46
 
47 47
 
48 48
 /*===========================================================================*/
@@ -70,14 +70,14 @@ void gfxSleepMicroseconds(gDelay ms);
70 70
 #define gfxMutexDestroy(pmutex)			cyg_mutex_destroy(pmutex)
71 71
 #define gfxMutexEnter(pmutex)			cyg_mutex_lock(pmutex)
72 72
 
73
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
74
-void gfxSemDestroy(gfxSem *psem);
75
-gBool gfxSemWait(gfxSem *psem, gDelay ms);
76
-gBool gfxSemWaitI(gfxSem *psem);
77
-void gfxSemSignal(gfxSem *psem);
78
-void gfxSemSignalI(gfxSem *psem);
73
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
74
+void gfxSemDestroy(gSem *psem);
75
+gBool gfxSemWait(gSem *psem, gDelay ms);
76
+gBool gfxSemWaitI(gSem *psem);
77
+void gfxSemSignal(gSem *psem);
78
+void gfxSemSignalI(gSem *psem);
79 79
 
80
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
80
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
81 81
 #define gfxThreadWait(thread)		NOTIMPLEMENTED_YET
82 82
 #define gfxThreadMe()				cyg_thread_self()
83 83
 #define gfxThreadClose(thread)		(void)thread

+ 8 - 8
src/gos/gos_freertos.c

@@ -42,7 +42,7 @@ void _gosInit(void)
42 42
 }
43 43
 
44 44
 #if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
45
-	static DECLARE_THREAD_FUNCTION(startUGFX_FreeRTOS, p) {
45
+	static GFX_THREAD_FUNCTION(startUGFX_FreeRTOS, p) {
46 46
 		(void) p;
47 47
 		uGFXMain();
48 48
 	}
@@ -98,7 +98,7 @@ void gfxSleepMicroseconds(gDelay ms)
98 98
 	// vUsDelay(ms%1000);
99 99
 }
100 100
 
101
-void gfxMutexInit(gfxMutex *pmutex)
101
+void gfxMutexInit(gMutex *pmutex)
102 102
 {
103 103
 	*pmutex = xSemaphoreCreateMutex();
104 104
 	#if GFX_FREERTOS_USE_TRACE
@@ -106,7 +106,7 @@ void gfxMutexInit(gfxMutex *pmutex)
106 106
 	#endif
107 107
 }
108 108
 
109
-void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
109
+void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
110 110
 {
111 111
 	if (val > limit)
112 112
 		val = limit;
@@ -117,14 +117,14 @@ void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
117 117
 	#endif
118 118
 }
119 119
 
120
-gBool gfxSemWait(gfxSem* psem, gDelay ms)
120
+gBool gfxSemWait(gSem* psem, gDelay ms)
121 121
 {
122 122
 	if (xSemaphoreTake(*psem, gfxMillisecondsToTicks(ms)) == pdPASS)
123 123
 		return gTrue;
124 124
 	return gFalse;
125 125
 }
126 126
 
127
-gBool gfxSemWaitI(gfxSem* psem)
127
+gBool gfxSemWaitI(gSem* psem)
128 128
 {
129 129
 	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
130 130
 
@@ -133,20 +133,20 @@ gBool gfxSemWaitI(gfxSem* psem)
133 133
 	return gFalse;
134 134
 }
135 135
 
136
-void gfxSemSignal(gfxSem* psem)
136
+void gfxSemSignal(gSem* psem)
137 137
 {
138 138
 	xSemaphoreGive(*psem);
139 139
 	taskYIELD();
140 140
 }
141 141
 
142
-void gfxSemSignalI(gfxSem* psem)
142
+void gfxSemSignalI(gSem* psem)
143 143
 {
144 144
 	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
145 145
 
146 146
 	xSemaphoreGiveFromISR(*psem,&xHigherPriorityTaskWoken);
147 147
 }
148 148
 
149
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
149
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
150 150
 {
151 151
 	gThread task;
152 152
 	(void) stackarea;

+ 15 - 15
src/gos/gos_freertos.h

@@ -26,24 +26,24 @@
26 26
 
27 27
 #define gDelayNone			0
28 28
 #define gDelayForever		((gDelay)-1)
29
-typedef gU32			gDelay;
29
+typedef gU32				gDelay;
30 30
 typedef portTickType		gTicks;
31 31
 typedef gI32				gSemcount;
32 32
 typedef void				gThreadreturn;
33 33
 typedef portBASE_TYPE		gThreadpriority;
34 34
 
35
-#define MAX_SEMAPHORE_COUNT	((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
35
+#define gSemMaxCount			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
36 36
 #define gThreadpriorityLow		0
37
-#define gThreadpriorityNormal		configMAX_PRIORITIES/2
37
+#define gThreadpriorityNormal	configMAX_PRIORITIES/2
38 38
 #define gThreadpriorityHigh		configMAX_PRIORITIES-1
39 39
 
40 40
 /* FreeRTOS will allocate the stack when creating the thread */
41
-#define DECLARE_THREAD_STACK(name, sz)	gU8 name[1]
42
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
43
-#define THREAD_RETURN(retval)
41
+#define GFX_THREAD_STACK(name, sz)			gU8 name[1]
42
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
43
+#define gfxThreadReturn(retval)				return
44 44
 
45
-typedef xSemaphoreHandle		gfxSem;
46
-typedef xSemaphoreHandle		gfxMutex;
45
+typedef xSemaphoreHandle		gSem;
46
+typedef xSemaphoreHandle		gMutex;
47 47
 typedef xTaskHandle				gThread;
48 48
 
49 49
 /*===========================================================================*/
@@ -60,7 +60,7 @@ typedef xTaskHandle				gThread;
60 60
 #define gfxSystemLock()				taskENTER_CRITICAL()
61 61
 #define gfxSystemUnlock()			taskEXIT_CRITICAL()
62 62
 
63
-void gfxMutexInit(gfxMutex* s);
63
+void gfxMutexInit(gMutex* s);
64 64
 #define gfxMutexDestroy(pmutex)		vSemaphoreDelete(*(pmutex))
65 65
 #define gfxMutexEnter(pmutex)		xSemaphoreTake(*(pmutex),portMAX_DELAY)
66 66
 #define gfxMutexExit(pmutex)		xSemaphoreGive(*(pmutex))
@@ -69,13 +69,13 @@ void *gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz);
69 69
 void gfxSleepMilliseconds(gDelay ms);
70 70
 void gfxSleepMicroseconds(gDelay ms);
71 71
 
72
-void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
72
+void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit);
73 73
 #define gfxSemDestroy(psem)			vSemaphoreDelete(*(psem))
74
-gBool gfxSemWait(gfxSem* psem, gDelay ms);
75
-gBool gfxSemWaitI(gfxSem* psem);
76
-void gfxSemSignal(gfxSem* psem);
77
-void gfxSemSignalI(gfxSem* psem);
78
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
74
+gBool gfxSemWait(gSem* psem, gDelay ms);
75
+gBool gfxSemWaitI(gSem* psem);
76
+void gfxSemSignal(gSem* psem);
77
+void gfxSemSignalI(gSem* psem);
78
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
79 79
 
80 80
 #define gfxThreadMe()				xTaskGetCurrentTaskHandle()
81 81
 #if INCLUDE_eTaskGetState == 1

+ 10 - 10
src/gos/gos_linux.c

@@ -25,7 +25,7 @@
25 25
 	#define linuxyield()	pthread_yield()
26 26
 #endif
27 27
 
28
-static gfxMutex		SystemMutex;
28
+static gMutex		SystemMutex;
29 29
 
30 30
 void _gosInit(void)
31 31
 {
@@ -109,7 +109,7 @@ gTicks gfxSystemTicks(void) {
109 109
 	return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
110 110
 }
111 111
 
112
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
112
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param) {
113 113
 	gThread		th;
114 114
 	(void)				stackarea;
115 115
 	(void)				stacksz;
@@ -138,14 +138,14 @@ gThreadreturn gfxThreadWait(gThread thread) {
138 138
 }
139 139
 
140 140
 #if GFX_USE_POSIX_SEMAPHORES
141
-	void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
141
+	void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
142 142
 		pSem->max = limit;
143 143
 		sem_init(&pSem->sem, 0, val);
144 144
 	}
145
-	void gfxSemDestroy(gfxSem *pSem) {
145
+	void gfxSemDestroy(gSem *pSem) {
146 146
 		sem_destroy(&pSem->sem);
147 147
 	}
148
-	gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
148
+	gBool gfxSemWait(gSem *pSem, gDelay ms) {
149 149
 		switch (ms) {
150 150
 		case gDelayForever:
151 151
 			return sem_wait(&pSem->sem) ? gFalse : gTrue;
@@ -164,7 +164,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
164 164
 			}
165 165
 		}
166 166
 	}
167
-	void gfxSemSignal(gfxSem *pSem) {
167
+	void gfxSemSignal(gSem *pSem) {
168 168
 		int	res;
169 169
 
170 170
 		res = 0;
@@ -173,7 +173,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
173 173
 			sem_post(&pSem->sem);
174 174
 	}
175 175
 #else
176
-	void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
176
+	void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
177 177
 		pthread_mutex_init(&pSem->mtx, 0);
178 178
 		pthread_cond_init(&pSem->cond, 0);
179 179
 		pthread_mutex_lock(&pSem->mtx);
@@ -181,11 +181,11 @@ gThreadreturn gfxThreadWait(gThread thread) {
181 181
 		pSem->max = limit;
182 182
 		pthread_mutex_unlock(&pSem->mtx);
183 183
 	}
184
-	void gfxSemDestroy(gfxSem *pSem) {
184
+	void gfxSemDestroy(gSem *pSem) {
185 185
 		pthread_mutex_destroy(&pSem->mtx);
186 186
 		pthread_cond_destroy(&pSem->cond);
187 187
 	}
188
-	gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
188
+	gBool gfxSemWait(gSem *pSem, gDelay ms) {
189 189
 		pthread_mutex_lock(&pSem->mtx);
190 190
 
191 191
 		switch (ms) {
@@ -226,7 +226,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
226 226
 		pthread_mutex_unlock(&pSem->mtx);
227 227
 		return gTrue;
228 228
 	}
229
-	void gfxSemSignal(gfxSem *pSem) {
229
+	void gfxSemSignal(gSem *pSem) {
230 230
 		pthread_mutex_lock(&pSem->mtx);
231 231
 
232 232
 		if (pSem->cnt < pSem->max) {

+ 20 - 20
src/gos/gos_linux.h

@@ -28,12 +28,12 @@ typedef void *				gThreadreturn;
28 28
 typedef unsigned long		gDelay;
29 29
 typedef pthread_t 			gThread;
30 30
 typedef int					gThreadpriority;
31
-typedef gU32			gSemcount;
32
-typedef pthread_mutex_t		gfxMutex;
31
+typedef gU32				gSemcount;
32
+typedef pthread_mutex_t		gMutex;
33 33
 
34
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
35
-#define DECLARE_THREAD_STACK(name, sz)			gU8 name[0];
36
-#define THREAD_RETURN(retval)					return retval
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
37 37
 
38 38
 #define gfxExit()						exit(0)
39 39
 #define gfxAlloc(sz)					malloc(sz)
@@ -49,25 +49,25 @@ typedef pthread_mutex_t		gfxMutex;
49 49
 #define gfxSemWaitI(psem)				gfxSemWait(psem, gDelayNone)
50 50
 #define gfxSemSignalI(psem)				gfxSemSignal(psem)
51 51
 
52
-#define gDelayNone					0
53
-#define gDelayForever				((gDelay)-1)
54
-#define MAX_SEMAPHORE_COUNT			((gSemcount)-1)
55
-#define gThreadpriorityLow				10
56
-#define gThreadpriorityNormal				0
57
-#define gThreadpriorityHigh				-10
52
+#define gDelayNone				0
53
+#define gDelayForever			((gDelay)-1)
54
+#define gSemMaxCount			((gSemcount)-1)
55
+#define gThreadpriorityLow		10
56
+#define gThreadpriorityNormal	0
57
+#define gThreadpriorityHigh		-10
58 58
 
59 59
 #if GFX_USE_POSIX_SEMAPHORES
60
-	typedef struct gfxSem {
60
+	typedef struct gSem {
61 61
 		sem_t			sem;
62 62
 		gSemcount		max;
63
-	} gfxSem;
63
+	} gSem;
64 64
 #else
65
-	typedef struct gfxSem {
65
+	typedef struct gSem {
66 66
 		pthread_mutex_t	mtx;
67 67
 		pthread_cond_t	cond;
68 68
 		gSemcount		cnt;
69 69
 		gSemcount		max;
70
-	} gfxSem;
70
+	} gSem;
71 71
 #endif
72 72
 
73 73
 /*===========================================================================*/
@@ -81,11 +81,11 @@ void gfxSleepMicroseconds(gDelay ms);
81 81
 gTicks gfxSystemTicks(void);
82 82
 void gfxSystemLock(void);
83 83
 void gfxSystemUnlock(void);
84
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
85
-void gfxSemDestroy(gfxSem *psem);
86
-gBool gfxSemWait(gfxSem *psem, gDelay ms);
87
-void gfxSemSignal(gfxSem *psem);
88
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
84
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
85
+void gfxSemDestroy(gSem *psem);
86
+gBool gfxSemWait(gSem *psem, gDelay ms);
87
+void gfxSemSignal(gSem *psem);
88
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
89 89
 gThreadreturn gfxThreadWait(gThread thread);
90 90
 
91 91
 #endif /* GFX_USE_OS_LINUX */

+ 6 - 6
src/gos/gos_osx.c

@@ -22,7 +22,7 @@
22 22
 #include <mach/clock.h>
23 23
 #include <mach/mach.h>
24 24
 
25
-static gfxMutex		SystemMutex;
25
+static gMutex		SystemMutex;
26 26
 
27 27
 void _gosInit(void)
28 28
 {
@@ -92,7 +92,7 @@ gTicks gfxSystemTicks(void) {
92 92
 	return ts.tv_sec * 1000UL + ts.tv_nsec / 1000000;
93 93
 }
94 94
 
95
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
95
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param) {
96 96
 	gThread		th;
97 97
 	(void)				stackarea;
98 98
 	(void)				stacksz;
@@ -118,7 +118,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
118 118
 	return retval;
119 119
 }
120 120
 
121
-void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
121
+void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
122 122
 	pthread_mutex_init(&pSem->mtx, 0);
123 123
 	pthread_cond_init(&pSem->cond, 0);
124 124
 	pthread_mutex_lock(&pSem->mtx);
@@ -127,12 +127,12 @@ void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
127 127
 	pthread_mutex_unlock(&pSem->mtx);
128 128
 }
129 129
 
130
-void gfxSemDestroy(gfxSem *pSem) {
130
+void gfxSemDestroy(gSem *pSem) {
131 131
 	pthread_mutex_destroy(&pSem->mtx);
132 132
 	pthread_cond_destroy(&pSem->cond);
133 133
 }
134 134
 
135
-gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
135
+gBool gfxSemWait(gSem *pSem, gDelay ms) {
136 136
 	pthread_mutex_lock(&pSem->mtx);
137 137
 	switch (ms) {
138 138
 	case gDelayForever:
@@ -171,7 +171,7 @@ gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
171 171
 	return gTrue;
172 172
 }
173 173
 
174
-void gfxSemSignal(gfxSem *pSem) {
174
+void gfxSemSignal(gSem *pSem) {
175 175
 	pthread_mutex_lock(&pSem->mtx);
176 176
 	if (pSem->cnt < pSem->max) {
177 177
 		pSem->cnt++;

+ 16 - 16
src/gos/gos_osx.h

@@ -19,12 +19,12 @@ typedef void *				gThreadreturn;
19 19
 typedef unsigned long		gDelay;
20 20
 typedef pthread_t 			gThread;
21 21
 typedef int					gThreadpriority;
22
-typedef gU32			gSemcount;
23
-typedef pthread_mutex_t		gfxMutex;
22
+typedef gU32				gSemcount;
23
+typedef pthread_mutex_t		gMutex;
24 24
 
25
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
26
-#define DECLARE_THREAD_STACK(name, sz)			gU8 name[0];
27
-#define THREAD_RETURN(retval)					return retval
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
28 28
 
29 29
 #define gfxExit()						exit(0)
30 30
 #define gfxAlloc(sz)					malloc(sz)
@@ -43,17 +43,17 @@ typedef pthread_mutex_t		gfxMutex;
43 43
 
44 44
 #define gDelayNone					0
45 45
 #define gDelayForever				((gDelay)-1)
46
-#define MAX_SEMAPHORE_COUNT			((gSemcount)-1)
47
-#define gThreadpriorityLow				10
48
-#define gThreadpriorityNormal				0
49
-#define gThreadpriorityHigh				-10
46
+#define gSemMaxCount				((gSemcount)-1)
47
+#define gThreadpriorityLow			10
48
+#define gThreadpriorityNormal		0
49
+#define gThreadpriorityHigh			-10
50 50
 
51
-typedef struct gfxSem {
51
+typedef struct gSem {
52 52
 	pthread_mutex_t	mtx;
53 53
 	pthread_cond_t	cond;
54 54
 	gSemcount		cnt;
55 55
 	gSemcount		max;
56
-} gfxSem;
56
+} gSem;
57 57
 
58 58
 /*===========================================================================*/
59 59
 /* Function declarations.                                                    */
@@ -65,11 +65,11 @@ void gfxSleepMicroseconds(gDelay ms);
65 65
 gTicks gfxSystemTicks(void);
66 66
 void gfxSystemLock(void);
67 67
 void gfxSystemUnlock(void);
68
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
69
-void gfxSemDestroy(gfxSem *psem);
70
-gBool gfxSemWait(gfxSem *psem, gDelay ms);
71
-void gfxSemSignal(gfxSem *psem);
72
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
68
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
69
+void gfxSemDestroy(gSem *psem);
70
+gBool gfxSemWait(gSem *psem, gDelay ms);
71
+void gfxSemSignal(gSem *psem);
72
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
73 73
 gThreadreturn gfxThreadWait(gThread thread);
74 74
 
75 75
 #endif /* GFX_USE_OS_OSX */

+ 11 - 11
src/gos/gos_qt.cpp

@@ -133,59 +133,59 @@ void gfxSystemUnlock(void)
133 133
     _systemMutex.unlock();
134 134
 }
135 135
 
136
-void gfxMutexInit(gfxMutex *pmutex)
136
+void gfxMutexInit(gMutex *pmutex)
137 137
 {
138 138
     *pmutex = new QMutex;
139 139
 }
140 140
 
141
-void gfxMutexDestroy(gfxMutex *pmutex)
141
+void gfxMutexDestroy(gMutex *pmutex)
142 142
 {
143 143
     delete static_cast<QMutex*>(*pmutex);
144 144
 }
145 145
 
146
-void gfxMutexEnter(gfxMutex *pmutex)
146
+void gfxMutexEnter(gMutex *pmutex)
147 147
 {
148 148
     static_cast<QMutex*>(*pmutex)->lock();
149 149
 }
150 150
 
151
-void gfxMutexExit(gfxMutex *pmutex)
151
+void gfxMutexExit(gMutex *pmutex)
152 152
 {
153 153
     static_cast<QMutex*>(*pmutex)->unlock();
154 154
 }
155 155
 
156
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
156
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
157 157
 {
158 158
     *psem = new QSemaphore(limit);
159 159
 
160 160
     static_cast<QSemaphore*>(*psem)->release(val);
161 161
 }
162 162
 
163
-void gfxSemDestroy(gfxSem *psem)
163
+void gfxSemDestroy(gSem *psem)
164 164
 {
165 165
     delete static_cast<QSemaphore*>(*psem);
166 166
 }
167 167
 
168
-gBool gfxSemWait(gfxSem *psem, gDelay ms)
168
+gBool gfxSemWait(gSem *psem, gDelay ms)
169 169
 {
170 170
     return static_cast<QSemaphore*>(*psem)->tryAcquire(1, ms);
171 171
 }
172 172
 
173
-gBool gfxSemWaitI(gfxSem *psem)
173
+gBool gfxSemWaitI(gSem *psem)
174 174
 {
175 175
     return static_cast<QSemaphore*>(*psem)->tryAcquire(1);
176 176
 }
177 177
 
178
-void gfxSemSignal(gfxSem *psem)
178
+void gfxSemSignal(gSem *psem)
179 179
 {
180 180
     static_cast<QSemaphore*>(*psem)->release(1);
181 181
 }
182 182
 
183
-void gfxSemSignalI(gfxSem *psem)
183
+void gfxSemSignalI(gSem *psem)
184 184
 {
185 185
     static_cast<QSemaphore*>(*psem)->release(1);
186 186
 }
187 187
 
188
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
188
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
189 189
 {
190 190
     Q_UNUSED(stackarea)
191 191
 

+ 22 - 22
src/gos/gos_qt.h

@@ -10,21 +10,21 @@
10 10
 
11 11
 #if GFX_USE_OS_QT
12 12
 
13
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
14
-#define DECLARE_THREAD_STACK(name, sz)          gU8 name[0]
15
-#define THREAD_RETURN(retval)					return retval
13
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
14
+#define GFX_THREAD_STACK(name, sz)          gU8 name[0]
15
+#define gfxThreadReturn(retval)				return retval
16 16
 
17
-#define gDelayNone					0
18
-#define gDelayForever				((gDelay)-1)
19
-#define MAX_SEMAPHORE_COUNT			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
20
-#define gThreadpriorityLow				2
21
-#define gThreadpriorityNormal				3
22
-#define gThreadpriorityHigh				4
17
+#define gDelayNone				0
18
+#define gDelayForever			((gDelay)-1)
19
+#define gSemMaxCount			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
20
+#define gThreadpriorityLow		2
21
+#define gThreadpriorityNormal	3
22
+#define gThreadpriorityHigh		4
23 23
 
24 24
 typedef int gTicks;
25 25
 typedef int gDelay;
26
-typedef void* gfxMutex;
27
-typedef void* gfxSem;
26
+typedef void* gMutex;
27
+typedef void* gSem;
28 28
 typedef int gSemcount;
29 29
 typedef int gThreadreturn;
30 30
 typedef int gThreadpriority;
@@ -45,17 +45,17 @@ gTicks gfxSystemTicks(void);
45 45
 gTicks gfxMillisecondsToTicks(gDelay ms);
46 46
 void gfxSystemLock(void);
47 47
 void gfxSystemUnlock(void);
48
-void gfxMutexInit(gfxMutex *pmutex);
49
-void gfxMutexDestroy(gfxMutex *pmutex);
50
-void gfxMutexEnter(gfxMutex *pmutex);
51
-void gfxMutexExit(gfxMutex *pmutex);
52
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
53
-void gfxSemDestroy(gfxSem *psem);
54
-gBool gfxSemWait(gfxSem *psem, gDelay ms);
55
-gBool gfxSemWaitI(gfxSem *psem);
56
-void gfxSemSignal(gfxSem *psem);
57
-void gfxSemSignalI(gfxSem *psem);
58
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
48
+void gfxMutexInit(gMutex *pmutex);
49
+void gfxMutexDestroy(gMutex *pmutex);
50
+void gfxMutexEnter(gMutex *pmutex);
51
+void gfxMutexExit(gMutex *pmutex);
52
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
53
+void gfxSemDestroy(gSem *psem);
54
+gBool gfxSemWait(gSem *psem, gDelay ms);
55
+gBool gfxSemWaitI(gSem *psem);
56
+void gfxSemSignal(gSem *psem);
57
+void gfxSemSignalI(gSem *psem);
58
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
59 59
 gThreadreturn gfxThreadWait(gThread thread);
60 60
 gThread gfxThreadMe(void);
61 61
 void gfxThreadClose(gThread thread);

+ 3 - 3
src/gos/gos_rawrtos.c

@@ -59,7 +59,7 @@ void gfxSleepMicroseconds(gDelay us)
59 59
 	raw_sleep(ticks);
60 60
 }
61 61
 
62
-gBool gfxSemWait(gfxSem* psem, gDelay ms)
62
+gBool gfxSemWait(gSem* psem, gDelay ms)
63 63
 {
64 64
 	gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
65 65
 	if(!ticks)ticks=1;
@@ -68,14 +68,14 @@ gBool gfxSemWait(gfxSem* psem, gDelay ms)
68 68
 	return gFalse;
69 69
 }
70 70
 
71
-gBool gfxSemWaitI(gfxSem* psem)
71
+gBool gfxSemWaitI(gSem* psem)
72 72
 {
73 73
 	if(raw_semaphore_get((psem), RAW_NO_WAIT)==RAW_SUCCESS)
74 74
 		return gTrue;
75 75
 	return gFalse;
76 76
 }
77 77
 
78
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
78
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
79 79
 {
80 80
 	RAW_U16 ret;
81 81
 	gThread taskobj;

+ 12 - 12
src/gos/gos_rawrtos.h

@@ -7,24 +7,24 @@
7 7
 
8 8
 #define gDelayNone			(RAW_NO_WAIT)
9 9
 #define gDelayForever		(RAW_WAIT_FOREVER)
10
-typedef gU32			gDelay;
10
+typedef gU32				gDelay;
11 11
 typedef RAW_TICK_TYPE		gTicks;
12 12
 typedef gI32				gSemcount;
13
-typedef gU32			gThreadreturn;
13
+typedef gU32				gThreadreturn;
14 14
 typedef RAW_U8				gThreadpriority;
15 15
 
16
-#define MAX_SEMAPHORE_COUNT	RAW_SEMAPHORE_COUNT
16
+#define gSemMaxCount			RAW_SEMAPHORE_COUNT
17 17
 #define gThreadpriorityLow		(CONFIG_RAW_PRIO_MAX-2)
18
-#define gThreadpriorityNormal		(CONFIG_RAW_PRIO_MAX/2)
18
+#define gThreadpriorityNormal	(CONFIG_RAW_PRIO_MAX/2)
19 19
 #define gThreadpriorityHigh		1
20 20
 
21
-typedef RAW_SEMAPHORE		gfxSem;
22
-typedef RAW_MUTEX			gfxMutex;
21
+typedef RAW_SEMAPHORE		gSem;
22
+typedef RAW_MUTEX			gMutex;
23 23
 typedef RAW_TASK_OBJ*		gThread;
24 24
 
25
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
26
-#define DECLARE_THREAD_STACK(name, sz)			PORT_STACK name[(sz) & ~3];
27
-#define THREAD_RETURN(retval)					return retval
25
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
26
+#define GFX_THREAD_STACK(name, sz)			PORT_STACK name[(sz) & ~3];
27
+#define gfxThreadReturn(retval)				return retval
28 28
 
29 29
 #define gfxHalt(msg)					for(;;)
30 30
 #define gfxExit()						for(;;)
@@ -65,9 +65,9 @@ extern RAW_U16 raw_semaphore_put(RAW_SEMAPHORE *semaphore_ptr);
65 65
 
66 66
 void gfxSleepMilliseconds(gDelay ms);
67 67
 void gfxSleepMicroseconds(gDelay us);
68
-gBool gfxSemWait(gfxSem* psem, gDelay ms);
69
-gBool gfxSemWaitI(gfxSem* psem);
70
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
68
+gBool gfxSemWait(gSem* psem, gDelay ms);
69
+gBool gfxSemWaitI(gSem* psem);
70
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
71 71
 
72 72
 #endif
73 73
 

+ 3 - 3
src/gos/gos_win32.c

@@ -74,7 +74,7 @@ void gfxSystemUnlock(void) {
74 74
 	ReleaseMutex(SystemMutex);
75 75
 }
76 76
 
77
-gBool gfxSemWait(gfxSem *psem, gDelay ms) {
77
+gBool gfxSemWait(gSem *psem, gDelay ms) {
78 78
 	return WaitForSingleObject(*psem, ms) == WAIT_OBJECT_0;
79 79
 }
80 80
 
@@ -87,7 +87,7 @@ typedef LONG (__stdcall *_NtQuerySemaphore)(
87 87
 );
88 88
 
89 89
 /* - Left here simply because of its undocumented cleverness...
90
-gSemcount gfxSemCounter(gfxSem *pSem) {
90
+gSemcount gfxSemCounter(gSem *pSem) {
91 91
 	static _NtQuerySemaphore NtQuerySemaphore;
92 92
 	struct _SEMAPHORE_BASIC_INFORMATION {
93 93
 	    ULONG CurrentCount;
@@ -103,7 +103,7 @@ gSemcount gfxSemCounter(gfxSem *pSem) {
103 103
 }
104 104
 */
105 105
 
106
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param) {
106
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION(*fn,p), void *param) {
107 107
 	(void)	stackarea;
108 108
 	HANDLE	thd;
109 109
 

+ 11 - 11
src/gos/gos_win32.h

@@ -31,19 +31,19 @@ typedef LONG				gSemcount;
31 31
 typedef DWORD				gThreadreturn;
32 32
 typedef int					gThreadpriority;
33 33
 
34
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn (WINAPI fnName)(void *param)
35
-#define DECLARE_THREAD_STACK(name, sz)			gU8 name[1];
36
-#define THREAD_RETURN(retval)					return retval
34
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn (WINAPI fnName)(void *param)
35
+#define GFX_THREAD_STACK(name, sz)			gU8 name[1];
36
+#define gfxThreadReturn(retval)				return retval
37 37
 
38 38
 #define gDelayNone					0
39 39
 #define gDelayForever				INFINITE
40
-#define MAX_SEMAPHORE_COUNT			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
41
-#define gThreadpriorityLow				THREAD_PRIORITY_BELOW_NORMAL
42
-#define gThreadpriorityNormal				THREAD_PRIORITY_NORMAL
43
-#define gThreadpriorityHigh				THREAD_PRIORITY_ABOVE_NORMAL
40
+#define gSemMaxCount				((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
41
+#define gThreadpriorityLow			THREAD_PRIORITY_BELOW_NORMAL
42
+#define gThreadpriorityNormal		THREAD_PRIORITY_NORMAL
43
+#define gThreadpriorityHigh			THREAD_PRIORITY_ABOVE_NORMAL
44 44
 
45
-typedef HANDLE gfxSem;
46
-typedef HANDLE gfxMutex;
45
+typedef HANDLE gSem;
46
+typedef HANDLE gMutex;
47 47
 typedef HANDLE gThread;
48 48
 
49 49
 #define gfxExit()						ExitProcess(0)
@@ -72,10 +72,10 @@ typedef HANDLE gThread;
72 72
 
73 73
 void gfxHalt(const char *msg);
74 74
 void gfxSleepMicroseconds(gDelay ms);
75
-gBool gfxSemWait(gfxSem *psem, gDelay ms);
75
+gBool gfxSemWait(gSem *psem, gDelay ms);
76 76
 void gfxSystemLock(void);
77 77
 void gfxSystemUnlock(void);
78
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param);
78
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION(*fn,p), void *param);
79 79
 gThreadreturn gfxThreadWait(gThread thread);
80 80
 
81 81
 #endif /* GFX_USE_OS_WIN32 */

+ 9 - 9
src/gos/gos_x_threads.c

@@ -26,11 +26,11 @@ void gfxSystemUnlock(void) {
26 26
 	INTERRUPTS_ON();
27 27
 }
28 28
 
29
-void gfxMutexInit(gfxMutex *pmutex) {
29
+void gfxMutexInit(gMutex *pmutex) {
30 30
 	pmutex[0] = 0;
31 31
 }
32 32
 
33
-void gfxMutexEnter(gfxMutex *pmutex) {
33
+void gfxMutexEnter(gMutex *pmutex) {
34 34
 	INTERRUPTS_OFF();
35 35
 	while (pmutex[0]) {
36 36
 		INTERRUPTS_ON();
@@ -41,16 +41,16 @@ void gfxMutexEnter(gfxMutex *pmutex) {
41 41
 	INTERRUPTS_ON();
42 42
 }
43 43
 
44
-void gfxMutexExit(gfxMutex *pmutex) {
44
+void gfxMutexExit(gMutex *pmutex) {
45 45
 	pmutex[0] = 0;
46 46
 }
47 47
 
48
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit) {
48
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit) {
49 49
 	psem->cnt = val;
50 50
 	psem->limit = limit;
51 51
 }
52 52
 
53
-gBool gfxSemWait(gfxSem *psem, gDelay ms) {
53
+gBool gfxSemWait(gSem *psem, gDelay ms) {
54 54
 	gTicks	starttm, delay;
55 55
 
56 56
 	// Convert our delay to ticks
@@ -90,20 +90,20 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms) {
90 90
 	return gTrue;
91 91
 }
92 92
 
93
-gBool gfxSemWaitI(gfxSem *psem) {
93
+gBool gfxSemWaitI(gSem *psem) {
94 94
 	if (psem->cnt <= 0)
95 95
 		return gFalse;
96 96
 	psem->cnt--;
97 97
 	return gTrue;
98 98
 }
99 99
 
100
-void gfxSemSignal(gfxSem *psem) {
100
+void gfxSemSignal(gSem *psem) {
101 101
 	INTERRUPTS_OFF();
102 102
 	gfxSemSignalI(psem);
103 103
 	INTERRUPTS_ON();
104 104
 }
105 105
 
106
-void gfxSemSignalI(gfxSem *psem) {
106
+void gfxSemSignalI(gSem *psem) {
107 107
 	if (psem->cnt < psem->limit)
108 108
 		psem->cnt++;
109 109
 }
@@ -508,7 +508,7 @@ void gfxThreadExit(gThreadreturn ret) {
508 508
 	// We never get back here as we didn't re-queue ourselves
509 509
 }
510 510
 
511
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
511
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param) {
512 512
 	thread *	t;
513 513
 	thread *	me;
514 514
 	(void)		prio;

+ 20 - 20
src/gos/gos_x_threads.h

@@ -30,23 +30,23 @@ typedef short			gSemcount;
30 30
 typedef int				gThreadreturn;
31 31
 typedef int				gThreadpriority;
32 32
 
33
-#define DECLARE_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
34
-#define DECLARE_THREAD_STACK(name, sz)			gU8 name[(sz) & ~3];
35
-#define THREAD_RETURN(retval)					return retval
33
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void *param)
34
+#define GFX_THREAD_STACK(name, sz)			gU8 name[(sz) & ~3];
35
+#define gfxThreadReturn(retval)				return retval
36 36
 
37
-#define gDelayNone					0
38
-#define gDelayForever				((gDelay)-1)
39
-#define MAX_SEMAPHORE_COUNT			0x7FFF
40
-#define gThreadpriorityLow				0
41
-#define gThreadpriorityNormal				1
42
-#define gThreadpriorityHigh				2
37
+#define gDelayNone				0
38
+#define gDelayForever			((gDelay)-1)
39
+#define gSemMaxCount			0x7FFF
40
+#define gThreadpriorityLow		0
41
+#define gThreadpriorityNormal	1
42
+#define gThreadpriorityHigh		2
43 43
 
44 44
 typedef struct {
45 45
 	gSemcount		cnt;
46 46
 	gSemcount		limit;
47
-} gfxSem;
47
+} gSem;
48 48
 
49
-typedef gU32		gfxMutex;
49
+typedef gU32		gMutex;
50 50
 typedef void *			gThread;
51 51
 
52 52
 // Required timing functions - supplied by the user or the operating system
@@ -63,21 +63,21 @@ void gfxSystemLock(void);
63 63
 void gfxSystemUnlock(void);
64 64
 
65 65
 // Mutexes
66
-void gfxMutexInit(gfxMutex *pmutex);
66
+void gfxMutexInit(gMutex *pmutex);
67 67
 #define gfxMutexDestroy(pmutex)
68
-void gfxMutexEnter(gfxMutex *pmutex);
69
-void gfxMutexExit(gfxMutex *pmutex);
68
+void gfxMutexEnter(gMutex *pmutex);
69
+void gfxMutexExit(gMutex *pmutex);
70 70
 
71 71
 // Semaphores
72
-void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
72
+void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
73 73
 #define gfxSemDestroy(psem)
74
-gBool gfxSemWait(gfxSem *psem, gDelay ms);
75
-gBool gfxSemWaitI(gfxSem *psem);
76
-void gfxSemSignal(gfxSem *psem);
77
-void gfxSemSignalI(gfxSem *psem);
74
+gBool gfxSemWait(gSem *psem, gDelay ms);
75
+gBool gfxSemWaitI(gSem *psem);
76
+void gfxSemSignal(gSem *psem);
77
+void gfxSemSignalI(gSem *psem);
78 78
 
79 79
 // Threads
80
-gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
80
+gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
81 81
 #define gfxThreadClose(thread)
82 82
 gThreadreturn gfxThreadWait(gThread thread);
83 83
 gThread gfxThreadMe(void);

+ 9 - 11
src/gos/gos_zephyr.h

@@ -22,24 +22,22 @@ typedef u32_t	gSemcount;
22 22
 typedef void	gThreadreturn;
23 23
 typedef int	gThreadpriority;
24 24
 
25
-#define DECLARE_THREAD_FUNCTION(fnName, param)\
26
-	gThreadreturn fnName(void* param, void* p2, void* p3)
25
+#define GFX_THREAD_FUNCTION(fnName, param)	gThreadreturn fnName(void* param, void* p2, void* p3)
27 26
 
28
-#define DECLARE_THREAD_STACK(name, sz)\
29
-	K_THREAD_STACK_DEFINE(name, sz)
27
+#define GFX_THREAD_STACK(name, sz)			K_THREAD_STACK_DEFINE(name, sz)
30 28
 
31
-#define THREAD_RETURN(retval)		return
29
+#define gfxThreadReturn(retval)				return
32 30
 
33 31
 #define gDelayNone				K_NO_WAIT
34 32
 #define gDelayForever			K_FOREVER
35
-#define MAX_SEMAPHORE_COUNT		((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
36
-#define gThreadpriorityLow			CONFIG_NUM_PREEMPT_PRIORITIES-1
37
-#define gThreadpriorityNormal			1
38
-#define gThreadpriorityHigh			0
33
+#define gSemMaxCount			((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
34
+#define gThreadpriorityLow		CONFIG_NUM_PREEMPT_PRIORITIES-1
35
+#define gThreadpriorityNormal	1
36
+#define gThreadpriorityHigh		0
39 37
 
40
-typedef struct k_sem gfxSem;
38
+typedef struct k_sem gSem;
41 39
 
42
-typedef struct k_mutex gfxMutex;
40
+typedef struct k_mutex gMutex;
43 41
 
44 42
 typedef k_tid_t gThread;
45 43
 

+ 2 - 2
src/gqueue/gqueue.c

@@ -156,7 +156,7 @@ void _gqueueDeinit(void)
156 156
 #if GQUEUE_NEED_GSYNC
157 157
 	void gfxQueueGSyncInit(gfxQueueGSync *pqueue) {
158 158
 		pqueue->head = pqueue->tail = 0;
159
-		gfxSemInit(&pqueue->sem, 0, MAX_SEMAPHORE_COUNT);
159
+		gfxSemInit(&pqueue->sem, 0, gSemMaxCount);
160 160
 	}
161 161
 	void gfxQueueGSyncDeinit(gfxQueueGSync *pqueue) {
162 162
 		pqueue->head = pqueue->tail = 0;
@@ -294,7 +294,7 @@ void _gqueueDeinit(void)
294 294
 #if GQUEUE_NEED_FSYNC
295 295
 	void gfxQueueFSyncInit(gfxQueueFSync *pqueue) {
296 296
 		pqueue->head = pqueue->tail = 0;
297
-		gfxSemInit(&pqueue->sem, 0, MAX_SEMAPHORE_COUNT);
297
+		gfxSemInit(&pqueue->sem, 0, gSemMaxCount);
298 298
 	}
299 299
 	void gfxQueueFSyncDeinit(gfxQueueFSync *pqueue) {
300 300
 		while(gfxQueueFSyncGet(pqueue, gDelayNone));

+ 3 - 3
src/gqueue/gqueue.h

@@ -43,7 +43,7 @@ typedef struct gfxQueueASyncItem {
43 43
 
44 44
 typedef struct gfxQueueFSyncItem {
45 45
 	struct gfxQueueFSyncItem	*next;
46
-	gfxSem						sem;
46
+	gSem						sem;
47 47
 } gfxQueueFSyncItem;
48 48
 /** @} */
49 49
 
@@ -59,13 +59,13 @@ typedef struct gfxQueueASync {
59 59
 typedef struct gfxQueueGSync {
60 60
 	gfxQueueGSyncItem	*head;
61 61
 	gfxQueueGSyncItem	*tail;
62
-	gfxSem				sem;
62
+	gSem				sem;
63 63
 } gfxQueueGSync;
64 64
 
65 65
 typedef struct gfxQueueFSync {
66 66
 	gfxQueueFSyncItem	*head;
67 67
 	gfxQueueFSyncItem	*tail;
68
-	gfxSem				sem;
68
+	gSem				sem;
69 69
 } gfxQueueFSync;
70 70
 /** @} */
71 71
 

+ 6 - 6
src/gtimer/gtimer.c

@@ -18,18 +18,18 @@
18 18
 #define TimeIsWithin(x, start, end)	((end >= start && x >= start && x <= end) || (end < start && (x >= start || x <= end)))
19 19
 
20 20
 /* This mutex protects access to our tables */
21
-static gfxMutex			mutex;
21
+static gMutex	mutex;
22 22
 static gThread	hThread = 0;
23
-static GTimer			*pTimerHead = 0;
24
-static gfxSem			waitsem;
23
+static GTimer	*pTimerHead = 0;
24
+static gSem		waitsem;
25 25
 static gTicks	ticks2ms;
26
-static DECLARE_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
26
+static GFX_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
27 27
 
28 28
 /*===========================================================================*/
29 29
 /* Driver local functions.                                                   */
30 30
 /*===========================================================================*/
31 31
 
32
-static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
32
+static GFX_THREAD_FUNCTION(GTimerThreadHandler, arg) {
33 33
 	GTimer			*pt;
34 34
 	gTicks	tm;
35 35
 	gTicks	nxtTimeout;
@@ -109,7 +109,7 @@ static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
109 109
 		lastTime = tm;
110 110
 		gfxMutexExit(&mutex);
111 111
 	}
112
-	THREAD_RETURN(0);
112
+	gfxThreadReturn(0);
113 113
 }
114 114
 
115 115
 void _gtimerInit(void)

+ 2 - 2
src/gwin/gwin_wm.c

@@ -24,7 +24,7 @@
24 24
 	#define MIN_WIN_WIDTH	1
25 25
 	#define MIN_WIN_HEIGHT	1
26 26
 
27
-	static gfxMutex		gmutex;
27
+	static gMutex		gmutex;
28 28
 
29 29
 	void _gwmInit(void)	{
30 30
 		gfxMutexInit(&gmutex);
@@ -162,7 +162,7 @@
162 162
 extern const GWindowManager	GNullWindowManager;
163 163
 GWindowManager *			_GWINwm;
164 164
 gBool						_gwinFlashState;
165
-static gfxSem				gwinsem;
165
+static gSem					gwinsem;
166 166
 static gfxQueueASync		_GWINList;
167 167
 #if GWIN_NEED_FLASHING
168 168
 	static GTimer			FlashTimer;