mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
CLEANUP: polling: gcc doesn't always optimize constants away
In ev_poll and ev_epoll, we have a bit-to-bit mapping between the POLL_ constants and the FD_POLL_ constants. A comment said that gcc was able to detect this and to automatically apply a mask. Things have possibly changed since the output assembly doesn't always reflect this. So let's perform an explicit assignment when bits are equal.
This commit is contained in:
parent
04281bd1ad
commit
462c7206bc
@ -144,15 +144,22 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* it looks complicated but gcc can optimize it away when constants
|
/* it looks complicated but gcc can optimize it away when constants
|
||||||
* have same values.
|
* have same values... In fact it depends on gcc :-(
|
||||||
*/
|
*/
|
||||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||||
fdtab[fd].ev |=
|
if (EPOLLIN == FD_POLL_IN && EPOLLOUT == FD_POLL_OUT &&
|
||||||
((e & EPOLLIN ) ? FD_POLL_IN : 0) |
|
EPOLLPRI == FD_POLL_PRI && EPOLLERR == FD_POLL_ERR &&
|
||||||
((e & EPOLLPRI) ? FD_POLL_PRI : 0) |
|
EPOLLHUP == FD_POLL_HUP) {
|
||||||
((e & EPOLLOUT) ? FD_POLL_OUT : 0) |
|
fdtab[fd].ev |= e & (EPOLLIN|EPOLLOUT|EPOLLPRI|EPOLLERR|EPOLLHUP);
|
||||||
((e & EPOLLERR) ? FD_POLL_ERR : 0) |
|
}
|
||||||
((e & EPOLLHUP) ? FD_POLL_HUP : 0);
|
else {
|
||||||
|
fdtab[fd].ev |=
|
||||||
|
((e & EPOLLIN ) ? FD_POLL_IN : 0) |
|
||||||
|
((e & EPOLLPRI) ? FD_POLL_PRI : 0) |
|
||||||
|
((e & EPOLLOUT) ? FD_POLL_OUT : 0) |
|
||||||
|
((e & EPOLLERR) ? FD_POLL_ERR : 0) |
|
||||||
|
((e & EPOLLHUP) ? FD_POLL_HUP : 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev) {
|
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev) {
|
||||||
int new_updt, old_updt = fd_nbupdt; /* Save number of updates to detect creation of new FDs. */
|
int new_updt, old_updt = fd_nbupdt; /* Save number of updates to detect creation of new FDs. */
|
||||||
|
@ -154,12 +154,21 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
|
|||||||
if (!fdtab[fd].owner)
|
if (!fdtab[fd].owner)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* it looks complicated but gcc can optimize it away when constants
|
||||||
|
* have same values... In fact it depends on gcc :-(
|
||||||
|
*/
|
||||||
fdtab[fd].ev &= FD_POLL_STICKY;
|
fdtab[fd].ev &= FD_POLL_STICKY;
|
||||||
fdtab[fd].ev |=
|
if (POLLIN == FD_POLL_IN && POLLOUT == FD_POLL_OUT &&
|
||||||
((e & POLLIN ) ? FD_POLL_IN : 0) |
|
POLLERR == FD_POLL_ERR && POLLHUP == FD_POLL_HUP) {
|
||||||
((e & POLLOUT) ? FD_POLL_OUT : 0) |
|
fdtab[fd].ev |= e & (POLLIN|POLLOUT|POLLERR|POLLHUP);
|
||||||
((e & POLLERR) ? FD_POLL_ERR : 0) |
|
}
|
||||||
((e & POLLHUP) ? FD_POLL_HUP : 0);
|
else {
|
||||||
|
fdtab[fd].ev |=
|
||||||
|
((e & POLLIN ) ? FD_POLL_IN : 0) |
|
||||||
|
((e & POLLOUT) ? FD_POLL_OUT : 0) |
|
||||||
|
((e & POLLERR) ? FD_POLL_ERR : 0) |
|
||||||
|
((e & POLLHUP) ? FD_POLL_HUP : 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev) {
|
if (fdtab[fd].iocb && fdtab[fd].owner && fdtab[fd].ev) {
|
||||||
/* Mark the events as speculative before processing
|
/* Mark the events as speculative before processing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user