<s> from pypy . rpython . lltypesystem import rffi <EOL> from pypy . rpython . lltypesystem import lltype <EOL> from pypy . rpython . tool import rffi_platform as platform <EOL> from pypy . rpython . lltypesystem . rffi import CCHARP <EOL> from pypy . rlib . rposix import get_errno as geterrno <EOL> from pypy . translator . tool . cbuild import ExternalCompilationInfo <EOL> from pypy . translator . platform import platform as target_platform <EOL> from pypy . rlib . rarithmetic import intmask , r_uint <EOL> import os , sys <EOL> _POSIX = os . name == "<STR_LIT>" <EOL> _WIN32 = sys . platform == "<STR_LIT:win32>" <EOL> _MSVC = target_platform . name == "<STR_LIT>" <EOL> _MINGW = target_platform . name == "<STR_LIT>" <EOL> _SOLARIS = sys . platform == "<STR_LIT>" <EOL> if _POSIX : <EOL> includes = ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> cond_includes = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> libraries = ( ) <EOL> calling_conv = '<STR_LIT:c>' <EOL> HEADER = '<STR_LIT>' . join ( [ '<STR_LIT>' % filename for filename in includes ] ) <EOL> COND_HEADER = '<STR_LIT>' . join ( [ '<STR_LIT>' % cond_include <EOL> for cond_include in cond_includes ] ) <EOL> if _SOLARIS : <EOL> libraries = libraries + ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if _WIN32 : <EOL> includes = ( ) <EOL> libraries = ( '<STR_LIT>' , ) <EOL> calling_conv = '<STR_LIT>' <EOL> header_lines = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> if _MSVC : <EOL> header_lines . extend ( [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> else : <EOL> includes = ( '<STR_LIT>' , ) <EOL> HEADER = '<STR_LIT:\n>' . join ( header_lines ) <EOL> COND_HEADER = '<STR_LIT>' <EOL> constants = { } <EOL> sources = [ """<STR_LIT>""" ] <EOL> eci = ExternalCompilationInfo ( <EOL> post_include_bits = [ HEADER , COND_HEADER ] , <EOL> includes = includes , <EOL> libraries = libraries , <EOL> separate_module_sources = sources , <EOL> export_symbols = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] , <EOL> ) <EOL> class CConfig : <EOL> _compilation_info_ = eci <EOL> linux = platform . Defined ( '<STR_LIT>' ) <EOL> WIN32 = platform . Defined ( '<STR_LIT>' ) <EOL> O_NONBLOCK = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> F_GETFL = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> F_SETFL = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> FIONBIO = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> INVALID_SOCKET = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> INET_ADDRSTRLEN = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> INET6_ADDRSTRLEN = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> EINPROGRESS = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> WSAEINPROGRESS = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> EWOULDBLOCK = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> WSAEWOULDBLOCK = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> EAFNOSUPPORT = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> WSAEAFNOSUPPORT = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> EISCONN = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> WSAEISCONN = platform . DefinedConstantInteger ( '<STR_LIT>' ) <EOL> constant_names = '''<STR_LIT>''' . split ( ) <EOL> for name in constant_names : <EOL> setattr ( CConfig , name , platform . DefinedConstantInteger ( name ) ) <EOL> constants [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> constants [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> constants_w_defaults = [ ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:6> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:5> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:6> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:6> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:255> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:0> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:1> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:2> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:4> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:8> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:16> ) , <EOL> ( '<STR_LIT>' , <NUM_LIT:64> ) , <EOL> ] <EOL> for name , default in constants_w_defaults : <EOL> setattr ( CConfig , name , platform . DefinedConstantInteger ( name ) ) <EOL> if _MSVC : <EOL> socketfd_type = rffi . UINT <EOL> else : <EOL> socketfd_type = rffi . INT <EOL> CConfig . uint16_t = platform . SimpleType ( '<STR_LIT>' , rffi . USHORT ) <EOL> CConfig . uint32_t = platform . SimpleType ( '<STR_LIT>' , rffi . UINT ) <EOL> CConfig . size_t = platform . SimpleType ( '<STR_LIT>' , rffi . INT ) <EOL> CConfig . ssize_t = platform . SimpleType ( '<STR_LIT>' , rffi . INT ) <EOL> CConfig . socklen_t = platform . SimpleType ( '<STR_LIT>' , rffi . INT ) <EOL> sockaddr_ptr = lltype . Ptr ( lltype . ForwardReference ( ) ) <EOL> addrinfo_ptr = lltype . Ptr ( lltype . ForwardReference ( ) ) <EOL> CConfig . sockaddr = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . CFixedArray ( rffi . CHAR , <NUM_LIT:1> ) ) ] ) <EOL> CConfig . in_addr = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . UINT ) ] ) <EOL> CConfig . in6_addr = platform . Struct ( '<STR_LIT>' , <EOL> [ ] ) <EOL> CConfig . sockaddr_in = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . USHORT ) , <EOL> ( '<STR_LIT>' , CConfig . in_addr ) ] ) <EOL> CConfig . sockaddr_in6 = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . USHORT ) , <EOL> ( '<STR_LIT>' , CConfig . in6_addr ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) ] ) <EOL> CConfig . sockaddr_un = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . CFixedArray ( rffi . CHAR , <NUM_LIT:1> ) ) ] , <EOL> ifdef = '<STR_LIT>' ) <EOL> CConfig . sockaddr_nl = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) ] , <EOL> ifdef = '<STR_LIT>' ) <EOL> CConfig . addrinfo = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , sockaddr_ptr ) , <EOL> ( '<STR_LIT>' , CCHARP ) , <EOL> ( '<STR_LIT>' , addrinfo_ptr ) ] ) <EOL> CConfig . hostent = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , CCHARP ) , <EOL> ( '<STR_LIT>' , rffi . CCHARPP ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , rffi . CCHARPP ) , <EOL> ] ) <EOL> CConfig . servent = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , CCHARP ) , <EOL> ( '<STR_LIT>' , rffi . INT ) , <EOL> ( '<STR_LIT>' , CCHARP ) , <EOL> ] ) <EOL> CConfig . protoent = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . INT ) , <EOL> ] ) <EOL> if _POSIX : <EOL> CConfig . nfds_t = platform . SimpleType ( '<STR_LIT>' ) <EOL> CConfig . pollfd = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , socketfd_type ) , <EOL> ( '<STR_LIT>' , rffi . SHORT ) , <EOL> ( '<STR_LIT>' , rffi . SHORT ) ] ) <EOL> if _WIN32 : <EOL> CConfig . WSAEVENT = platform . SimpleType ( '<STR_LIT>' , rffi . VOIDP ) <EOL> CConfig . WSANETWORKEVENTS = platform . Struct ( <EOL> '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . LONG ) , <EOL> ( '<STR_LIT>' , rffi . CFixedArray ( rffi . INT , <NUM_LIT:10> ) ) , <EOL> ] ) <EOL> CConfig . timeval = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . LONG ) , <EOL> ( '<STR_LIT>' , rffi . LONG ) ] ) <EOL> fd_set = rffi . COpaquePtr ( '<STR_LIT>' , compilation_info = eci ) <EOL> if _WIN32 : <EOL> CConfig . WSAData = platform . Struct ( '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , rffi . USHORT ) , <EOL> ( '<STR_LIT>' , rffi . USHORT ) , <EOL> ( '<STR_LIT>' , rffi . CFixedArray ( lltype . Char , <NUM_LIT:1> ) ) , <EOL> ( '<STR_LIT>' , rffi . CFixedArray ( lltype . Char , <NUM_LIT:1> ) ) , <EOL> ( '<STR_LIT>' , rffi . USHORT ) , <EOL> ( '<STR_LIT>' , rffi . USHORT ) , <EOL> ( '<STR_LIT>' , CCHARP ) ] ) <EOL> class cConfig : <EOL> pass <EOL> cConfig . __dict__ . update ( platform . configure ( CConfig ) ) <EOL> sockaddr_ptr . TO . become ( cConfig . sockaddr ) <EOL> addrinfo_ptr . TO . become ( cConfig . addrinfo ) <EOL> cConfig . NI_MAXHOST = cConfig . NI_MAXHOST or <NUM_LIT> <EOL> cConfig . NI_MAXSERV = cConfig . NI_MAXSERV or <NUM_LIT:32> <EOL> cConfig . INET_ADDRSTRLEN = cConfig . INET_ADDRSTRLEN or <NUM_LIT:16> <EOL> for name in constant_names : <EOL> value = getattr ( cConfig , name ) <EOL> if value is not None : <EOL> constants [ name ] = value <EOL> for name , default in constants_w_defaults : <EOL> value = getattr ( cConfig , name ) <EOL> if value is not None : <EOL> constants [ name ] = value <EOL> else : <EOL> constants [ name ] = default <EOL> constants [ '<STR_LIT>' ] = True <EOL> for name , value in constants . items ( ) : <EOL> if isinstance ( value , long ) : <EOL> if r_uint ( value ) == value : <EOL> constants [ name ] = intmask ( value ) <EOL> locals ( ) . update ( constants ) <EOL> O_NONBLOCK = cConfig . O_NONBLOCK <EOL> F_GETFL = cConfig . F_GETFL <EOL> F_SETFL = cConfig . F_SETFL <EOL> FIONBIO = cConfig . FIONBIO <EOL> INET_ADDRSTRLEN = cConfig . INET_ADDRSTRLEN <EOL> INET6_ADDRSTRLEN = cConfig . INET6_ADDRSTRLEN <EOL> EINPROGRESS = cConfig . EINPROGRESS or cConfig . WSAEINPROGRESS <EOL> EWOULDBLOCK = cConfig . EWOULDBLOCK or cConfig . WSAEWOULDBLOCK <EOL> EAFNOSUPPORT = cConfig . EAFNOSUPPORT or cConfig . WSAEAFNOSUPPORT <EOL> EISCONN = cConfig . EISCONN or cConfig . WSAEISCONN <EOL> linux = cConfig . linux <EOL> WIN32 = cConfig . WIN32 <EOL> assert WIN32 == _WIN32 <EOL> if WIN32 : <EOL> def invalid_socket ( fd ) : <EOL> return fd == INVALID_SOCKET <EOL> INVALID_SOCKET = cConfig . INVALID_SOCKET <EOL> else : <EOL> def invalid_socket ( fd ) : <EOL> return fd < <NUM_LIT:0> <EOL> INVALID_SOCKET = - <NUM_LIT:1> <EOL> uint16_t = cConfig . uint16_t <EOL> uint32_t = cConfig . uint32_t <EOL> size_t = cConfig . size_t <EOL> ssize_t = cConfig . ssize_t <EOL> socklen_t = cConfig . socklen_t <EOL> sockaddr = cConfig . sockaddr <EOL> sockaddr_in = cConfig . sockaddr_in <EOL> sockaddr_in6 = cConfig . sockaddr_in6 <EOL> sockaddr_un = cConfig . sockaddr_un <EOL> if cConfig . sockaddr_nl is not None : <EOL> sockaddr_nl = cConfig . sockaddr_nl <EOL> in_addr = cConfig . in_addr <EOL> in6_addr = cConfig . in6_addr <EOL> addrinfo = cConfig . addrinfo <EOL> if _POSIX : <EOL> nfds_t = cConfig . nfds_t <EOL> pollfd = cConfig . pollfd <EOL> if WIN32 : <EOL> WSAEVENT = cConfig . WSAEVENT <EOL> WSANETWORKEVENTS = cConfig . WSANETWORKEVENTS <EOL> timeval = cConfig . timeval <EOL> def external ( name , args , result ) : <EOL> return rffi . llexternal ( name , args , result , compilation_info = eci , <EOL> calling_conv = calling_conv ) <EOL> def external_c ( name , args , result ) : <EOL> return rffi . llexternal ( name , args , result , compilation_info = eci , <EOL> calling_conv = '<STR_LIT:c>' ) <EOL> if _POSIX : <EOL> dup = external ( '<STR_LIT>' , [ socketfd_type ] , socketfd_type ) <EOL> gai_strerror = external ( '<STR_LIT>' , [ rffi . INT ] , CCHARP ) <EOL> socket = external ( '<STR_LIT>' , [ rffi . INT , rffi . INT , rffi . INT ] , socketfd_type ) <EOL> if WIN32 : <EOL> socketclose = external ( '<STR_LIT>' , [ socketfd_type ] , rffi . INT ) <EOL> else : <EOL> socketclose = external ( '<STR_LIT>' , [ socketfd_type ] , rffi . INT ) <EOL> socketconnect = external ( '<STR_LIT>' , [ socketfd_type , sockaddr_ptr , socklen_t ] , rffi . INT ) <EOL> if not WIN32 : <EOL> getaddrinfo = external ( '<STR_LIT>' , [ CCHARP , CCHARP , <EOL> addrinfo_ptr , <EOL> lltype . Ptr ( rffi . CArray ( addrinfo_ptr ) ) ] , rffi . INT ) <EOL> freeaddrinfo = external ( '<STR_LIT>' , [ addrinfo_ptr ] , lltype . Void ) <EOL> getnameinfo = external ( '<STR_LIT>' , [ sockaddr_ptr , socklen_t , CCHARP , <EOL> size_t , CCHARP , size_t , rffi . INT ] , rffi . INT ) <EOL> htonl = external ( '<STR_LIT>' , [ rffi . UINT ] , rffi . UINT ) <EOL> htons = external ( '<STR_LIT>' , [ rffi . USHORT ] , rffi . USHORT ) <EOL> ntohl = external ( '<STR_LIT>' , [ rffi . UINT ] , rffi . UINT ) <EOL> ntohs = external ( '<STR_LIT>' , [ rffi . USHORT ] , rffi . USHORT ) <EOL> if _POSIX : <EOL> inet_aton = external ( '<STR_LIT>' , [ CCHARP , lltype . Ptr ( in_addr ) ] , <EOL> rffi . INT ) <EOL> inet_ntoa = external ( '<STR_LIT>' , [ in_addr ] , rffi . CCHARP ) <EOL> if _POSIX : <EOL> inet_pton = external ( '<STR_LIT>' , [ rffi . INT , rffi . CCHARP , <EOL> rffi . VOIDP ] , rffi . INT ) <EOL> inet_ntop = external ( '<STR_LIT>' , [ rffi . INT , rffi . VOIDP , CCHARP , <EOL> socklen_t ] , CCHARP ) <EOL> inet_addr = external ( '<STR_LIT>' , [ rffi . CCHARP ] , rffi . UINT ) <EOL> socklen_t_ptr = lltype . Ptr ( rffi . CFixedArray ( socklen_t , <NUM_LIT:1> ) ) <EOL> socketaccept = external ( '<STR_LIT>' , [ socketfd_type , sockaddr_ptr , <EOL> socklen_t_ptr ] , socketfd_type ) <EOL> socketbind = external ( '<STR_LIT>' , [ socketfd_type , sockaddr_ptr , socklen_t ] , <EOL> rffi . INT ) <EOL> socketlisten = external ( '<STR_LIT>' , [ socketfd_type , rffi . INT ] , rffi . INT ) <EOL> socketgetpeername = external ( '<STR_LIT>' , [ socketfd_type , <EOL> sockaddr_ptr , socklen_t_ptr ] , rffi . INT ) <EOL> socketgetsockname = external ( '<STR_LIT>' , [ socketfd_type , <EOL> sockaddr_ptr , socklen_t_ptr ] , rffi . INT ) <EOL> socketgetsockopt = external ( '<STR_LIT>' , [ socketfd_type , rffi . INT , <EOL> rffi . INT , rffi . VOIDP , socklen_t_ptr ] , rffi . INT ) <EOL> socketsetsockopt = external ( '<STR_LIT>' , [ socketfd_type , rffi . INT , <EOL> rffi . INT , rffi . VOIDP , socklen_t ] , rffi . INT ) <EOL> socketrecv = external ( '<STR_LIT>' , [ socketfd_type , rffi . VOIDP , rffi . INT , <EOL> rffi . INT ] , ssize_t ) <EOL> recvfrom = external ( '<STR_LIT>' , [ socketfd_type , rffi . VOIDP , size_t , <EOL> rffi . INT , sockaddr_ptr , socklen_t_ptr ] , rffi . INT ) <EOL> send = external ( '<STR_LIT>' , [ socketfd_type , rffi . CCHARP , size_t , rffi . INT ] , <EOL> ssize_t ) <EOL> sendto = external ( '<STR_LIT>' , [ socketfd_type , rffi . VOIDP , size_t , rffi . INT , <EOL> sockaddr_ptr , socklen_t ] , ssize_t ) <EOL> socketshutdown = external ( '<STR_LIT>' , [ socketfd_type , rffi . INT ] , rffi . INT ) <EOL> gethostname = external ( '<STR_LIT>' , [ rffi . CCHARP , rffi . INT ] , rffi . INT ) <EOL> gethostbyname = external ( '<STR_LIT>' , [ rffi . CCHARP ] , <EOL> lltype . Ptr ( cConfig . hostent ) ) <EOL> gethostbyaddr = external ( '<STR_LIT>' , [ rffi . VOIDP , rffi . INT , rffi . INT ] , lltype . Ptr ( cConfig . hostent ) ) <EOL> getservbyname = external ( '<STR_LIT>' , [ rffi . CCHARP , rffi . CCHARP ] , lltype . Ptr ( cConfig . servent ) ) <EOL> getservbyport = external ( '<STR_LIT>' , [ rffi . INT , rffi . CCHARP ] , lltype . Ptr ( cConfig . servent ) ) <EOL> getprotobyname = external ( '<STR_LIT>' , [ rffi . CCHARP ] , lltype . Ptr ( cConfig . protoent ) ) <EOL> if _POSIX : <EOL> fcntl = external ( '<STR_LIT>' , [ socketfd_type , rffi . INT , rffi . INT ] , rffi . INT ) <EOL> socketpair_t = rffi . CArray ( socketfd_type ) <EOL> socketpair = external ( '<STR_LIT>' , [ rffi . INT , rffi . INT , rffi . INT , <EOL> lltype . Ptr ( socketpair_t ) ] , rffi . INT ) <EOL> if _WIN32 : <EOL> ioctlsocket = external ( '<STR_LIT>' , <EOL> [ socketfd_type , rffi . LONG , rffi . ULONGP ] , <EOL> rffi . INT ) <EOL> select = external ( '<STR_LIT>' , <EOL> [ rffi . INT , fd_set , fd_set , <EOL> fd_set , lltype . Ptr ( timeval ) ] , <EOL> rffi . INT ) <EOL> FD_CLR = external_c ( '<STR_LIT>' , [ rffi . INT , fd_set ] , lltype . Void ) <EOL> FD_ISSET = external_c ( '<STR_LIT>' , [ rffi . INT , fd_set ] , rffi . INT ) <EOL> FD_SET = external_c ( '<STR_LIT>' , [ rffi . INT , fd_set ] , lltype . Void ) <EOL> FD_ZERO = external_c ( '<STR_LIT>' , [ fd_set ] , lltype . Void ) <EOL> if _POSIX : <EOL> pollfdarray = rffi . CArray ( pollfd ) <EOL> poll = external ( '<STR_LIT>' , [ lltype . Ptr ( pollfdarray ) , nfds_t , rffi . INT ] , <EOL> rffi . INT ) <EOL> elif WIN32 : <EOL> WSAEVENT_ARRAY = rffi . CArray ( WSAEVENT ) <EOL> WSACreateEvent = external ( '<STR_LIT>' , [ ] , WSAEVENT ) <EOL> WSACloseEvent = external ( '<STR_LIT>' , [ WSAEVENT ] , rffi . INT ) <EOL> WSAEventSelect = external ( '<STR_LIT>' , <EOL> [ socketfd_type , WSAEVENT , rffi . LONG ] , <EOL> rffi . INT ) <EOL> WSAWaitForMultipleEvents = external ( '<STR_LIT>' , <EOL> [ rffi . LONG , lltype . Ptr ( WSAEVENT_ARRAY ) , <EOL> rffi . INT , rffi . LONG , rffi . INT ] , <EOL> rffi . ULONG ) <EOL> WSAEnumNetworkEvents = external ( '<STR_LIT>' , <EOL> [ socketfd_type , WSAEVENT , <EOL> lltype . Ptr ( WSANETWORKEVENTS ) ] , <EOL> rffi . INT ) <EOL> if WIN32 : <EOL> WSAData = cConfig . WSAData <EOL> WSAStartup = external ( '<STR_LIT>' , [ rffi . INT , lltype . Ptr ( WSAData ) ] , <EOL> rffi . INT ) <EOL> WSAGetLastError = external ( '<STR_LIT>' , [ ] , rffi . INT ) <EOL> geterrno = WSAGetLastError <EOL> import errno <EOL> WIN32_ERROR_MESSAGES = { <EOL> errno . WSAEINTR : "<STR_LIT>" , <EOL> errno . WSAEBADF : "<STR_LIT>" , <EOL> errno . WSAEACCES : "<STR_LIT>" , <EOL> errno . WSAEFAULT : "<STR_LIT>" , <EOL> errno . WSAEINVAL : "<STR_LIT>" , <EOL> errno . WSAEMFILE : "<STR_LIT>" , <EOL> errno . WSAEWOULDBLOCK : <EOL> "<STR_LIT>" , <EOL> errno . WSAEINPROGRESS : "<STR_LIT>" , <EOL> errno . WSAEALREADY : "<STR_LIT>" , <EOL> errno . WSAENOTSOCK : "<STR_LIT>" , <EOL> errno . WSAEDESTADDRREQ : "<STR_LIT>" , <EOL> errno . WSAEMSGSIZE : "<STR_LIT>" , <EOL> errno . WSAEPROTOTYPE : "<STR_LIT>" , <EOL> errno . WSAENOPROTOOPT : "<STR_LIT>" , <EOL> errno . WSAEPROTONOSUPPORT : "<STR_LIT>" , <EOL> errno . WSAESOCKTNOSUPPORT : "<STR_LIT>" , <EOL> errno . WSAEOPNOTSUPP : "<STR_LIT>" , <EOL> errno . WSAEPFNOSUPPORT : "<STR_LIT>" , <EOL> errno . WSAEAFNOSUPPORT : "<STR_LIT>" , <EOL> errno . WSAEADDRINUSE : "<STR_LIT>" , <EOL> errno . WSAEADDRNOTAVAIL : "<STR_LIT>" , <EOL> errno . WSAENETDOWN : "<STR_LIT>" , <EOL> errno . WSAENETUNREACH : "<STR_LIT>" , <EOL> errno . WSAENETRESET : "<STR_LIT>" , <EOL> errno . WSAECONNABORTED : "<STR_LIT>" , <EOL> errno . WSAECONNRESET : "<STR_LIT>" , <EOL> errno . WSAENOBUFS : "<STR_LIT>" , <EOL> errno . WSAEISCONN : "<STR_LIT>" , <EOL> errno . WSAENOTCONN : "<STR_LIT>" , <EOL> errno . WSAESHUTDOWN : "<STR_LIT>" , <EOL> errno . WSAETOOMANYREFS : "<STR_LIT>" , <EOL> errno . WSAETIMEDOUT : "<STR_LIT>" , <EOL> errno . WSAECONNREFUSED : "<STR_LIT>" , <EOL> errno . WSAELOOP : "<STR_LIT>" , <EOL> errno . WSAENAMETOOLONG : "<STR_LIT>" , <EOL> errno . WSAEHOSTDOWN : "<STR_LIT>" , <EOL> errno . WSAEHOSTUNREACH : "<STR_LIT>" , <EOL> errno . WSAENOTEMPTY : "<STR_LIT>" , <EOL> errno . WSAEPROCLIM : "<STR_LIT>" , <EOL> errno . WSAEUSERS : "<STR_LIT>" , <EOL> errno . WSAEDQUOT : "<STR_LIT>" , <EOL> errno . WSAESTALE : "<STR_LIT>" , <EOL> errno . WSAEREMOTE : "<STR_LIT>" , <EOL> errno . WSASYSNOTREADY : "<STR_LIT>" , <EOL> errno . WSAVERNOTSUPPORTED : "<STR_LIT>" , <EOL> errno . WSANOTINITIALISED : "<STR_LIT>" , <EOL> errno . WSAEDISCON : "<STR_LIT>" , <EOL> WSA_IO_PENDING : "<STR_LIT>" , <EOL> WSA_IO_INCOMPLETE : "<STR_LIT>" , <EOL> WSA_INVALID_HANDLE : "<STR_LIT>" , <EOL> WSA_INVALID_PARAMETER : "<STR_LIT>" , <EOL> WSA_NOT_ENOUGH_MEMORY : "<STR_LIT>" , <EOL> WSA_OPERATION_ABORTED : "<STR_LIT>" , <EOL> } <EOL> assert len ( WIN32_ERROR_MESSAGES ) == <NUM_LIT> <EOL> def socket_strerror_str ( errno ) : <EOL> return WIN32_ERROR_MESSAGES . get ( errno , "<STR_LIT>" % errno ) <EOL> else : <EOL> socket_strerror_str = os . strerror </s>
