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 napms above poll above select above nap.  The nap function is
11   last because on different systems the argument has different
12   meanings.  */
13#if HAVE_USLEEP || HAVE_NAPMS || HAVE_POLL || HAVE_SELECT
14#undef HAVE_NAP
15#define HAVE_NAP 0
16#endif
17
18#if HAVE_USLEEP || HAVE_NAPMS || HAVE_POLL
19#undef HAVE_SELECT
20#define HAVE_SELECT 0
21#endif
22
23#if HAVE_USLEEP || HAVE_NAPMS
24#undef HAVE_POLL
25#define HAVE_POLL 0
26#endif
27
28#if HAVE_USLEEP
29#undef HAVE_NAPMS
30#define HAVE_NAPMS 0
31#endif
32
33#if HAVE_SELECT
34#if HAVE_SYS_TIME_H
35#include <sys/time.h>
36#endif
37#if HAVE_SYS_SELECT_H
38#include <sys/select.h>
39#endif
40#endif
41
42#if HAVE_POLL
43#if HAVE_STROPTS_H
44#include <stropts.h>
45#endif
46#if HAVE_POLL_H
47#include <poll.h>
48#endif
49#if ! HAVE_STROPTS_H && ! HAVE_POLL_H
50/* We need a definition for struct pollfd, although it doesn't matter
51   what it contains.  */
52struct pollfd
53{
54  int idummy;
55};
56#endif /* ! HAVE_STROPTS_H && ! HAVE_POLL_H */
57#endif /* HAVE_POLL */
58
59#if HAVE_TIME_H
60#if ! HAVE_SYS_TIME_H || ! HAVE_SELECT || TIME_WITH_SYS_TIME
61#include <time.h>
62#endif
63#endif
64
65void
66usysdep_pause ()
67{
68#if HAVE_NAPMS
69  napms (500);
70#endif /* HAVE_NAPMS */
71#if HAVE_NAP
72#if HAVE_HUNDREDTHS_NAP
73  nap (50L);
74#else
75  nap (500L);
76#endif /* ! HAVE_HUNDREDTHS_NAP */
77#endif /* HAVE_NAP */
78#if HAVE_USLEEP
79  usleep (500 * (long) 1000);
80#endif /* HAVE_USLEEP */
81#if HAVE_POLL
82  struct pollfd sdummy;
83
84  /* We need to pass an unused pollfd structure because poll checks
85     the address before checking the number of elements.  */
86  memset (&sdummy, 0, sizeof sdummy);
87  poll (&sdummy, 0, 500);
88#endif /* HAVE_POLL */
89#if HAVE_SELECT
90  struct timeval s;
91
92  s.tv_sec = 0;
93  s.tv_usec = 500 * (long) 1000;
94  select (0, (pointer) NULL, (pointer) NULL, (pointer) NULL, &s);
95#endif /* HAVE_SELECT */
96#if ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP
97#if ! HAVE_SELECT && ! HAVE_POLL
98  sleep (1);
99#endif /* ! HAVE_SELECT && ! HAVE_POLL */
100#endif /* ! HAVE_NAPMS && ! HAVE_NAP && ! HAVE_USLEEP */
101}
102