1 /* This file is part of the Project Athena Zephyr Notification System.
2 * It contains the ZCheckIfNotice/select loop used for waiting for
3 * a notice, with a timeout.
5 * Copyright (c) 1991 by the Massachusetts Institute of Technology.
6 * For copying and distribution information, see the file
15 #ifndef ZEPHYR_USES_KERBEROS
16 static int gettimeofday(struct timeval
* tv
, struct timezone
* tz
){
18 long long ns100
; /*time since 1 Jan 1601 in 100ns units */
22 GetSystemTimeAsFileTime( &(_now
.ft
) );
23 tv
->tv_usec
=(long)((_now
.ns100
/ 10LL) % 1000000LL );
24 tv
->tv_sec
= (long)((_now
.ns100
-(116444736000000000LL))/10000000LL);
30 #include <sys/socket.h>
33 Code_t
Z_WaitForNotice (notice
, pred
, arg
, timeout
)
35 int (*pred
)(ZNotice_t
*, void *);
40 struct timeval tv
, t0
;
44 retval
= ZCheckIfNotice (notice
, (struct sockaddr_in
*) 0, pred
,
46 if (retval
== ZERR_NONE
)
48 if (retval
!= ZERR_NONOTICE
)
55 gettimeofday (&t0
, (struct timezone
*)NULL
);
59 i
= select (fd
+ 1, &fdmask
, (fd_set
*) 0, (fd_set
*) 0, &tv
);
62 if (i
< 0 && errno
!= EINTR
)
65 retval
= ZCheckIfNotice (notice
, (struct sockaddr_in
*) 0, pred
,
67 if (retval
!= ZERR_NONOTICE
) /* includes ZERR_NONE */
70 gettimeofday (&tv
, (struct timezone
*) NULL
);
71 tv
.tv_usec
= t0
.tv_usec
- tv
.tv_usec
;
73 tv
.tv_usec
+= 1000000;
74 tv
.tv_sec
= t0
.tv_sec
- tv
.tv_sec
- 1;
77 tv
.tv_sec
= t0
.tv_sec
- tv
.tv_sec
;