12 #if GQUEUE_NEED_BUFFERS
13 static gfxQueueGSync bufferFreeList;
16 void _gqueueInit(
void)
18 #if GQUEUE_NEED_BUFFERS
19 gfxQueueGSyncInit(&bufferFreeList);
23 void _gqueueDeinit(
void)
29 pqueue->head = pqueue->tail = 0;
40 pi = gfxQueueASyncGetI(pqueue);
48 if ((pi = pqueue->head)) {
49 pqueue->head = pi->next;
58 gfxQueueASyncPutI(pqueue, pitem);
65 pqueue->head = pqueue->tail = pitem;
67 pqueue->tail->next = pitem;
74 gfxQueueASyncPushI(pqueue, pitem);
79 pitem->next = pqueue->head;
87 gfxQueueASyncInsertI(pqueue, pitem, pafter);
93 if (pafter && gfxQueueASyncIsInI(pqueue, pafter)) {
94 pitem->next = pafter->next;
96 if (pqueue->tail == pafter)
101 pqueue->head = pqueue->tail = pitem;
103 pqueue->tail->next = pitem;
104 pqueue->tail = pitem;
111 gfxQueueASyncRemoveI(pqueue, pitem);
119 if (pqueue->head == pitem) {
120 pqueue->head = pitem->next;
123 for(pi = pqueue->head; pi->next; pi = pi->next) {
124 if (pi->next == pitem) {
125 pi->next = pitem->next;
126 if (pqueue->tail == pitem)
140 res = gfxQueueASyncIsInI(pqueue, pitem);
148 for(pi = pqueue->head; pi; pi = pi->next) {
156 #if GQUEUE_NEED_GSYNC
157 void gfxQueueGSyncInit(gfxQueueGSync *pqueue) {
158 pqueue->head = pqueue->tail = 0;
161 void gfxQueueGSyncDeinit(gfxQueueGSync *pqueue) {
162 pqueue->head = pqueue->tail = 0;
174 pqueue->head = pi->next;
187 pqueue->head = pi->next;
194 gfxQueueGSyncPutI(pqueue, pitem);
201 pqueue->head = pqueue->tail = pitem;
203 pqueue->tail->next = pitem;
204 pqueue->tail = pitem;
211 gfxQueueGSyncPushI(pqueue, pitem);
216 pitem->next = pqueue->head;
217 pqueue->head = pitem;
219 pqueue->tail = pitem;
225 gfxQueueGSyncInsertI(pqueue, pitem, pafter);
231 if (pafter && gfxQueueGSyncIsInI(pqueue, pafter)) {
232 pitem->next = pafter->next;
233 pafter->next = pitem;
234 if (pqueue->tail == pafter)
235 pqueue->tail = pitem;
239 pqueue->head = pqueue->tail = pitem;
241 pqueue->tail->next = pitem;
242 pqueue->tail = pitem;
249 gfxQueueGSyncRemoveI(pqueue, pitem);
257 if (pqueue->head == pitem) {
258 pqueue->head = pitem->next;
261 for(pi = pqueue->head; pi->next; pi = pi->next) {
262 if (pi->next == pitem) {
263 pi->next = pitem->next;
264 if (pqueue->tail == pitem)
278 res = gfxQueueGSyncIsInI(pqueue, pitem);
283 gBool gfxQueueGSyncIsInI(gfxQueueGSync *pqueue,
const gfxQueueGSyncItem *pitem) {
286 for(pi = pqueue->head; pi; pi = pi->next) {
294 #if GQUEUE_NEED_FSYNC
295 void gfxQueueFSyncInit(gfxQueueFSync *pqueue) {
296 pqueue->head = pqueue->tail = 0;
299 void gfxQueueFSyncDeinit(gfxQueueFSync *pqueue) {
300 while(gfxQueueFSyncGet(pqueue, gDelayNone));
301 pqueue->head = pqueue->tail = 0;
305 gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, gDelay ms) {
306 gfxQueueFSyncItem *pi;
313 pqueue->head = pi->next;
323 gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms) {
330 pqueue->head = pqueue->tail = pitem;
332 pqueue->tail->next = pitem;
333 pqueue->tail = pitem;
342 gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms) {
347 pitem->next = pqueue->head;
348 pqueue->head = pitem;
350 pqueue->tail = pitem;
358 gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueFSyncItem *pafter, gDelay ms) {
363 if (pafter && gfxQueueFSyncIsInI(pqueue, pafter)) {
364 pitem->next = pafter->next;
365 pafter->next = pitem;
366 if (pqueue->tail == pafter)
367 pqueue->tail = pitem;
371 pqueue->head = pqueue->tail = pitem;
373 pqueue->tail->next = pitem;
374 pqueue->tail = pitem;
385 void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem) {
386 gfxQueueFSyncItem *pi;
391 if (pqueue->head == pitem) {
392 pqueue->head = pitem->next;
400 for(pi = pqueue->head; pi->next; pi = pi->next) {
401 if (pi->next == pitem) {
402 pi->next = pitem->next;
403 if (pqueue->tail == pitem)
412 gBool gfxQueueFSyncIsIn(gfxQueueFSync *pqueue,
const gfxQueueFSyncItem *pitem) {
416 res = gfxQueueFSyncIsInI(pqueue, pitem);
421 gBool gfxQueueFSyncIsInI(gfxQueueFSync *pqueue,
const gfxQueueFSyncItem *pitem) {
422 gfxQueueFSyncItem *pi;
424 for(pi = pqueue->head; pi; pi = pi->next) {
432 #if GQUEUE_NEED_BUFFERS
433 gBool gfxBufferAlloc(
unsigned num, gMemSize size) {
440 size = (size + 3) & ~0x03;
447 for(;num--; pd = (
GDataBuffer *)((
char *)(pd+1)+size)) {
449 gfxBufferRelease(pd);
459 gBool gfxBufferIsAvailable(
void) {
return bufferFreeList.head != 0; }
void gfxSemSignal(gSem *psem)
Signal a semaphore.
gBool gfxSemWait(gSem *psem, gDelay ms)
Wait on a semaphore.
void gfxSystemUnlock(void)
Unlock the operating system previous locked by gfxSystemLock()
void * gfxAlloc(gMemSize sz)
Allocate memory.
void gfxSystemLock(void)
Lock the operating system to protect a sequence of code.
gBool gfxSemWaitI(gSem *psem)
Test if a wait on a semaphore can be satisfied immediately.
void gfxSemDestroy(gSem *psem)
Destroy a Counted Semaphore.
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
Initialise a Counted Semaphore.
void gfxSemSignalI(gSem *psem)
Signal a semaphore.