@@ -470,6 +470,7 @@ struct GAIOptions {
470470 flags : i32 ,
471471}
472472
473+ #[ cfg( not( target_os = "redox" ) ) ]
473474fn socket_getaddrinfo ( opts : GAIOptions , vm : & VirtualMachine ) -> PyResult {
474475 let hints = dns_lookup:: AddrInfoHints {
475476 socktype : opts. ty ,
@@ -512,6 +513,7 @@ fn socket_getaddrinfo(opts: GAIOptions, vm: &VirtualMachine) -> PyResult {
512513 Ok ( vm. ctx . new_list ( list) )
513514}
514515
516+ #[ cfg( not( target_os = "redox" ) ) ]
515517fn socket_gethostbyaddr (
516518 addr : PyStringRef ,
517519 vm : & VirtualMachine ,
@@ -609,9 +611,20 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
609611 let socket_gaierror = ctx. new_class ( "socket.gaierror" , vm. ctx . exceptions . os_error . clone ( ) ) ;
610612
611613 let module = py_module ! ( vm, "_socket" , {
614+ "socket" => PySocket :: make_class( ctx) ,
612615 "error" => ctx. exceptions. os_error. clone( ) ,
613616 "timeout" => socket_timeout,
614617 "gaierror" => socket_gaierror,
618+ "inet_aton" => ctx. new_function( socket_inet_aton) ,
619+ "inet_ntoa" => ctx. new_function( socket_inet_ntoa) ,
620+ "gethostname" => ctx. new_function( socket_gethostname) ,
621+ "htonl" => ctx. new_function( socket_hton:: <u32 >) ,
622+ "htons" => ctx. new_function( socket_hton:: <u16 >) ,
623+ "ntohl" => ctx. new_function( socket_ntoh:: <u32 >) ,
624+ "ntohs" => ctx. new_function( socket_ntoh:: <u16 >) ,
625+ "getdefaulttimeout" => ctx. new_function( |vm: & VirtualMachine | vm. get_none( ) ) ,
626+ "has_ipv6" => ctx. new_bool( false ) ,
627+ // constants
615628 "AF_UNSPEC" => ctx. new_int( 0 ) ,
616629 "AF_INET" => ctx. new_int( c:: AF_INET ) ,
617630 "AF_INET6" => ctx. new_int( c:: AF_INET6 ) ,
@@ -620,33 +633,28 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
620633 "SHUT_RD" => ctx. new_int( c:: SHUT_RD ) ,
621634 "SHUT_WR" => ctx. new_int( c:: SHUT_WR ) ,
622635 "SHUT_RDWR" => ctx. new_int( c:: SHUT_RDWR ) ,
623- "MSG_OOB" => ctx. new_int( c:: MSG_OOB ) ,
624636 "MSG_PEEK" => ctx. new_int( c:: MSG_PEEK ) ,
625- "MSG_WAITALL" => ctx. new_int( c:: MSG_WAITALL ) ,
626- "AI_ALL" => ctx. new_int( c:: AI_ALL ) ,
627- "AI_PASSIVE" => ctx. new_int( c:: AI_PASSIVE ) ,
628637 "IPPROTO_TCP" => ctx. new_int( c:: IPPROTO_TCP ) ,
629638 "IPPROTO_UDP" => ctx. new_int( c:: IPPROTO_UDP ) ,
630639 "IPPROTO_IP" => ctx. new_int( c:: IPPROTO_IP ) ,
631640 "IPPROTO_IPIP" => ctx. new_int( c:: IPPROTO_IP ) ,
632641 "IPPROTO_IPV6" => ctx. new_int( c:: IPPROTO_IPV6 ) ,
633- "IPPROTO_NONE" => ctx. new_int( c:: IPPROTO_NONE ) ,
634642 "SOL_SOCKET" => ctx. new_int( c:: SOL_SOCKET ) ,
635643 "SO_REUSEADDR" => ctx. new_int( c:: SO_REUSEADDR ) ,
636644 "TCP_NODELAY" => ctx. new_int( c:: TCP_NODELAY ) ,
637645 "SO_BROADCAST" => ctx. new_int( c:: SO_BROADCAST ) ,
638- "socket" => PySocket :: make_class( ctx) ,
639- "inet_aton" => ctx. new_function( socket_inet_aton) ,
640- "inet_ntoa" => ctx. new_function( socket_inet_ntoa) ,
641- "gethostname" => ctx. new_function( socket_gethostname) ,
642- "htonl" => ctx. new_function( socket_hton:: <u32 >) ,
643- "htons" => ctx. new_function( socket_hton:: <u16 >) ,
644- "ntohl" => ctx. new_function( socket_ntoh:: <u32 >) ,
645- "ntohs" => ctx. new_function( socket_ntoh:: <u16 >) ,
646- "has_ipv6" => ctx. new_bool( false ) ,
647- "getdefaulttimeout" => ctx. new_function( |vm: & VirtualMachine | vm. get_none( ) ) ,
646+ } ) ;
647+
648+ #[ cfg( not( target_os = "redox" ) ) ]
649+ extend_module ! ( vm, module, {
648650 "getaddrinfo" => ctx. new_function( socket_getaddrinfo) ,
649651 "gethostbyaddr" => ctx. new_function( socket_gethostbyaddr) ,
652+ // non-redox constants
653+ "MSG_OOB" => ctx. new_int( c:: MSG_OOB ) ,
654+ "MSG_WAITALL" => ctx. new_int( c:: MSG_WAITALL ) ,
655+ "AI_ALL" => ctx. new_int( c:: AI_ALL ) ,
656+ "AI_PASSIVE" => ctx. new_int( c:: AI_PASSIVE ) ,
657+ "IPPROTO_NONE" => ctx. new_int( c:: IPPROTO_NONE ) ,
650658 } ) ;
651659
652660 extend_module_platform_specific ( vm, & module) ;
0 commit comments