[MAJOR] convert all expiration timers from timeval to ticks

This is the first attempt at moving all internal parts from
using struct timeval to integer ticks. Those provides simpler
and faster code due to simplified operations, and this change
also saved about 64 bytes per session.

A new header file has been added : include/common/ticks.h.

It is possible that some functions should finally not be inlined
because they're used quite a lot (eg: tick_first, tick_add_ifset
and tick_is_expired). More measurements are required in order to
decide whether this is interesting or not.

Some function and variable names are still subject to change for
a better overall logics.
diff --git a/src/ev_select.c b/src/ev_select.c
index 30df928..ecdd870 100644
--- a/src/ev_select.c
+++ b/src/ev_select.c
@@ -16,6 +16,7 @@
 
 #include <common/compat.h>
 #include <common/config.h>
+#include <common/ticks.h>
 #include <common/time.h>
 
 #include <types/fd.h>
@@ -78,12 +79,8 @@
 /*
  * Select() poller
  */
-REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp)
+REGPRM2 static void _do_poll(struct poller *p, int exp)
 {
-	const struct timeval max_delay = {
-		.tv_sec  = MAX_DELAY_MS / 1000,
-		.tv_usec = (MAX_DELAY_MS % 1000) * 1000
-	};
 	int status;
 	int fd, i;
 	struct timeval delta;
@@ -92,28 +89,22 @@
 	int fds;
 	char count;
 		
-	/* allow select to return immediately when needed */
-	delta.tv_sec = delta.tv_usec = 0;
-	delta_ms = 0;
+	delta_ms      = 0;
+	delta.tv_sec  = 0;
+	delta.tv_usec = 0;
+
 	if (!run_queue) {
-		if (!tv_isset(exp)) {
-			delta = max_delay;
-			delta_ms = MAX_DELAY_MS;
+		if (!exp) {
+			delta_ms      = MAX_DELAY_MS;
+			delta.tv_sec  = (MAX_DELAY_MS / 1000);
+			delta.tv_usec = (MAX_DELAY_MS % 1000) * 1000;
 		}
-		else if (tv_islt(&now, 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 ++;
-			}
-			if (__tv_isge(&delta, &max_delay)) {
-				delta = max_delay;
+		else if (!tick_is_expired(exp, now_ms)) {
+			delta_ms = TICKS_TO_MS(tick_remain(now_ms, exp)) + SCHEDULER_RESOLUTION;
+			if (delta_ms > MAX_DELAY_MS)
 				delta_ms = MAX_DELAY_MS;
-			} else {
-				delta_ms = delta.tv_sec * 1000 + delta.tv_usec / 1000;
-			}
+			delta.tv_sec  = (delta_ms / 1000);
+			delta.tv_usec = (delta_ms % 1000) * 1000;
 		}
 	}