~profzoom/ubuntu/quantal/wmaker/bug-1079925

« back to all changes in this revision

Viewing changes to WINGs/usleep.c

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2004-11-10 14:05:30 UTC
  • Revision ID: james.westby@ubuntu.com-20041110140530-qpd66b5lm38x7apk
Tags: upstream-0.91.0
ImportĀ upstreamĀ versionĀ 0.91.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
#include "../src/config.h"
 
4
 
 
5
 
 
6
#ifdef HAVE_SYS_TIME_H
 
7
# include <sys/time.h>
 
8
#endif
 
9
 
 
10
#ifdef HAVE_SYS_TYPES_H
 
11
# include <sys/types.h>
 
12
#endif
 
13
 
 
14
 
 
15
#include <unistd.h>
 
16
#include <string.h>
 
17
 
 
18
#if defined(HAVE_SELECT)
 
19
 
 
20
#ifdef HAVE_SYS_SELECT_H
 
21
# include <sys/select.h>
 
22
#endif
 
23
 
 
24
void
 
25
wusleep(unsigned int microsecs)
 
26
{
 
27
    struct timeval tv;
 
28
    fd_set rd, wr, ex;
 
29
    FD_ZERO(&rd);
 
30
    FD_ZERO(&wr);
 
31
    FD_ZERO(&ex);
 
32
    tv.tv_sec = microsecs / 1000000u;
 
33
    tv.tv_usec = microsecs % 1000000u;
 
34
    select(1, &rd, &wr, &ex, &tv);
 
35
}
 
36
 
 
37
#else /* not HAVE_SELECT */
 
38
 
 
39
# ifdef HAVE_POLL
 
40
 
 
41
void
 
42
wusleep(unsigned int microsecs)
 
43
{
 
44
    poll((struct poll *) 0, (size_t) 0, microsecs/1000);
 
45
}
 
46
 
 
47
# else /* ! HAVE_POLL */
 
48
 
 
49
oops!
 
50
 
 
51
# endif /* !HAVE_POLL */
 
52
#endif /* !HAVE_SELECT */