Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing select family of functions #10

Closed
flaub opened this issue May 14, 2015 · 5 comments
Closed

Missing select family of functions #10

flaub opened this issue May 14, 2015 · 5 comments

Comments

@flaub
Copy link

flaub commented May 14, 2015

Looks like this belongs either in bsd42 or posix01.

From select(2) of Linux man pages:

/* According to POSIX.1-2001 */
#include <sys/select.h>

/* According to earlier standards */
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

int select(int nfds, fd_set *readfds, fd_set *writefds,
           fd_set *exceptfds, struct timeval *timeout);

void FD_CLR(int fd, fd_set *set);
int  FD_ISSET(int fd, fd_set *set);
void FD_SET(int fd, fd_set *set);
void FD_ZERO(fd_set *set);

From select(2) of BSD System Calls Manual:

     #include <sys/select.h>

     void
     FD_CLR(fd, fd_set *fdset);

     void
     FD_COPY(fd_set *fdset_orig, fd_set *fdset_copy);

     int
     FD_ISSET(fd, fd_set *fdset);

     void
     FD_SET(fd, fd_set *fdset);

     void
     FD_ZERO(fd_set *fdset);

     int
     select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict errorfds, struct timeval *restrict timeout);

And then on Windows, which only works for sockets:

int select(
  _In_    int                  nfds,
  _Inout_ fd_set               *readfds,
  _Inout_ fd_set               *writefds,
  _Inout_ fd_set               *exceptfds,
  _In_    const struct timeval *timeout
);

With FD_CLR, FD_ISSET, FD_SET, and FD_ZERO defined as macros on most (all?) platforms.

@flaub
Copy link
Author

flaub commented May 14, 2015

With this layer in place, it would be possible to extend the std::net::*Socket API to allow for cancelation of pending I/O operations (recv, recv_from, send, accept, etc). This would fix rust-lang/rust#23272 and mentioned in rust-lang/rfcs#957. The goal here would not be to allow non-blocking I/O in general per-se, but to simply provide a way for users to cleanly cancel blocking calls.

@alexcrichton
Copy link
Member

Thanks for the report! Currently we're not trying to track all the missing APIs in liblibc, though, (there are quite a few!). You're more than welcome to add the bindings, however! If you make a PR against the main Rust repo then we can update the submodule here once that's landed.

@flaub
Copy link
Author

flaub commented May 14, 2015

Ok, I'll take a stab, thanks for the reply :)

@flaub
Copy link
Author

flaub commented May 14, 2015

I see now that many of the low level functions are actually implemented directly in libstd/sys.

jdm pushed a commit to jdm/libc that referenced this issue Jan 17, 2017
Susurrus pushed a commit to Susurrus/libc that referenced this issue Mar 26, 2017
dlrobertson pushed a commit to dlrobertson/libc that referenced this issue Oct 31, 2017
@keepsimple1
Copy link

Is select available now in Rust std? I couldn't find it in the current Rust 1.59.

lvllvl added a commit to lvllvl/libc that referenced this issue Jan 7, 2025
# This is the 1st commit message:

chore: add labels to FIXMEs

# This is the commit message rust-lang#2:

change label for .field FIXMEs
# This is the commit message rust-lang#3:

add fixme csv

# This is the commit message rust-lang#4:

Update fixmes.csv
# This is the commit message rust-lang#5:

Update fixmes.csv
# This is the commit message rust-lang#6:

Update fixmes.csv
# This is the commit message rust-lang#7:

Update fixmes.csv
# This is the commit message rust-lang#8:

Update fixmes.csv
# This is the commit message rust-lang#9:

Update fixmes.csv
# This is the commit message rust-lang#10:

Update fixmes.csv
# This is the commit message rust-lang#11:

Update fixmes.csv
# This is the commit message rust-lang#12:

Update fixmes.csv
# This is the commit message rust-lang#13:

Update fixmes.csv
# This is the commit message rust-lang#14:

Update fixmes.csv
# This is the commit message rust-lang#15:

Update fixmes.csv
# This is the commit message rust-lang#16:

Update fixmes.csv
# This is the commit message rust-lang#17:

Update fixmes.csv
# This is the commit message rust-lang#18:

updates to csv

# This is the commit message rust-lang#19:

Update fixmes.csv
# This is the commit message rust-lang#20:

Update fixmes.csv
# This is the commit message rust-lang#21:

Update fixmes.csv
# This is the commit message rust-lang#22:

Update fixmes.csv remove hurd"
# This is the commit message rust-lang#23:

Update fixmes.csv remove "'s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants