Ticket #796: semtimedwait.txt

File semtimedwait.txt, 974 bytes (added by dufault, on 12/03/06 at 13:31:13)

semtimedwait.txt

Line 
1*** semtimedwait.c.orig 2001-01-24 09:17:28.000000000 -0500
2--- semtimedwait.c      2005-05-23 15:28:45.000000000 -0400
3***************
4*** 29,40 ****
5
6int sem_timedwait(
7  sem_t                 *sem,
8!   const struct timespec *timeout
9)
10{
11  return _POSIX_Semaphore_Wait_support(
12    sem,
13    TRUE,
14!     _POSIX_Timespec_to_interval( timeout )
15  );
16}
17--- 29,56 ----
18
19int sem_timedwait(
20  sem_t                 *sem,
21!   const struct timespec *abstime
22)
23{
24+   /*
25+    *  The abstime is a walltime.  We turn it into an interval.
26+    */
27+
28+   Watchdog_Interval timeout;
29+   struct timespec   current_time;
30+   struct timespec   difference;
31+
32+   (void) clock_gettime( CLOCK_REALTIME, &current_time );
33+
34+   /* XXX probably some error checking should go here */
35+
36+   _POSIX_Timespec_subtract( &current_time, abstime, &difference );
37+
38+   timeout = _POSIX_Timespec_to_interval( &difference );
39+
40  return _POSIX_Semaphore_Wait_support(
41    sem,
42    TRUE,
43!     timeout
44  );
45}
46