From 6cf657ac72a8ace3ccf88d12a32e6507a164ba11 Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 3 Mar 2010 17:26:57 +0000 Subject: Use static_cast if using std::time-based get_nanoseconds_clock to make it obvious that truncation is occuring. Something to deal with in 2038 I guess, though get_nanoseconds_clock is already an unknown/unspecified epoch (since the Windows timer uses 1/1/1601 as the epoch) --- src/utils/time.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/utils/time.cpp b/src/utils/time.cpp index fe4521706..0dbbd5e9c 100644 --- a/src/utils/time.cpp +++ b/src/utils/time.cpp @@ -1,6 +1,6 @@ /** * Time Functions -* (C) 1999-2009 Jack Lloyd +* (C) 1999-2010 Jack Lloyd * * Distributed under the terms of the Botan license */ @@ -93,11 +93,13 @@ calendar_point calendar_value(u64bit a_time_t) u64bit get_nanoseconds_clock() { #if defined(BOTAN_TARGET_OS_HAS_CLOCK_GETTIME) + struct ::timespec tv; ::clock_gettime(CLOCK_REALTIME, &tv); return combine_timers(tv.tv_sec, tv.tv_nsec, 1000000000); #elif defined(BOTAN_TARGET_OS_HAS_GETTIMEOFDAY) + struct ::timeval tv; ::gettimeofday(&tv, 0); return combine_timers(tv.tv_sec, tv.tv_usec, 1000000); @@ -113,7 +115,9 @@ u64bit get_nanoseconds_clock() return (tstamp * 100); // Scale to 1 nanosecond units #else - return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC); + + return combine_timers(static_cast(std::time(0)), + std::clock(), CLOCKS_PER_SEC); #endif } -- cgit v1.2.3