diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-07-17 16:16:36 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-07-17 16:16:36 +0000 |
commit | da8e87e3c955dd8d775d93ed437d1b7466f31aa7 (patch) | |
tree | 1fadc2d194d767dab385e781ace2644833c010b4 /ace/OS.i | |
parent | 64668680a52f0104d61e5b404165bde3bd8a5144 (diff) | |
download | ATCD-da8e87e3c955dd8d775d93ed437d1b7466f31aa7.tar.gz |
(sema_wait w/time): on VxWorks and pSoS, subtract the current time from
the time argument to get the relative time that the systems calls expect.
Also, removed ACE_ADAPT_RETVAL wrap so that errno isn't disturbed. On
VxWorks, convert S_objLib_OBJ_TIMEOUT errno to ETIME.
Diffstat (limited to 'ace/OS.i')
-rw-r--r-- | ace/OS.i | 47 |
1 files changed, 33 insertions, 14 deletions
@@ -2845,7 +2845,7 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) switch (::WaitForSingleObject (*s, msec_timeout)) { case WAIT_OBJECT_0: - tv = ACE_OS::gettimeofday (); // Update time to when acquired + tv = ACE_OS::gettimeofday (); // Update time to when acquired return 0; case WAIT_TIMEOUT: errno = ETIME; @@ -2892,10 +2892,10 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) // Only return when we successfully get the semaphore. if (result == 0) - { - tv = ACE_OS::gettimeofday (); // Update to time acquired - return 0; - } + { + tv = ACE_OS::gettimeofday (); // Update to time acquired + return 0; + } break; // We have timed out. @@ -2920,19 +2920,38 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv) return -1; # endif /* ACE_USES_WINCE_SEMA_SIMULATION */ # elif defined (VXWORKS) + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // the system call expects). + ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); + int ticks_per_sec = ::sysClkRateGet (); - int ticks = tv.sec() * ticks_per_sec + - tv.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::semTake (s->sema_, ticks), ace_result_), int, -1); + int ticks = relative_time.sec() * ticks_per_sec + + relative_time.usec () * ticks_per_sec / ACE_ONE_SECOND_IN_USECS; + if (::semTake (s->sema_, ticks) == ERROR) + { + if (errno == S_objLib_OBJ_TIMEOUT) + // Convert the VxWorks errno to one that's common for to ACE + // platforms. + errno = ETIME; + return -1; + } + else + { + return 0; + } # endif /* ACE_HAS_STHREADS */ #elif defined (ACE_PSOS) /* TBD - move this into threaded section with mutithreaded port */ - int result; - u_long ticks = tv.sec() * KC_TICKS2SEC + - tv.usec () * KC_TICKS2SEC / ACE_ONE_SECOND_IN_USECS; - ACE_OSCALL (ACE_ADAPT_RETVAL (::sm_p (s->sema_, SM_WAIT, ticks), result), - int, -1, result); - return result; + // Note that we must convert between absolute time (which is + // passed as a parameter) and relative time (which is what + // the system call expects). + ACE_Time_Value relative_time (tv - ACE_OS::gettimeofday ()); + + u_long ticks = relative_time.sec() * KC_TICKS2SEC + + relative_time.usec () * KC_TICKS2SEC / + ACE_ONE_SECOND_IN_USECS; + ACE_OSCALL_RETURN (::sm_p (s->sema_, SM_WAIT, ticks), int, -1); #else ACE_UNUSED_ARG (s); ACE_UNUSED_ARG (tv); |