X-Git-Url: http://developer.intra2net.com/git/?a=blobdiff_plain;f=src%2Ftimefunc.cpp;fp=src%2Ftimefunc.cpp;h=6f4ffb5dbdfc6be0500fa88021f3a8bc1e0b580c;hb=4f1a78cac519d257c52cf3677175689b70f796c0;hp=a4d38b863a48310e7c1def0091ff1f81740d8c53;hpb=c3df2bda5837805d87bc2f8d6ff7c8bca8e1d6ff;p=libi2ncommon diff --git a/src/timefunc.cpp b/src/timefunc.cpp index a4d38b8..6f4ffb5 100644 --- a/src/timefunc.cpp +++ b/src/timefunc.cpp @@ -38,7 +38,6 @@ on this file might be covered by the GNU General Public License. #include #include #include -#include #include #include @@ -59,12 +58,17 @@ using namespace std; double prec_time(void) { - struct timeb tb; - double ret; + struct timespec ts = { 0 }; + double ret = 0.0; - ftime(&tb); + if (clock_gettime(CLOCK_REALTIME_COARSE, &ts) == -1) { + /* Something’s wrong on the kernel end! */ + return ret; + } - ret=tb.time+(static_cast(tb.millitm)/1000); + ret = static_cast(ts.tv_sec); + ret += static_cast(ts.tv_nsec) + / static_cast(TIME_CONST_FACTOR_NANO); return ret; }