[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/include/proto/buffers.h b/include/proto/buffers.h
index 95d63a5..c25e8f6 100644
--- a/include/proto/buffers.h
+++ b/include/proto/buffers.h
@@ -28,6 +28,7 @@
 
 #include <common/config.h>
 #include <common/memory.h>
+#include <common/ticks.h>
 #include <common/time.h>
 
 #include <types/buffers.h>
@@ -68,14 +69,14 @@
 /* marks the buffer as "shutdown pending" for reads and cancels the timeout */
 static inline void buffer_shutr(struct buffer *buf)
 {
-	tv_eternity(&buf->rex);
+	buf->rex = TICK_ETERNITY;
 	buf->flags |= BF_SHUTR_PENDING;
 }
 
 /* marks the buffer as "shutdown pending" for writes and cancels the timeout */
 static inline void buffer_shutw(struct buffer *buf)
 {
-	tv_eternity(&buf->wex);
+	buf->wex = TICK_ETERNITY;
 	buf->flags |= BF_SHUTW_PENDING;
 }
 
diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index 68b3f11..0a20644 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -58,7 +58,7 @@
 #define HTTP_IS_VER_TOKEN(x) (http_is_ver_token[(unsigned char)(x)])
 
 int event_accept(int fd);
-void process_session(struct task *t, struct timeval *next);
+void process_session(struct task *t, int *next);
 int process_cli(struct session *t);
 int process_srv(struct session *t);
 
diff --git a/include/proto/proto_uxst.h b/include/proto/proto_uxst.h
index 642beb8..e46f35e 100644
--- a/include/proto/proto_uxst.h
+++ b/include/proto/proto_uxst.h
@@ -2,7 +2,7 @@
   include/proto/proto_uxst.h
   This file contains UNIX-stream socket protocol definitions.
 
-  Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
+  Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,7 @@
 
 int uxst_event_accept(int fd);
 void uxst_add_listener(struct listener *listener);
-void process_uxst_stats(struct task *t, struct timeval *next);
+void process_uxst_stats(struct task *t, int *next);
 
 #endif /* _PROTO_PROTO_UXST_H */
 
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index 7268bfa..78f6120 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -23,11 +23,12 @@
 #define _PROTO_PROXY_H
 
 #include <common/config.h>
+#include <common/ticks.h>
 #include <common/time.h>
 #include <types/proxy.h>
 
 int start_proxies(int verbose);
-void maintain_proxies(struct timeval *next);
+void maintain_proxies(int *next);
 void soft_stop(void);
 void pause_proxy(struct proxy *p);
 void pause_proxies(void);
@@ -52,14 +53,14 @@
 /* this function initializes all timeouts for proxy p */
 static inline void proxy_reset_timeouts(struct proxy *proxy)
 {
-	tv_eternity(&proxy->timeout.client);
-	tv_eternity(&proxy->timeout.tarpit);
-	tv_eternity(&proxy->timeout.queue);
-	tv_eternity(&proxy->timeout.connect);
-	tv_eternity(&proxy->timeout.server);
-	tv_eternity(&proxy->timeout.appsession);
-	tv_eternity(&proxy->timeout.httpreq);
-	tv_eternity(&proxy->timeout.check);
+	proxy->timeout.client = TICK_ETERNITY;
+	proxy->timeout.tarpit = TICK_ETERNITY;
+	proxy->timeout.queue = TICK_ETERNITY;
+	proxy->timeout.connect = TICK_ETERNITY;
+	proxy->timeout.server = TICK_ETERNITY;
+	proxy->timeout.appsession = TICK_ETERNITY;
+	proxy->timeout.httpreq = TICK_ETERNITY;
+	proxy->timeout.check = TICK_ETERNITY;
 }
 
 #endif /* _PROTO_PROXY_H */
diff --git a/include/proto/task.h b/include/proto/task.h
index cc5c180..10f6b42 100644
--- a/include/proto/task.h
+++ b/include/proto/task.h
@@ -123,13 +123,13 @@
  *   - return the date of next event in <next> or eternity.
  */
 
-void process_runnable_tasks(struct timeval *next);
+void process_runnable_tasks(int *next);
 
 /*
  * Extract all expired timers from the timer queue, and wakes up all
  * associated tasks. Returns the date of next event (or eternity).
  */
-void wake_expired_tasks(struct timeval *next);
+void wake_expired_tasks(int *next);
 
 
 #endif /* _PROTO_TASK_H */