Annotation of gforth/select.c, revision 1.2
1.1 anton 1: #include <sys/time.h>
2:
3: /* select replacement for DOS computers for ms only */
4: void select(int n, int a, int b, int c, struct timeval * timeout)
5: {
6: struct timeval time1;
7: struct timeval time2;
8: struct timezone zone1;
9:
10: gettimeofday(&time1,&zone1);
11: time1.tv_sec += timeout->tv_sec;
12: time1.tv_usec += timeout->tv_usec;
13: if(time1.tv_usec >= 1000000)
14: {
15: time1.tv_sec += time1.tv_usec / 1000000;
16: time1.tv_usec %= 1000000;
17: }
18: do
19: {
20: gettimeofday(&time2,&zone1);
21: }
22: while(time2.tv_sec < time1.tv_sec);
23:
24: do
25: {
26: gettimeofday(&time2,&zone1);
27: }
28: while(time2.tv_usec < time1.tv_usec &&
29: time2.tv_sec == time1.tv_sec);
30:
31: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>