Use fixed value of DILL_RDTSC_DIFF
#if defined(__x86_64__) || defined(__i386__)
#include <x86intrin.h>
+
+#define DILL_RDTSC_DIFF 1000000ULL
#endif
#include "cr.h"
#include "pollset.h"
#include "utils.h"
-static __attribute__((noinline)) uint64_t dill_now_measure(void) {
- uint64_t start_rdtsc = __rdtsc();
- usleep(100);
- uint64_t stop_rdtsc = __rdtsc();
- int64_t diff_rdtsc = stop_rdtsc - start_rdtsc;
- if(diff_rdtsc < 0) diff_rdtsc = -diff_rdtsc;
- return diff_rdtsc * 5;
-}
-
static int64_t mnow(void) {
#if defined __APPLE__
static mach_timebase_info_data_t dill_mtid = {0};
@@ -84,12 +77,10 @@ int64_t now(void) {
#if defined(__x86_64__) || defined(__i386__)
static int64_t last_tick = 0;
static uint64_t last_rdtsc = 0;
- static uint64_t rdtsc_diff = 0ULL;
uint64_t rdtsc = __rdtsc();
int64_t diff = rdtsc - last_rdtsc;
- if(dill_slow(!rdtsc_diff)) rdtsc_diff = dill_now_measure();
if(diff < 0) diff = -diff;
- if(dill_fast(diff < rdtsc_diff))
+ if(dill_fast(diff < DILL_RDTSC_DIFF))
return last_tick;
else
last_rdtsc = rdtsc;
