From 11dbdfca4df8ed87535359411b37a23818326b3c Mon Sep 17 00:00:00 2001 From: Roland Schwarz Date: Mon, 2 Oct 2006 09:45:28 +0000 Subject: [PATCH] added assertions around gettimeofday and clock_gettime [SVN r35439] --- src/xtime.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/xtime.cpp b/src/xtime.cpp index 0732cf43..0ae854ff 100644 --- a/src/xtime.cpp +++ b/src/xtime.cpp @@ -22,6 +22,8 @@ # include #endif +#include + namespace boost { #ifdef BOOST_HAS_MPTASKS @@ -106,13 +108,23 @@ int xtime_get(struct xtime* xtp, int clock_type) return clock_type; #elif defined(BOOST_HAS_GETTIMEOFDAY) struct timeval tv; +# ifndef NDEBUG + int res = +#endif gettimeofday(&tv, 0); + assert(0 == res); + assert(tv.tv_sec >= 0); + assert(tv.tv_usec >= 0); xtp->sec = tv.tv_sec; xtp->nsec = tv.tv_usec * 1000; return clock_type; #elif defined(BOOST_HAS_CLOCK_GETTIME) timespec ts; +# ifndef NDEBUG + int res = +# endif clock_gettime(CLOCK_REALTIME, &ts); + assert(0 == res); xtp->sec = ts.tv_sec; xtp->nsec = ts.tv_nsec; return clock_type;