1313#![ allow( dead_code) ]
1414#![ allow( non_camel_case_types) ]
1515
16- pub use self :: select:: fd_set;
1716pub use self :: signal:: { sigaction, siginfo, sigset_t} ;
1817pub use self :: signal:: { SA_ONSTACK , SA_RESTART , SA_RESETHAND , SA_NOCLDSTOP } ;
1918pub use self :: signal:: { SA_NODEFER , SA_NOCLDWAIT , SA_SIGINFO , SIGCHLD } ;
@@ -26,45 +25,21 @@ use libc;
2625 target_os = "dragonfly" ,
2726 target_os = "bitrig" ,
2827 target_os = "openbsd" ) ) ]
29- mod consts {
30- use libc;
31- pub const FIONBIO : libc:: c_ulong = 0x8004667e ;
32- pub const FIOCLEX : libc:: c_ulong = 0x20006601 ;
33- pub const FIONCLEX : libc:: c_ulong = 0x20006602 ;
34- }
28+ pub const FIOCLEX : libc:: c_ulong = 0x20006601 ;
29+
3530#[ cfg( any( all( target_os = "linux" ,
3631 any( target_arch = "x86" ,
3732 target_arch = "x86_64" ,
3833 target_arch = "arm" ,
3934 target_arch = "aarch64" ) ) ,
4035 target_os = "android" ) ) ]
41- mod consts {
42- use libc;
43- pub const FIONBIO : libc:: c_ulong = 0x5421 ;
44- pub const FIOCLEX : libc:: c_ulong = 0x5451 ;
45- pub const FIONCLEX : libc:: c_ulong = 0x5450 ;
46- }
36+ pub const FIOCLEX : libc:: c_ulong = 0x5451 ;
37+
4738#[ cfg( all( target_os = "linux" ,
4839 any( target_arch = "mips" ,
4940 target_arch = "mipsel" ,
5041 target_arch = "powerpc" ) ) ) ]
51- mod consts {
52- use libc;
53- pub const FIONBIO : libc:: c_ulong = 0x667e ;
54- pub const FIOCLEX : libc:: c_ulong = 0x6601 ;
55- pub const FIONCLEX : libc:: c_ulong = 0x6600 ;
56- }
57- pub use self :: consts:: * ;
58-
59- #[ cfg( any( target_os = "macos" ,
60- target_os = "ios" ,
61- target_os = "freebsd" ,
62- target_os = "dragonfly" ,
63- target_os = "bitrig" ,
64- target_os = "openbsd" ) ) ]
65- pub const MSG_DONTWAIT : libc:: c_int = 0x80 ;
66- #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
67- pub const MSG_DONTWAIT : libc:: c_int = 0x40 ;
42+ pub const FIOCLEX : libc:: c_ulong = 0x6601 ;
6843
6944pub const WNOHANG : libc:: c_int = 1 ;
7045
@@ -123,13 +98,6 @@ pub struct passwd {
12398}
12499
125100extern {
126- pub fn gettimeofday ( timeval : * mut libc:: timeval ,
127- tzp : * mut libc:: c_void ) -> libc:: c_int ;
128- pub fn select ( nfds : libc:: c_int ,
129- readfds : * mut fd_set ,
130- writefds : * mut fd_set ,
131- errorfds : * mut fd_set ,
132- timeout : * mut libc:: timeval ) -> libc:: c_int ;
133101 pub fn getsockopt ( sockfd : libc:: c_int ,
134102 level : libc:: c_int ,
135103 optname : libc:: c_int ,
@@ -165,44 +133,6 @@ extern {
165133 -> * mut libc:: c_char ;
166134}
167135
168- #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
169- mod select {
170- pub const FD_SETSIZE : usize = 1024 ;
171-
172- #[ repr( C ) ]
173- pub struct fd_set {
174- fds_bits : [ i32 ; ( FD_SETSIZE / 32 ) ]
175- }
176-
177- pub fn fd_set ( set : & mut fd_set , fd : i32 ) {
178- set. fds_bits [ ( fd / 32 ) as usize ] |= 1 << ( ( fd % 32 ) as usize ) ;
179- }
180- }
181-
182- #[ cfg( any( target_os = "android" ,
183- target_os = "freebsd" ,
184- target_os = "dragonfly" ,
185- target_os = "bitrig" ,
186- target_os = "openbsd" ,
187- target_os = "linux" ) ) ]
188- mod select {
189- use usize;
190- use libc;
191-
192- pub const FD_SETSIZE : usize = 1024 ;
193-
194- #[ repr( C ) ]
195- pub struct fd_set {
196- // FIXME: shouldn't this be a c_ulong?
197- fds_bits : [ libc:: uintptr_t ; ( FD_SETSIZE / usize:: BITS ) ]
198- }
199-
200- pub fn fd_set ( set : & mut fd_set , fd : i32 ) {
201- let fd = fd as usize ;
202- set. fds_bits [ fd / usize:: BITS ] |= 1 << ( fd % usize:: BITS ) ;
203- }
204- }
205-
206136#[ cfg( any( all( target_os = "linux" ,
207137 any( target_arch = "x86" ,
208138 target_arch = "x86_64" ,
0 commit comments