X-Git-Url: http://git.jankratochvil.net/?a=blobdiff_plain;f=src%2Flibcaptive%2Fke%2Fevent.c;h=1ec3b44ff619d4626e8e3fc0cd65e91376509d9a;hb=a2dd38f86df22c46ae18f3ad7d9850eaacb02b92;hp=5a9d142ea835a3d6af91d0b2f6d6c4cb38a135bd;hpb=f1749916d66b0f25f93a252fee0c8117aba451e6;p=captive.git diff --git a/src/libcaptive/ke/event.c b/src/libcaptive/ke/event.c index 5a9d142..1ec3b44 100644 --- a/src/libcaptive/ke/event.c +++ b/src/libcaptive/ke/event.c @@ -21,13 +21,15 @@ #include "reactos/ddk/kefuncs.h" /* self */ #include +#include "reactos/ddk/exfuncs.h" /* for InterlockedExchange() */ /** * KeInitializeEvent: * @Event: Event to initialize. + * %NULL value is forbidden. * @Type: %NotificationEvent or %SynchronizationEvent. - * @State: Initial state. + * @State: Initial signal state. * * Initalizes a kernel event. Currently libcaptive doesn't use multithreading * and thus this function is a NOP now. @@ -35,7 +37,64 @@ VOID KeInitializeEvent(PKEVENT Event,EVENT_TYPE Type,BOOLEAN State) { g_return_if_fail(Event!=NULL); - g_return_if_fail(Type!=NotificationEvent && Type!=SynchronizationEvent); + g_return_if_fail(Type==NotificationEvent || Type==SynchronizationEvent); /* TODO:thread */ } + + +/** + * KeSetEvent: + * @Event: Event to set its signal state on. + * %NULL value is forbidden. + * @Increment: Thread priority increase during wait; ignored by libcaptive. + * @Wait: Do not release locks, KeWait() is required afterwards; ignored by libcaptive. + * + * Sets the signal state of @Event. Currently libcaptive doesn't use multithreading + * and thus this function will just set the @Event's internal state and it returns + * the previous value. + * See also KeResetEvent(), KeClearEvent(). + * + * Returns: Previous signal state value of @Event. + */ +LONG KeSetEvent(PKEVENT Event,KPRIORITY Increment,BOOLEAN Wait) +{ + g_return_val_if_fail(Event!=NULL,0); + + /* TODO:thread */ + return InterlockedExchange(&(Event->Header.SignalState),1); +} + + +/** + * KeResetEvent: + * @Event: Event to clear its signal state off. + * %NULL value is forbidden. + * + * Clears the signal state of @Event. See also KeSetEvent(). + * Use KeClearEvent() if you do not need the previous signal state of @Event. + * + * Returns: Previous signal state value of @Event. + */ +LONG KeResetEvent(PKEVENT Event) +{ + g_return_val_if_fail(Event!=NULL,0); + + return InterlockedExchange(&(Event->Header.SignalState),0); +} + + +/** + * KeClearEvent: + * @Event: Event to clear its signal state off. + * %NULL value is forbidden. + * + * Clears the signal state of @Event. See also KeSetEvent(). + * Use KeResetEvent() if you need the previous signal state of @Event. + */ +VOID KeClearEvent(PKEVENT Event) +{ + g_return_if_fail(Event!=NULL); + + Event->Header.SignalState=FALSE; +}