11#define LIBCGLUE_SYS_SOCKET_NO_ALIASES
12#define LIBCGLUE_ARPA_INET_NO_ALIASES
13#include <sys/socket.h>
25 fd_set ready_readfds, ready_writefds, ready_exceptfds;
26 fd_set iop_readfds, iop_writefds, iop_exceptfds;
28 if (_libcglue_fdman_socket_ops == NULL || _libcglue_fdman_socket_ops->select == NULL)
34 FD_ZERO(&ready_readfds);
35 FD_ZERO(&ready_writefds);
36 FD_ZERO(&ready_exceptfds);
38 FD_ZERO(&iop_readfds);
39 FD_ZERO(&iop_writefds);
40 FD_ZERO(&iop_exceptfds);
42 for (fd = 0; fd < n; fd += 1)
45 iop_fd = ps2sdk_get_iop_fd(fd);
51 if (readfds && FD_ISSET(fd, readfds))
53 FD_SET(iop_fd, &iop_readfds);
55 if (writefds && FD_ISSET(fd, writefds))
57 FD_SET(iop_fd, &iop_writefds);
59 if (exceptfds && FD_ISSET(fd, exceptfds))
61 FD_SET(iop_fd, &iop_exceptfds);
65 ret = _libcglue_fdman_socket_ops->select(n, &iop_readfds, &iop_writefds, &iop_exceptfds, timeout);
67 for (fd = 0; fd < n; fd += 1)
70 iop_fd = ps2sdk_get_iop_fd(fd);
71 if (FD_ISSET(iop_fd, &iop_readfds))
73 FD_SET(fd, &ready_readfds);
75 if (FD_ISSET(iop_fd, &iop_writefds))
77 FD_SET(fd, &ready_writefds);
79 if (FD_ISSET(iop_fd, &iop_exceptfds))
81 FD_SET(fd, &ready_exceptfds);
87 *readfds = ready_readfds;
91 *writefds = ready_writefds;
95 *exceptfds = ready_exceptfds;