+#include <cfg/macros.h> // BV()
+
+#include <cpu/irq.h>
+
+#include <kern/proc.h>
+
+#if CONFIG_KERN_SIGNALS
+
+INLINE sigmask_t __sig_checkSignal(Signal *s, sigmask_t sigs)
+{
+ sigmask_t result;
+
+ result = s->recv & sigs;
+ s->recv &= ~sigs;
+
+ return result;
+}
+
+/**
+ * Check if any of the signals in \a sigs has occurred and clear them.
+ *
+ * \return the signals that have occurred.
+ */
+INLINE sigmask_t sig_checkSignal(Signal *s, sigmask_t sigs)
+{
+ cpu_flags_t flags;
+ sigmask_t result;
+
+ IRQ_SAVE_DISABLE(flags);
+ result = __sig_checkSignal(s, sigs);
+ IRQ_RESTORE(flags);
+
+ return result;
+}
+
+/**
+ * Check if any of the signals in \a sigs has occurred and clear them.
+ *
+ * \return the signals that have occurred.
+ */
+INLINE sigmask_t sig_check(sigmask_t sigs)
+{
+ Process *proc = proc_current();
+ return sig_checkSignal(&proc->sig, sigs);
+}
+
+void sig_sendSignal(Signal *s, Process *proc, sigmask_t sig);
+
+/**
+ * Send the signals \a sigs to the process \a proc and immeditaly dispatch it
+ * for execution.
+ *
+ * The process will be awoken if it was waiting for any of them and immediately
+ * dispatched for execution.
+ *
+ * \note This function can't be called from IRQ context, use sig_post()
+ * instead.
+ */
+INLINE void sig_send(Process *proc, sigmask_t sig)
+{
+ sig_sendSignal(&proc->sig, proc, sig);
+}
+
+void sig_postSignal(Signal *s, Process *proc, sigmask_t sig);
+
+/**
+ * Send the signals \a sigs to the process \a proc.
+ * The process will be awoken if it was waiting for any of them.
+ *
+ * \note This call is interrupt safe.
+ */
+INLINE void sig_post(Process *proc, sigmask_t sig)
+{
+ sig_postSignal(&proc->sig, proc, sig);
+}
+
+/*
+ * XXX: this is provided for backword compatibility, consider to make this
+ * deprecated for the future.
+ */
+INLINE void sig_signal(Process *proc, sigmask_t sig)
+{
+ sig_postSignal(&proc->sig, proc, sig);
+}
+
+sigmask_t sig_waitSignal(Signal *s, sigmask_t sigs);