select.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * select() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #include <sys/select.h>
  11. extern __typeof(select) __libc_select;
  12. #if !defined(__NR__newselect) && !defined(__NR_select) && defined __USE_XOPEN2K
  13. # define __NR___libc_pselect6 __NR_pselect6
  14. _syscall6(int, __libc_pselect6, int, n, fd_set *, readfds, fd_set *, writefds,
  15. fd_set *, exceptfds, const struct timespec *, timeout,
  16. const sigset_t *, sigmask)
  17. int __libc_select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
  18. struct timeval *timeout)
  19. {
  20. struct timespec _ts, *ts = 0;
  21. if (timeout) {
  22. _ts.tv_sec = timeout->tv_sec;
  23. _ts.tv_nsec = timeout->tv_usec * 1000;
  24. ts = &_ts;
  25. }
  26. return __libc_pselect6(n, readfds, writefds, exceptfds, ts, 0);
  27. }
  28. #else
  29. #ifdef __NR__newselect
  30. # define __NR___libc_select __NR__newselect
  31. #else
  32. # define __NR___libc_select __NR_select
  33. #endif
  34. _syscall5(int, __libc_select, int, n, fd_set *, readfds, fd_set *, writefds,
  35. fd_set *, exceptfds, struct timeval *, timeout)
  36. #endif
  37. libc_hidden_proto(select)
  38. weak_alias(__libc_select,select)
  39. libc_hidden_weak(select)