+#endif
+
+bool event_loop(void) {
+ running = true;
+
+ fd_set readable;
+ fd_set writable;
+
+ while(running) {
+ gettimeofday(&now, NULL);
+ struct timeval diff, *tv = NULL;
+
+ while(timeout_tree.head) {
+ timeout_t *timeout = timeout_tree.head->data;
+ timersub(&timeout->tv, &now, &diff);
+
+ if(diff.tv_sec < 0) {
+ timeout->cb(timeout->data);
+ if(timercmp(&timeout->tv, &now, <))
+ timeout_del(timeout);
+ } else {
+ tv = &diff;
+ break;
+ }
+ }
+
+ memcpy(&readable, &readfds, sizeof readable);
+ memcpy(&writable, &writefds, sizeof writable);
+
+ int fds = 0;