@@ -40,10 +40,9 @@ cfg_if! {
40
40
41
41
use std:: time:: Duration ;
42
42
43
- #[ cfg( any( unix, target_os = "redox" , target_os = " wasi") ) ] use libc:: * ;
44
- #[ cfg( any( unix, target_os = "redox" ) ) ] use std:: os:: unix:: prelude:: * ;
43
+ #[ cfg( any( unix, target_os = "wasi" ) ) ] use libc:: * ;
44
+ #[ cfg( any( unix) ) ] use std:: os:: unix:: prelude:: * ;
45
45
#[ cfg( target_os = "wasi" ) ] use std:: os:: wasi:: prelude:: * ;
46
- #[ cfg( target_os = "redox" ) ] pub type Socket = usize ;
47
46
#[ cfg( unix) ] pub type Socket = c_int ;
48
47
#[ cfg( target_os = "wasi" ) ] pub type Socket = std:: os:: wasi:: io:: RawFd ;
49
48
#[ cfg( windows) ] pub type Socket = SOCKET ;
@@ -59,7 +58,7 @@ struct tcp_keepalive {
59
58
keepaliveinterval : c_ulong ,
60
59
}
61
60
62
- #[ cfg( any( unix, target_os = "redox" , target_os = " wasi") ) ] fn v ( opt : c_int ) -> c_int { opt }
61
+ #[ cfg( any( unix, target_os = "wasi" ) ) ] fn v ( opt : c_int ) -> c_int { opt }
63
62
#[ cfg( windows) ] fn v ( opt : IPPROTO ) -> c_int { opt as c_int }
64
63
65
64
#[ cfg( target_os = "wasi" ) ]
@@ -73,8 +72,6 @@ pub fn set_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int,
73
72
payload : T ) -> io:: Result < ( ) > {
74
73
unsafe {
75
74
let payload = & payload as * const T as * const c_void ;
76
- #[ cfg( target_os = "redox" ) ]
77
- let sock = sock as c_int ;
78
75
try!( :: cvt ( setsockopt ( sock, opt, val, payload as * const _ ,
79
76
mem:: size_of :: < T > ( ) as socklen_t ) ) ) ;
80
77
}
@@ -90,8 +87,6 @@ pub fn get_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int) -> io::Result<T> {
90
87
unsafe {
91
88
let mut slot: T = mem:: zeroed ( ) ;
92
89
let mut len = mem:: size_of :: < T > ( ) as socklen_t ;
93
- #[ cfg( target_os = "redox" ) ]
94
- let sock = sock as c_int ;
95
90
try!( :: cvt ( getsockopt ( sock, opt, val,
96
91
& mut slot as * mut _ as * mut _ ,
97
92
& mut len) ) ) ;
@@ -656,7 +651,7 @@ pub trait AsSock {
656
651
fn as_sock ( & self ) -> Socket ;
657
652
}
658
653
659
- #[ cfg( any( unix, target_os = "redox" , target_os = " wasi") ) ]
654
+ #[ cfg( any( unix, target_os = "wasi" ) ) ]
660
655
impl < T : AsRawFd > AsSock for T {
661
656
fn as_sock ( & self ) -> Socket { self . as_raw_fd ( ) }
662
657
}
@@ -672,8 +667,6 @@ cfg_if! {
672
667
use libc:: SO_KEEPALIVE as KEEPALIVE_OPTION ;
673
668
} else if #[ cfg( unix) ] {
674
669
use libc:: TCP_KEEPIDLE as KEEPALIVE_OPTION ;
675
- } else if #[ cfg( target_os = "redox" ) ] {
676
- use libc:: TCP_KEEPIDLE as KEEPALIVE_OPTION ;
677
670
} else {
678
671
// ...
679
672
}
@@ -715,29 +708,6 @@ impl TcpStreamExt for TcpStream {
715
708
self . keepalive_ms ( ) . map ( |o| o. map ( ms2dur) )
716
709
}
717
710
718
- #[ cfg( target_os = "redox" ) ]
719
- fn set_keepalive_ms ( & self , keepalive : Option < u32 > ) -> io:: Result < ( ) > {
720
- try!( set_opt ( self . as_sock ( ) , SOL_SOCKET , SO_KEEPALIVE ,
721
- keepalive. is_some ( ) as c_int ) ) ;
722
- if let Some ( dur) = keepalive {
723
- try!( set_opt ( self . as_sock ( ) , v ( IPPROTO_TCP ) , KEEPALIVE_OPTION ,
724
- ( dur / 1000 ) as c_int ) ) ;
725
- }
726
- Ok ( ( ) )
727
- }
728
-
729
- #[ cfg( target_os = "redox" ) ]
730
- fn keepalive_ms ( & self ) -> io:: Result < Option < u32 > > {
731
- let keepalive = try!( get_opt :: < c_int > ( self . as_sock ( ) , SOL_SOCKET ,
732
- SO_KEEPALIVE ) ) ;
733
- if keepalive == 0 {
734
- return Ok ( None )
735
- }
736
- let secs = try!( get_opt :: < c_int > ( self . as_sock ( ) , v ( IPPROTO_TCP ) ,
737
- KEEPALIVE_OPTION ) ) ;
738
- Ok ( Some ( ( secs as u32 ) * 1000 ) )
739
- }
740
-
741
711
#[ cfg( unix) ]
742
712
fn set_keepalive_ms ( & self , keepalive : Option < u32 > ) -> io:: Result < ( ) > {
743
713
try!( set_opt ( self . as_sock ( ) , SOL_SOCKET , SO_KEEPALIVE ,
@@ -893,7 +863,7 @@ impl TcpStreamExt for TcpStream {
893
863
}
894
864
}
895
865
896
- #[ cfg( any( target_os = "redox" , unix, target_os = "wasi" ) ) ]
866
+ #[ cfg( any( unix, target_os = "wasi" ) ) ]
897
867
fn ms2timeout ( dur : Option < u32 > ) -> timeval {
898
868
// TODO: be more rigorous
899
869
match dur {
@@ -905,7 +875,7 @@ fn ms2timeout(dur: Option<u32>) -> timeval {
905
875
}
906
876
}
907
877
908
- #[ cfg( any( target_os = "redox" , unix, target_os = "wasi" ) ) ]
878
+ #[ cfg( any( unix, target_os = "wasi" ) ) ]
909
879
fn timeout2ms ( dur : timeval ) -> Option < u32 > {
910
880
if dur. tv_sec == 0 && dur. tv_usec == 0 {
911
881
None
@@ -950,7 +920,7 @@ fn dur2linger(dur: Option<Duration>) -> linger {
950
920
}
951
921
}
952
922
953
- #[ cfg( any( target_os = "redox" , unix, target_os = "wasi" ) ) ]
923
+ #[ cfg( any( unix, target_os = "wasi" ) ) ]
954
924
fn dur2linger ( dur : Option < Duration > ) -> linger {
955
925
match dur {
956
926
Some ( d) => {
@@ -1027,24 +997,18 @@ impl UdpSocketExt for UdpSocket {
1027
997
set_opt ( self . as_sock ( ) , IPPROTO_IP , IP_MULTICAST_TTL ,
1028
998
multicast_ttl_v4 as c_int )
1029
999
}
1030
-
1000
+
1031
1001
fn multicast_ttl_v4 ( & self ) -> io:: Result < u32 > {
1032
1002
get_opt :: < c_int > ( self . as_sock ( ) , IPPROTO_IP , IP_MULTICAST_TTL )
1033
1003
. map ( |b| b as u32 )
1034
1004
}
1035
1005
1036
1006
fn set_multicast_hops_v6 ( & self , _hops : u32 ) -> io:: Result < ( ) > {
1037
- #[ cfg( target_os = "redox" ) ]
1038
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1039
- #[ cfg( not( target_os = "redox" ) ) ]
1040
1007
set_opt ( self . as_sock ( ) , v ( IPPROTO_IPV6 ) , IPV6_MULTICAST_HOPS ,
1041
1008
_hops as c_int )
1042
1009
}
1043
1010
1044
1011
fn multicast_hops_v6 ( & self ) -> io:: Result < u32 > {
1045
- #[ cfg( target_os = "redox" ) ]
1046
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1047
- #[ cfg( not( target_os = "redox" ) ) ]
1048
1012
get_opt :: < c_int > ( self . as_sock ( ) , v ( IPPROTO_IPV6 ) , IPV6_MULTICAST_HOPS )
1049
1013
. map ( |b| b as u32 )
1050
1014
}
@@ -1059,30 +1023,18 @@ impl UdpSocketExt for UdpSocket {
1059
1023
}
1060
1024
1061
1025
fn set_multicast_if_v4 ( & self , _interface : & Ipv4Addr ) -> io:: Result < ( ) > {
1062
- #[ cfg( target_os = "redox" ) ]
1063
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1064
- #[ cfg( not( target_os = "redox" ) ) ]
1065
1026
set_opt ( self . as_sock ( ) , IPPROTO_IP , IP_MULTICAST_IF , ip2in_addr ( _interface) )
1066
1027
}
1067
1028
1068
1029
fn multicast_if_v4 ( & self ) -> io:: Result < Ipv4Addr > {
1069
- #[ cfg( target_os = "redox" ) ]
1070
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1071
- #[ cfg( not( target_os = "redox" ) ) ]
1072
1030
get_opt ( self . as_sock ( ) , IPPROTO_IP , IP_MULTICAST_IF ) . map ( in_addr2ip)
1073
1031
}
1074
1032
1075
1033
fn set_multicast_if_v6 ( & self , _interface : u32 ) -> io:: Result < ( ) > {
1076
- #[ cfg( target_os = "redox" ) ]
1077
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1078
- #[ cfg( not( target_os = "redox" ) ) ]
1079
1034
set_opt ( self . as_sock ( ) , v ( IPPROTO_IPV6 ) , IPV6_MULTICAST_IF , to_ipv6mr_interface ( _interface) )
1080
1035
}
1081
1036
1082
1037
fn multicast_if_v6 ( & self ) -> io:: Result < u32 > {
1083
- #[ cfg( target_os = "redox" ) ]
1084
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1085
- #[ cfg( not( target_os = "redox" ) ) ]
1086
1038
get_opt :: < c_int > ( self . as_sock ( ) , v ( IPPROTO_IPV6 ) , IPV6_MULTICAST_IF ) . map ( |b| b as u32 )
1087
1039
}
1088
1040
@@ -1096,16 +1048,10 @@ impl UdpSocketExt for UdpSocket {
1096
1048
}
1097
1049
1098
1050
fn set_unicast_hops_v6 ( & self , _ttl : u32 ) -> io:: Result < ( ) > {
1099
- #[ cfg( target_os = "redox" ) ]
1100
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1101
- #[ cfg( not( target_os = "redox" ) ) ]
1102
1051
set_opt ( self . as_sock ( ) , v ( IPPROTO_IPV6 ) , IPV6_UNICAST_HOPS , _ttl as c_int )
1103
1052
}
1104
1053
1105
1054
fn unicast_hops_v6 ( & self ) -> io:: Result < u32 > {
1106
- #[ cfg( target_os = "redox" ) ]
1107
- return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "Not implemented yet" ) ) ;
1108
- #[ cfg( not( target_os = "redox" ) ) ]
1109
1055
get_opt :: < c_int > ( self . as_sock ( ) , IPPROTO_IP , IPV6_UNICAST_HOPS )
1110
1056
. map ( |b| b as u32 )
1111
1057
}
@@ -1200,13 +1146,6 @@ impl UdpSocketExt for UdpSocket {
1200
1146
do_connect ( self . as_sock ( ) , addr)
1201
1147
}
1202
1148
1203
- #[ cfg( target_os = "redox" ) ]
1204
- fn send ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
1205
- unsafe {
1206
- :: cvt ( write ( self . as_sock ( ) as c_int , buf. as_ptr ( ) as * const _ , buf. len ( ) ) ) . map ( |n| n as usize )
1207
- }
1208
- }
1209
-
1210
1149
#[ cfg( unix) ]
1211
1150
fn send ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
1212
1151
unsafe {
@@ -1240,14 +1179,6 @@ impl UdpSocketExt for UdpSocket {
1240
1179
}
1241
1180
}
1242
1181
1243
- #[ cfg( target_os = "redox" ) ]
1244
- fn recv ( & self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
1245
- unsafe {
1246
- :: cvt ( read ( self . as_sock ( ) as c_int , buf. as_mut_ptr ( ) as * mut _ , buf. len ( ) ) )
1247
- . map ( |n| n as usize )
1248
- }
1249
- }
1250
-
1251
1182
#[ cfg( unix) ]
1252
1183
fn recv ( & self , buf : & mut [ u8 ] ) -> io:: Result < usize > {
1253
1184
unsafe {
@@ -1302,21 +1233,6 @@ fn do_connect<A: ToSocketAddrs>(sock: Socket, addr: A) -> io::Result<()> {
1302
1233
return ret
1303
1234
}
1304
1235
1305
- #[ cfg( target_os = "redox" ) ]
1306
- fn set_nonblocking ( sock : Socket , nonblocking : bool ) -> io:: Result < ( ) > {
1307
- let mut flags = :: cvt ( unsafe {
1308
- fcntl ( sock as c_int , F_GETFL )
1309
- } ) ?;
1310
- if nonblocking {
1311
- flags |= O_NONBLOCK ;
1312
- } else {
1313
- flags &= !O_NONBLOCK ;
1314
- }
1315
- :: cvt ( unsafe {
1316
- fcntl ( sock as c_int , F_SETFL , flags)
1317
- } ) . and ( Ok ( ( ) ) )
1318
- }
1319
-
1320
1236
#[ cfg( unix) ]
1321
1237
fn set_nonblocking ( sock : Socket , nonblocking : bool ) -> io:: Result < ( ) > {
1322
1238
let mut nonblocking = nonblocking as c_ulong ;
@@ -1338,17 +1254,6 @@ fn set_nonblocking(sock: Socket, nonblocking: bool) -> io::Result<()> {
1338
1254
} ) . map ( |_| ( ) )
1339
1255
}
1340
1256
1341
- #[ cfg( target_os = "redox" ) ]
1342
- fn ip2in_addr ( ip : & Ipv4Addr ) -> in_addr {
1343
- let oct = ip. octets ( ) ;
1344
- in_addr {
1345
- s_addr : :: hton ( ( ( oct[ 0 ] as u32 ) << 24 ) |
1346
- ( ( oct[ 1 ] as u32 ) << 16 ) |
1347
- ( ( oct[ 2 ] as u32 ) << 8 ) |
1348
- ( ( oct[ 3 ] as u32 ) << 0 ) ) ,
1349
- }
1350
- }
1351
-
1352
1257
#[ cfg( any( unix, target_os = "wasi" ) ) ]
1353
1258
fn ip2in_addr ( ip : & Ipv4Addr ) -> in_addr {
1354
1259
let oct = ip. octets ( ) ;
@@ -1377,7 +1282,7 @@ fn ip2in_addr(ip: &Ipv4Addr) -> in_addr {
1377
1282
1378
1283
fn in_addr2ip ( ip : & in_addr ) -> Ipv4Addr {
1379
1284
let h_addr = c:: in_addr_to_u32 ( ip) ;
1380
-
1285
+
1381
1286
let a: u8 = ( h_addr >> 24 ) as u8 ;
1382
1287
let b: u8 = ( h_addr >> 16 ) as u8 ;
1383
1288
let c: u8 = ( h_addr >> 8 ) as u8 ;
0 commit comments