-#if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
-int event_select(Event **evs, int n, ticks_t timeout)
+static NOINLINE bool event_waitTimeoutSlowPath(Event *e, ticks_t timeout)
+{
+ bool ret;
+
+ e->Ev.Sig.sig_proc = proc_current();
+ ret = (sig_waitTimeoutSignal(&e->Ev.Sig.sig,
+ EVENT_GENERIC_SIGNAL, timeout,
+ event_hook_generic_timeout_signal, e) & SIG_TIMEOUT) ?
+ false : true;
+ return ret;
+}
+
+bool event_waitTimeout(Event *e, ticks_t timeout)
+{
+ /*
+ * Fast path: check if the event already happened and return
+ * immediately in this case.
+ */
+ if (sig_checkSignal(&e->Ev.Sig.sig,
+ EVENT_GENERIC_SIGNAL) == EVENT_GENERIC_SIGNAL)
+ return true;
+ return event_waitTimeoutSlowPath(e, timeout);
+}
+
+/*
+ * event_select() slow path: this function handles the case when any event was
+ * not yet notified, so it takes care of making the current process to sleep on
+ * the list of events, mapping them to a different signal bit and issuing a
+ * call to sig_waitTimeout() using the process's sigmask.
+ */
+static NOINLINE int event_selectSlowPath(Event **evs, int n, ticks_t timeout)