From: John Hodge Date: Wed, 8 Feb 2012 06:21:40 +0000 (+0800) Subject: AcessNative - Implemented events, don't trust them X-Git-Tag: rel0.15~789^2~2 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5240c280222eb76d29c2eaecaaadcbac01af3a9c;p=tpg%2Facess2.git AcessNative - Implemented events, don't trust them --- diff --git a/AcessNative/acesskernel_src/Makefile b/AcessNative/acesskernel_src/Makefile index a9b7278e..ef63ff2b 100644 --- a/AcessNative/acesskernel_src/Makefile +++ b/AcessNative/acesskernel_src/Makefile @@ -11,7 +11,7 @@ ifeq ($(PLATFORM),) PLATFORM := lin endif -KERNEL_SRC = ../../Kernel/ +KERNEL_SRC = ../../KernelLand/Kernel/ KERNEL_OBJ := logging.o adt.o lib.o drvutil.o debug.o KERNEL_OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/io.o vfs/dir.o diff --git a/AcessNative/acesskernel_src/threads.c b/AcessNative/acesskernel_src/threads.c index 1e7d0c3f..a39fb5e4 100644 --- a/AcessNative/acesskernel_src/threads.c +++ b/AcessNative/acesskernel_src/threads.c @@ -70,6 +70,9 @@ typedef struct sThread tProcess *Process; + Uint32 Events, WaitMask; + SDL_sem *EventSem; + } tThread; // === PROTOTYPES === @@ -359,3 +362,23 @@ int Semaphore_Signal(tSemaphore *Sem, int AmmountToAdd) return AmmountToAdd; } +Uint32 Threads_WaitEvents(Uint32 Mask) +{ + Uint32 rv; + gpCurrentThread->WaitMask = Mask; + if( !(gpCurrentThread->Events & Mask) ) + SDL_SemWait( gpCurrentThread->EventSem ); + rv = gpCurrentThread->Events & Mask; + gpCurrentThread->Events &= ~Mask; + gpCurrentThread->WaitMask = -1; + return rv; +} + +void Threads_PostEvent(tThread *Thread, Uint32 Events) +{ + Thread->Events |= Events; + + if( Thread->WaitMask & Events ) + SDL_SemPost( gpCurrentThread->EventSem ); +} +