#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
+#include <math.h>
// For realpath
#include <limits.h>
getCyclePerNsec(tf);
- tf->overflow_nsec = (-((double)(tf->a_block_start->cycle_count&0xFFFFFFFF))
- * tf->nsec_per_cycle);
+ tf->overflow_nsec = round(
+ (-((double)(tf->a_block_start->cycle_count&0xFFFFFFFF))
+ * tf->nsec_per_cycle));
tf->current_event_time = getEventTime(tf);
tf->prev_event_time.tv_nsec = 0;
tf->count = 0;
- tf->overflow_nsec = (-((double)tf->a_block_start->cycle_count)
- * tf->nsec_per_cycle);
+ tf->overflow_nsec = round((-((double)tf->a_block_start->cycle_count)
+ * tf->nsec_per_cycle));
}
t->nsec_per_cycle = (double)lBufTotalNSec / (double)lBufTotalCycle;
/* Pre-multiply one overflow (2^32 cycles) by nsec_per_cycle */
- t->one_overflow_nsec = t->nsec_per_cycle * (double)0x100000000ULL;
+ t->one_overflow_nsec = round(t->nsec_per_cycle * (double)0x100000000ULL);
}
if(unlikely(evId == TRACE_BLOCK_START)) {
lEventNSec = 0;
} else if(unlikely(evId == TRACE_BLOCK_END)) {
- lEventNSec = ((double)
+ lEventNSec = round(((double)
(tf->a_block_end->cycle_count - tf->a_block_start->cycle_count)
- * tf->nsec_per_cycle);
+ * tf->nsec_per_cycle));
}
#if 0
/* If you want to make heart beat a special case and use their own 64 bits
}
#endif //0
else {
- lEventNSec = (gint64)((double)cycle_count * tf->nsec_per_cycle)
+ lEventNSec = (gint64)round(((double)cycle_count * tf->nsec_per_cycle))
+tf->overflow_nsec;
}