MEDIUM: fd: do not use the FD_POLL_* flags in the pollers anymore

As mentioned in previous commit, these flags do not map well to
modern poller capabilities. Let's use the FD_EV_*_{R,W} flags instead.
This first patch only performs a 1-to-1 mapping making sure that the
previously reported flags are still reported identically while using
the closest possible semantics in the pollers.

It's worth noting that kqueue will now support improvements such as
returning distinctions between shut and errors on each direction,
though this is not exploited for now.
diff --git a/include/proto/fd.h b/include/proto/fd.h
index e3b0b2b..3ee71a5 100644
--- a/include/proto/fd.h
+++ b/include/proto/fd.h
@@ -318,20 +318,32 @@
 	updt_fd_polling(fd);
 }
 
-/* Update events seen for FD <fd> and its state if needed. This should be called
- * by the poller to set FD_POLL_* flags. */
-static inline void fd_update_events(int fd, int evts)
+/* Update events seen for FD <fd> and its state if needed. This should be
+ * called by the poller, passing FD_EV_*_{R,W,RW} in <evts>. FD_EV_ERR_*
+ * doesn't need to also pass FD_EV_SHUT_*, it's implied. ERR and SHUT are
+ * allowed to be reported regardless of R/W readiness.
+ */
+static inline void fd_update_events(int fd, unsigned char evts)
 {
 	unsigned long locked = atleast2(fdtab[fd].thread_mask);
 	unsigned char old, new;
+	int new_flags;
+
+	new_flags =
+	      ((evts & FD_EV_READY_R) ? FD_POLL_IN  : 0) |
+	      ((evts & FD_EV_READY_W) ? FD_POLL_OUT : 0) |
+	      ((evts & FD_EV_SHUT_R)  ? FD_POLL_HUP : 0) |
+	      ((evts & FD_EV_SHUT_W)  ? FD_POLL_ERR : 0) |
+	      ((evts & FD_EV_ERR_R)   ? FD_POLL_ERR : 0) |
+	      ((evts & FD_EV_ERR_W)   ? FD_POLL_ERR : 0);
 
 	old = fdtab[fd].ev;
-	new = (old & FD_POLL_STICKY) | evts;
+	new = (old & FD_POLL_STICKY) | new_flags;
 
 	if (unlikely(locked)) {
 		/* Locked FDs (those with more than 2 threads) are atomically updated */
 		while (unlikely(new != old && !_HA_ATOMIC_CAS(&fdtab[fd].ev, &old, new)))
-			new = (old & FD_POLL_STICKY) | evts;
+			new = (old & FD_POLL_STICKY) | new_flags;
 	} else {
 		if (new != old)
 			fdtab[fd].ev = new;