+
+/*
+ * Put current thread to sleep until file descriptor @fd is ready for I/O.
+ * If @flags & EMPTH_FD_READ, wake up if @fd is ready for input.
+ * If @flags & EMPTH_FD_WRITE, wake up if @fd is ready for output.
+ * At most one thread may sleep on the same file descriptor.
+ * @timeout, if non-null, limits the sleep time.
+ * Return one when the @fd is ready, zero on timeout or early wakeup by
+ * empth_wakeup(), -1 on error with errno set.
+ * Note: Currently, Empire sleeps only on network I/O, i.e. @fd is a
+ * socket. Implementations should not rely on that.
+ */
+int empth_select(int fd, int flags, struct timeval *timeout);
+
+/*
+ * Awaken @thread if it is sleeping in empth_select() or empth_sleep().
+ * This does not awaken threads sleeping in other functions.
+ * Does not yield the processor.
+ */
+void empth_wakeup(empth_t *thread);
+
+/*
+ * Put current thread to sleep until the time is @until.
+ * Return 0 if it slept until that time.
+ * Return -1 if woken up early, by empth_wakeup().
+ */
+int empth_sleep(time_t until);
+
+/*
+ * Put current thread to sleep until SIGHUP, SIGINT or SIGTERM is received.
+ * Return the signal number.
+ */
+int empth_wait_for_signal(void);
+
+/*
+ * Create a read-write lock.
+ * @name is its name, it is used for debugging.
+ * Return the read-write lock, or NULL on error.
+ */
+empth_rwlock_t *empth_rwlock_create(char *name);
+
+/*
+ * Destroy @rwlock.
+ */
+void empth_rwlock_destroy(empth_rwlock_t *rwlock);
+
+/*
+ * Lock @rwlock for writing.
+ * A read-write lock can be locked for writing only when it is
+ * unlocked. If this is not the case, put the current thread to sleep
+ * until it is.
+ */
+void empth_rwlock_wrlock(empth_rwlock_t *rwlock);
+
+/*
+ * Lock @rwlock for reading.
+ * A read-write lock can be locked for reading only when it is not
+ * locked for writing, and no other thread is attempting to lock it
+ * for writing. If this is not the case, put the current thread to
+ * sleep until it is.
+ */
+void empth_rwlock_rdlock(empth_rwlock_t *rwlock);
+
+/*
+ * Unlock read-write lock @rwlock.
+ * The current thread must hold @rwlock.
+ * Wake up threads that can now lock it.
+ */
+void empth_rwlock_unlock(empth_rwlock_t *rwlock);
+
+
+/*
+ * Stuff for implementations, not for clients.
+ */
+
+void empth_init_signals(void);