+
+int _wapi_select(int nfds G_GNUC_UNUSED, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+ int ret;
+
+ if (startup_count == 0) {
+ WSASetLastError (WSANOTINITIALISED);
+ return(SOCKET_ERROR);
+ }
+
+ do {
+ ret = select(getdtablesize (), readfds, writefds, exceptfds,
+ timeout);
+ } while (ret == -1 && errno == EINTR &&
+ !_wapi_thread_cur_apc_pending ());
+
+ if (ret == -1) {
+ gint errnum = errno;
+#ifdef DEBUG
+ g_message ("%s: select error: %s", __func__, strerror (errno));
+#endif
+ errnum = errno_to_WSA (errnum, __func__);
+ WSASetLastError (errnum);
+
+ return(SOCKET_ERROR);
+ }
+
+ return(ret);
+}
+
+void _wapi_FD_CLR(guint32 fd, fd_set *set)
+{
+ gpointer handle = GUINT_TO_POINTER (fd);
+
+ if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
+ WSASetLastError (WSAENOTSOCK);
+ return;
+ }
+
+ FD_CLR (fd, set);
+}
+
+int _wapi_FD_ISSET(guint32 fd, fd_set *set)
+{
+ gpointer handle = GUINT_TO_POINTER (fd);
+
+ if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
+ WSASetLastError (WSAENOTSOCK);
+ return(0);
+ }
+
+ return(FD_ISSET (fd, set));
+}
+
+void _wapi_FD_SET(guint32 fd, fd_set *set)
+{
+ gpointer handle = GUINT_TO_POINTER (fd);
+
+ if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
+ WSASetLastError (WSAENOTSOCK);
+ return;
+ }
+
+ FD_SET (fd, set);
+}
+