VirtualBox

Changeset 15221 in vbox for trunk/src/VBox/Devices/Network


Ignore:
Timestamp:
Dec 10, 2008 3:12:28 AM (16 years ago)
Author:
vboxsync
Message:

slirp: even more readability

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/slirp.c

    r15220 r15221  
    2828
    2929# define DO_POLL_EVENTS(rc, error, so, events, label) do {} while (0)
     30
     31#define DO_CHECK_FD_SET(so, events, fdset) (FD_ISSET((so)->s, (fdset)))
    3032
    3133# ifdef VBOX_WITH_SLIRP_ICMP
     
    7173    }
    7274
     75# define readfds_win FD_READ
     76# define readfds_win_bit FD_READ_BIT
     77
     78# define writefds_win FD_WRITE
     79# define writefds_win_bit FD_WRITE_BIT
     80
     81# define xfds_win FD_OOB
     82# define xfds_win_bit FD_OOB_BIT
     83
     84# define DO_CHECK_FD_SET(so, events, fdset)  \
     85    (((events).lNetworkEvents & fdset ## _win) && ((event).iErrorCode[fdset ## _win_bit] == 0))
     86
     87
    7388#endif /* defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) && defined(RT_OS_WINDOWS) */
    7489
     
    87102#define POLL_UDP_EVENTS(rc, error, so, events) \
    88103    DO_POLL_EVENTS((rc), (error), (so), (events), UDP)
     104
     105#define CHECK_FD_SET(so, events, set)           \
     106    (DO_CHECK_FD_SET((so), (events), set))
    89107
    90108static const uint8_t special_ethaddr[6] =
     
    711729             * test for readfds below if this succeeds
    712730             */
    713 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
    714             if (FD_ISSET(so->s, xfds))
    715 #else
     731
    716732            /* out-of-band data */
    717             if ((NetworkEvents.lNetworkEvents & FD_OOB) && NetworkEvents.iErrorCode[FD_OOB_BIT] == 0)
    718 #endif
     733            if (CHECK_FD_SET(so, NetworkEvents, xfds))
    719734            {
    720735                sorecvoob(pData, so);
     
    724739             * Check sockets for reading
    725740             */
    726 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
    727             else if (FD_ISSET(so->s, readfds))
    728 #else
    729             else if ((NetworkEvents.lNetworkEvents & FD_READ) && (NetworkEvents.iErrorCode[FD_READ_BIT] == 0))
    730 #endif
     741            else if (CHECK_FD_SET(so, NetworkEvents, readfds))
    731742            {
    732743                /*
     
    771782             * Check sockets for writing
    772783             */
    773 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
    774             if (FD_ISSET(so->s, writefds))
    775 #else
    776             if ((NetworkEvents.lNetworkEvents & FD_WRITE) && (NetworkEvents.iErrorCode[FD_WRITE_BIT] == 0))
    777 #endif
     784            if (CHECK_FD_SET(so, NetworkEvents, writefds))
    778785            {
    779786                /*
     
    884891            POLL_UDP_EVENTS(rc, error, so, NetworkEvents);
    885892
    886 #if !defined(VBOX_WITH_SIMPLIFIED_SLIRP_SYNC) || !defined(RT_OS_WINDOWS)
    887             if (so->s != -1 && FD_ISSET(so->s, readfds))
    888 #else
    889             if (((NetworkEvents.lNetworkEvents & FD_READ) && (NetworkEvents.iErrorCode[FD_READ_BIT] == 0)))
    890 #endif
     893            if (so->s != -1 && CHECK_FD_SET(so, NetworkEvents, readfds))
    891894            {
    892895                sorecvfrom(pData, so);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette