@@ -178,6 +178,11 @@ s! {
178
178
pub st_ctim: timespec,
179
179
__reserved: [ c_longlong; 3 ] ,
180
180
}
181
+
182
+ pub struct fd_set {
183
+ __nfds: usize ,
184
+ __fds: [ c_int; FD_SETSIZE as usize ] ,
185
+ }
181
186
}
182
187
183
188
// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
@@ -446,6 +451,28 @@ pub const NOEXPR: ::nl_item = 0x50001;
446
451
pub const YESSTR : :: nl_item = 0x50002 ;
447
452
pub const NOSTR : :: nl_item = 0x50003 ;
448
453
454
+ f ! {
455
+ pub fn FD_ISSET ( fd: :: c_int, set: * const fd_set) -> bool {
456
+ let set = & * set;
457
+ let n = set. __nfds;
458
+ return set. __fds[ ..n] . iter( ) . any( |p| * p == fd)
459
+ }
460
+
461
+ pub fn FD_SET ( fd: :: c_int, set: * mut fd_set) -> ( ) {
462
+ let set = & mut * set;
463
+ let n = set. __nfds;
464
+ if !set. __fds[ ..n] . iter( ) . any( |p| * p == fd) {
465
+ set. __nfds = n + 1 ;
466
+ set. __fds[ n] = fd;
467
+ }
468
+ }
469
+
470
+ pub fn FD_ZERO ( set: * mut fd_set) -> ( ) {
471
+ ( * set) . __nfds = 0 ;
472
+ return
473
+ }
474
+ }
475
+
449
476
#[ cfg_attr(
450
477
feature = "rustc-dep-of-std" ,
451
478
link(
@@ -741,6 +768,14 @@ extern "C" {
741
768
pub fn nl_langinfo ( item : :: nl_item ) -> * mut :: c_char ;
742
769
pub fn nl_langinfo_l ( item : :: nl_item , loc : :: locale_t ) -> * mut :: c_char ;
743
770
771
+ pub fn select (
772
+ nfds : c_int ,
773
+ readfds : * mut fd_set ,
774
+ writefds : * mut fd_set ,
775
+ errorfds : * mut fd_set ,
776
+ timeout : * const timeval ,
777
+ ) -> c_int ;
778
+
744
779
pub fn __wasilibc_register_preopened_fd ( fd : c_int , path : * const c_char ) -> c_int ;
745
780
pub fn __wasilibc_fd_renumber ( fd : c_int , newfd : c_int ) -> c_int ;
746
781
pub fn __wasilibc_unlinkat ( fd : c_int , path : * const c_char ) -> c_int ;
0 commit comments