2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "../afs/param.h"
15 #include "../afs/sysincludes.h" /* Standard vendor system headers */
16 #include "../afs/afsincludes.h" /* Afs-based standard headers */
17 #include "../afs/afs_stats.h" /* afs statistics */
24 /* call procedure aproc with arock as an argument, in ams milliseconds */
25 static int afs_osi_CallProc(aproc, arock, ams)
26 register void (*aproc)();
32 AFS_STATCNT(osi_CallProc);
34 /* hz is in cycles/second, and timeout's 3rd parm is in cycles */
35 code = timeout(aproc, arock, (ams * afs_hz)/1000 + 1);
40 /* cancel a timeout, whether or not it has already occurred */
41 static int afs_osi_CancelProc(aproc, arock)
42 register void (*aproc)();
46 AFS_STATCNT(osi_CancelProc);
49 code = untimeout(aproc, arock);
54 static void AfsWaitHack()
56 AFS_STATCNT(WaitHack);
60 void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle)
62 AFS_STATCNT(osi_InitWaitHandle);
63 achandle->proc = (caddr_t) 0;
67 void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
71 AFS_STATCNT(osi_CancelWait);
72 proc = achandle->proc;
73 if (proc == 0) return;
74 achandle->proc = (caddr_t) 0; /* so dude can figure out he was signalled */
75 afs_osi_Wakeup(&waitV);
79 * Waits for data on ahandle, or ams ms later. ahandle may be null.
80 * Returns 0 if timeout and EINTR if signalled.
82 int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok)
85 afs_int32 endTime, tid;
87 AFS_STATCNT(osi_Wait);
88 endTime = osi_Time() + (ams/1000);
90 ahandle->proc = (caddr_t) u.u_procp;
94 /* do not do anything for solaris, digital, AIX, and SGI MP */
95 afs_osi_CallProc(AfsWaitHack, (char *) u.u_procp, ams);
96 afs_osi_Sleep(&waitV); /* for HP 10.0 */
98 /* do not do anything for solaris, digital, and SGI MP */
99 afs_osi_CancelProc(AfsWaitHack, (char *) u.u_procp);
100 if (code) break; /* if something happened, quit now */
101 /* if we we're cancelled, quit now */
102 if (ahandle && (ahandle->proc == (caddr_t) 0)) {
103 /* we've been signalled */
106 } while (osi_Time() < endTime);
110 int afs_osi_SleepSig(void *event)
112 afs_osi_Sleep(event);