Change to the linux kernel coding style
[wmaker-crm.git] / WINGs / usleep.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001
558615a8 dan2004-10-30 05:46:37 +00002#include "wconfig.h"
9d2e6ef9 scottc1998-09-29 22:36:29 +00003
9d2e6ef9 scottc1998-09-29 22:36:29 +00004#ifdef HAVE_SYS_TIME_H
5# include <sys/time.h>
6#endif
7
9d2e6ef9 scottc1998-09-29 22:36:29 +00008#ifdef HAVE_SYS_TYPES_H
9# include <sys/types.h>
10#endif
11
7f9f8894 kojima1999-03-15 23:41:22 +000012#include <unistd.h>
13#include <string.h>
14
9d2e6ef9 scottc1998-09-29 22:36:29 +000015#if defined(HAVE_SELECT)
16
9af1c6c4 dan1998-10-21 14:43:47 +000017#ifdef HAVE_SYS_SELECT_H
18# include <sys/select.h>
19#endif
9d2e6ef9 scottc1998-09-29 22:36:29 +000020
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020021void wusleep(unsigned int microsecs)
9d2e6ef9 scottc1998-09-29 22:36:29 +000022{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020023 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);
9d2e6ef9 scottc1998-09-29 22:36:29 +000031}
32
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020033#else /* not HAVE_SELECT */
9d2e6ef9 scottc1998-09-29 22:36:29 +000034
6830b057 dan2004-10-12 21:28:27 +000035# ifdef HAVE_POLL
9d2e6ef9 scottc1998-09-29 22:36:29 +000036
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020037void wusleep(unsigned int microsecs)
9d2e6ef9 scottc1998-09-29 22:36:29 +000038{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020039 poll((struct poll *)0, (size_t) 0, microsecs / 1000);
9d2e6ef9 scottc1998-09-29 22:36:29 +000040}
41
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020042# else /* ! HAVE_POLL */
9d2e6ef9 scottc1998-09-29 22:36:29 +000043
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020044oops !
45# endif /* !HAVE_POLL */
46#endif /* !HAVE_SELECT */