summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-17 21:23:02 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-17 21:23:02 +0000
commit6e021697ae756d3957cb1deb153c91bdc7ab1ff4 (patch)
tree94184e08436c2678c0fd7c1f1ceb57e2cebcba86 /ace
parent60bef640626e02842baafd7623e51d7bec5dcec3 (diff)
downloadATCD-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.i8
1 files changed, 7 insertions, 1 deletions
diff --git a/ace/OS.i b/ace/OS.i
index 98905d05e02..1b5f6cd26c3 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -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 */;