X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fmware%2Fevent.h;h=0a87af1abe170dbf58a80156477c0b80135ec715;hb=89ed880270068f4e28bad0d98020c2902a41fd92;hp=4e2aace1e3c8d8bc12bf79c1b5ff0c0ba3bca6c8;hpb=d6222ffd2cb7f51110e352988df89da3e048d144;p=bertos.git diff --git a/bertos/mware/event.h b/bertos/mware/event.h index 4e2aace1..0a87af1a 100644 --- a/bertos/mware/event.h +++ b/bertos/mware/event.h @@ -30,7 +30,9 @@ * Copyright 1999, 2001, 2003 Bernie Innocenti * --> * - * \addtogroup event_handling + * \defgroup event_handling Event handling module + * \ingroup core + * \{ * * \brief Events handling * @@ -107,12 +109,6 @@ struct Process; #endif -/** - * \defgroup event_handling Events handling module - * \{ - */ - - /// User defined callback type typedef void (*Hook)(void *); @@ -192,15 +188,6 @@ INLINE Event event_createSignal(struct Process *proc, sigbit_t bit) #endif -/** - * Prevent the compiler from optimizing access to the variable \a x, enforcing - * a refetch from memory. This also forbid from reordering successing instances - * of ACCESS_SAFE(). - * - * TODO: move this to cfg/compiler.h - */ -#define ACCESS_SAFE(x) (*(volatile typeof(x) *)&(x)) - #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS /** Initialize the generic sleepable event \a e */ #define event_initGeneric(e) \ @@ -256,23 +243,23 @@ INLINE void event_wait(Event *e) */ INLINE bool event_waitTimeout(Event *e, ticks_t timeout) { + bool ret; + #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS e->Ev.Sig.sig_proc = proc_current(); - return (sig_waitTimeout(e->Ev.Sig.sig_bit, timeout) & SIG_TIMEOUT) ? + ret = (sig_waitTimeout(e->Ev.Sig.sig_bit, timeout) & SIG_TIMEOUT) ? false : true; #else ticks_t end = timer_clock() + timeout; - bool ret; while ((ACCESS_SAFE(e->Ev.Gen.completed) == false) || TIMER_AFTER(timer_clock(), end)) cpu_relax(); ret = e->Ev.Gen.completed; e->Ev.Gen.completed = false; +#endif MEMORY_BARRIER; - return ret; -#endif } #endif /* CONFIG_TIMER_EVENTS */