posixselect.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* posixselect.h -- wrapper for select(2) includes and definitions */
  2. /* Copyright (C) 2009 Free Software Foundation, Inc.
  3. This file is part of GNU Bash, the Bourne Again SHell.
  4. Bash is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Bash is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Bash. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef _POSIXSELECT_H_
  16. #define _POSIXSELECT_H_
  17. #if defined (FD_SET) && !defined (HAVE_SELECT)
  18. # define HAVE_SELECT 1
  19. #endif
  20. #if defined (HAVE_SELECT)
  21. # if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
  22. # include <sys/time.h>
  23. # endif
  24. #endif /* HAVE_SELECT */
  25. #if defined (HAVE_SYS_SELECT_H)
  26. # include <sys/select.h>
  27. #endif
  28. #ifndef USEC_PER_SEC
  29. # define USEC_PER_SEC 1000000
  30. #endif
  31. #define USEC_TO_TIMEVAL(us, tv) \
  32. do { \
  33. (tv).tv_sec = (us) / USEC_PER_SEC; \
  34. (tv).tv_usec = (us) % USEC_PER_SEC; \
  35. } while (0)
  36. #endif /* _POSIXSELECT_H_ */