diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-17 21:23:02 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-17 21:23:02 +0000 |
commit | 6e021697ae756d3957cb1deb153c91bdc7ab1ff4 (patch) | |
tree | 94184e08436c2678c0fd7c1f1ceb57e2cebcba86 /ace | |
parent | 60bef640626e02842baafd7623e51d7bec5dcec3 (diff) | |
download | ATCD-6e021697ae756d3957cb1deb153c91bdc7ab1ff4.tar.gz |
(gethrtime): with ACE_HAS_CLOCK_GETTIME, carefully construct return value to avoid arithmetic overflow if ACE_LACKS_LONGLONG_T
Diffstat (limited to 'ace')
-rw-r--r-- | ace/OS.i | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -7866,7 +7866,13 @@ ACE_OS::gethrtime (void) ACE_OS::clock_gettime (CLOCK_REALTIME, &ts); - return ts.tv_sec * ACE_ONE_SECOND_IN_NSECS + ts.tv_nsec; + // Carefully create the return value to avoid arithmetic overflow + // if ACE_hrtime_t is ACE_U_LongLong. + ACE_hrtime_t now = ts.tv_sec; + now *= (ACE_UINT32) ACE_ONE_SECOND_IN_NSECS; + now += ts.tv_nsec; + + return now; #else const ACE_Time_Value now = ACE_OS::gettimeofday (); return now.msec () * 1000000L /* Turn millseconds into nanoseconds */; |