diff options
Diffstat (limited to 'win32/include/sys/socket.h')
-rw-r--r-- | win32/include/sys/socket.h | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/win32/include/sys/socket.h b/win32/include/sys/socket.h index 487f9d5877..c6d0123143 100644 --- a/win32/include/sys/socket.h +++ b/win32/include/sys/socket.h @@ -44,6 +44,41 @@ typedef struct _OVERLAPPED { #define ENOTSOCK WSAENOTSOCK #undef HOST_NOT_FOUND +#ifdef USE_SOCKETS_AS_HANDLES + +#ifndef PERL_FD_SETSIZE +#define PERL_FD_SETSIZE 64 +#endif + +#define PERL_BITS_PER_BYTE 8 +#define PERL_NFDBITS (sizeof(Perl_fd_mask)*PERL_BITS_PER_BYTE) + +typedef int Perl_fd_mask; + +typedef struct Perl_fd_set { + Perl_fd_mask bits[(PERL_FD_SETSIZE+PERL_NFDBITS-1)/PERL_NFDBITS]; +} Perl_fd_set; + +#define PERL_FD_CLR(n,p) \ + ((p)->bits[(n)/PERL_NFDBITS] &= ~((unsigned)1 << ((n)%PERL_NFDBITS))) + +#define PERL_FD_SET(n,p) \ + ((p)->bits[(n)/PERL_NFDBITS] |= ((unsigned)1 << ((n)%PERL_NFDBITS))) + +#define PERL_FD_ZERO(p) memset((char *)(p),0,sizeof(*(p))) + +#define PERL_FD_ISSET(n,p) \ + ((p)->bits[(n)/PERL_NFDBITS] & ((unsigned)1 << ((n)%PERL_NFDBITS))) + +#else /* USE_SOCKETS_AS_HANDLES */ + +#define Perl_fd_set fd_set +#define PERL_FD_SET(n,p) FD_SET(n,p) +#define PERL_FD_CLR(n,p) FD_CLR(n,p) +#define PERL_FD_ISSET(n,p) FD_ISSET(n,p) +#define PERL_FD_ZERO(p) FD_ZERO(p) + +#endif /* USE_SOCKETS_AS_HANDLES */ SOCKET win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen); int win32_bind (SOCKET s, const struct sockaddr *addr, int namelen); @@ -63,7 +98,8 @@ u_short win32_ntohs (u_short netshort); int win32_recv (SOCKET s, char * buf, int len, int flags); int win32_recvfrom (SOCKET s, char * buf, int len, int flags, struct sockaddr *from, int * fromlen); -int win32_select (int nfds, int *readfds, int *writefds, int *exceptfds, const struct timeval *timeout); +int win32_select (int nfds, Perl_fd_set *rfds, Perl_fd_set *wfds, Perl_fd_set *xfds, + const struct timeval *timeout); int win32_send (SOCKET s, const char * buf, int len, int flags); int win32_sendto (SOCKET s, const char * buf, int len, int flags, const struct sockaddr *to, int tolen); @@ -95,6 +131,7 @@ void win32_endnetent(void); void win32_endprotoent(void); void win32_endservent(void); +#ifndef WIN32SCK_IS_STDSCK // // direct to our version // @@ -143,6 +180,21 @@ void win32_endservent(void); #define setprotoent win32_setprotoent #define setservent win32_setservent +#ifdef USE_SOCKETS_AS_HANDLES +#undef fd_set +#undef FD_SET +#undef FD_CLR +#undef FD_ISSET +#undef FD_ZERO +#define fd_set Perl_fd_set +#define FD_SET(n,p) PERL_FD_SET(n,p) +#define FD_CLR(n,p) PERL_FD_CLR(n,p) +#define FD_ISSET(n,p) PERL_FD_ISSET(n,p) +#define FD_ZERO(p) PERL_FD_ZERO(p) +#endif /* USE_SOCKETS_AS_HANDLES */ + +#endif /* WIN32SCK_IS_STDSCK */ + #ifdef __cplusplus } #endif |