@@ -175,6 +175,11 @@ s! {
175
175
pub st_ctim: timespec,
176
176
__reserved: [ c_longlong; 3 ] ,
177
177
}
178
+
179
+ pub struct fd_set {
180
+ __nfds: usize ,
181
+ __fds: [ c_int; FD_SETSIZE ] ,
182
+ }
178
183
}
179
184
180
185
// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
@@ -438,6 +443,28 @@ pub const NOEXPR: ::nl_item = 0x50001;
438
443
pub const YESSTR : :: nl_item = 0x50002 ;
439
444
pub const NOSTR : :: nl_item = 0x50003 ;
440
445
446
+ f ! {
447
+ pub fn FD_ISSET ( fd: :: c_int, set: * const fd_set) -> bool {
448
+ let set = & * set;
449
+ let n = set. __nfds;
450
+ return set. __fds[ ..n] . iter( ) . any( |p| * p == fd)
451
+ }
452
+
453
+ pub fn FD_SET ( fd: :: c_int, set: * mut fd_set) -> ( ) {
454
+ let set = & mut * set;
455
+ let n = set. __nfds;
456
+ if !set. __fds[ ..n] . iter( ) . any( |p| * p == fd) {
457
+ set. __nfds = n + 1 ;
458
+ set. __fds[ n] = fd;
459
+ }
460
+ }
461
+
462
+ pub fn FD_ZERO ( set: * mut fd_set) -> ( ) {
463
+ ( * set) . __nfds = 0 ;
464
+ return
465
+ }
466
+ }
467
+
441
468
#[ cfg_attr(
442
469
feature = "rustc-dep-of-std" ,
443
470
link(
@@ -733,6 +760,14 @@ extern "C" {
733
760
pub fn nl_langinfo ( item : :: nl_item ) -> * mut :: c_char ;
734
761
pub fn nl_langinfo_l ( item : :: nl_item , loc : :: locale_t ) -> * mut :: c_char ;
735
762
763
+ pub fn select (
764
+ nfds : c_int ,
765
+ readfds : * mut fd_set ,
766
+ writefds : * mut fd_set ,
767
+ errorfds : * mut fd_set ,
768
+ timeout : * const timeval ,
769
+ ) -> c_int ;
770
+
736
771
pub fn __wasilibc_register_preopened_fd ( fd : c_int , path : * const c_char ) -> c_int ;
737
772
pub fn __wasilibc_fd_renumber ( fd : c_int , newfd : c_int ) -> c_int ;
738
773
pub fn __wasilibc_unlinkat ( fd : c_int , path : * const c_char ) -> c_int ;
0 commit comments