home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / uucp-1.04 / unix / pause.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-13  |  1.9 KB  |  97 lines

  1. /* pause.c
  2.    Pause for half a second.  */
  3.  
  4. #include "uucp.h"
  5.  
  6. #include "sysdep.h"
  7. #include "system.h"
  8.  
  9. /* Pick a timing routine to use.  I somewhat arbitrarily picked usleep
  10.    above nap above napms above poll above select.  */
  11. #if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS || HAVE_POLL
  12. #undef HAVE_SELECT
  13. #define HAVE_SELECT 0
  14. #endif
  15.  
  16. #if HAVE_USLEEP || HAVE_NAP || HAVE_NAPMS
  17. #undef HAVE_POLL
  18. #define HAVE_POLL 0
  19. #endif
  20.  
  21. #if HAVE_USLEEP || HAVE_NAP
  22. #undef HAVE_NAPMS
  23. #define HAVE_NAPMS 0
  24. #endif
  25.  
  26. #if HAVE_USLEEP
  27. #undef HAVE_NAP
  28. #define HAVE_NAP 0
  29. #endif
  30.  
  31. #if HAVE_SELECT
  32. #include <sys/time.h>
  33. #if HAVE_SYS_SELECT_H
  34. #include <sys/select.h>
  35. #endif
  36. #endif
  37.  
  38. #if HAVE_POLL
  39. #if HAVE_STROPTS_H
  40. #include <stropts.h>
  41. #endif
  42. #if HAVE_POLL_H
  43. #include <poll.h>
  44. #endif
  45. #if ! HAVE_STROPTS_H && ! HAVE_POLL_H
  46. /* We need a definition for struct pollfd, although it doesn't matter
  47.    what it contains.  */
  48. struct pollfd
  49. {
  50.   int idummy;
  51. };
  52. #endif /* ! HAVE_STROPTS_H && ! HAVE_POLL_H */
  53. #endif /* HAVE_POLL */
  54.  
  55. #if HAVE_TIME_H
  56. #if HAVE_SYS_TIME_AND_TIME_H || ! USE_SELECT_TIMER
  57. #include <time.h>
  58. #endif
  59. #endif
  60.  
  61. void
  62. usysdep_pause ()
  63. {
  64. #if HAVE_NAPMS
  65.   napms (500);
  66. #endif /* HAVE_NAPMS */
  67. #if HAVE_NAP
  68. #if HAVE_HUNDREDTHS_NAP
  69.   nap (50L);
  70. #else
  71.   nap (500L);
  72. #endif /* ! HAVE_HUNDREDTHS_NAP */
  73. #endif /* HAVE_NAP */
  74. #if HAVE_USLEEP
  75.   usleep (500 * (long) 1000);
  76. #endif /* HAVE_USLEEP */
  77. #if HAVE_POLL
  78.   struct pollfd sdummy;
  79.  
  80.   /* We need to pass an unused pollfd structure because poll checks
  81.      the address before checking the number of elements.  */
  82.   poll (&sdummy, 0, 500);
  83. #endif /* HAVE_POLL */
  84. #if HAVE_SELECT
  85.   struct timeval s;
  86.  
  87.   s.tv_sec = 0;
  88.   s.tv_usec = 500 * (long) 1000;
  89.   select (0, (pointer) NULL, (pointer) NULL, (pointer) NULL, &s);
  90. #endif /* USE_SELECT_TIMER */
  91. #if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP
  92. #if ! USE_SELECT_TIMER && ! HAVE_POLL
  93.   sleep (1);
  94. #endif /* ! USE_SELECT_TIMER && ! HAVE_POLL */
  95. #endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */
  96. }
  97.