Change to the linux kernel coding style
[wmaker-crm.git] / WINGs / usleep.c
1
2 #include "wconfig.h"
3
4 #ifdef HAVE_SYS_TIME_H
5 # include <sys/time.h>
6 #endif
7
8 #ifdef HAVE_SYS_TYPES_H
9 # include <sys/types.h>
10 #endif
11
12 #include <unistd.h>
13 #include <string.h>
14
15 #if defined(HAVE_SELECT)
16
17 #ifdef HAVE_SYS_SELECT_H
18 # include <sys/select.h>
19 #endif
20
21 void wusleep(unsigned int microsecs)
22 {
23         struct timeval tv;
24         fd_set rd, wr, ex;
25         FD_ZERO(&rd);
26         FD_ZERO(&wr);
27         FD_ZERO(&ex);
28         tv.tv_sec = microsecs / 1000000u;
29         tv.tv_usec = microsecs % 1000000u;
30         select(1, &rd, &wr, &ex, &tv);
31 }
32
33 #else                           /* not HAVE_SELECT */
34
35 # ifdef HAVE_POLL
36
37 void wusleep(unsigned int microsecs)
38 {
39         poll((struct poll *)0, (size_t) 0, microsecs / 1000);
40 }
41
42 # else                          /* ! HAVE_POLL */
43
44 oops !
45 # endif                         /* !HAVE_POLL */
46 #endif                          /* !HAVE_SELECT */