[MAJOR] replaced all timeouts with struct timeval

The timeout functions were difficult to manipulate because they were
rounding results to the millisecond. Thus, it was difficult to compare
and to check what expired and what did not. Also, the comparison
functions were heavy with multiplies and divides by 1000. Now, all
timeouts are stored in timevals, reducing the number of operations
for updates and leading to cleaner and more efficient code.
diff --git a/src/ev_select.c b/src/ev_select.c
index ed79abf..fb5cc41 100644
--- a/src/ev_select.c
+++ b/src/ev_select.c
@@ -78,7 +78,7 @@
 /*
  * Select() poller
  */
-REGPRM2 static void _do_poll(struct poller *p, int wait_time)
+REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp)
 {
 	int status;
 	int fd, i;
@@ -89,12 +89,14 @@
 		
 	/* allow select to return immediately when needed */
 	delta.tv_sec = delta.tv_usec = 0;
-	if (wait_time > 0) {  /* FIXME */
-		/* Convert to timeval */
-		/* to avoid eventual select loops due to timer precision */
-		wait_time += SCHEDULER_RESOLUTION;
-		delta.tv_sec  = wait_time / 1000; 
-		delta.tv_usec = (wait_time % 1000) * 1000;
+	if (tv_isset(exp)) {
+		tv_remain(&now, exp, &delta);
+		/* To avoid eventual select loops due to timer precision */
+		delta.tv_usec += SCHEDULER_RESOLUTION * 1000;
+		if (delta.tv_usec >= 1000000) {
+			delta.tv_usec -= 1000000;
+			delta.tv_sec ++;
+		}
 	}
 
 	/* let's restore fdset state */
@@ -118,7 +120,7 @@
 			readnotnull ? tmp_evts[DIR_RD] : NULL,
 			writenotnull ? tmp_evts[DIR_WR] : NULL,
 			NULL,
-			(wait_time >= 0) ? &delta : NULL);
+			tv_isset(exp) ? &delta : NULL);
       
 	tv_now(&now);