| 1158 | volatile uint64_t now; |
| 1159 | static std::atomic<pthread_t> ts_updater(0); |
| 1160 | static inline uint64_t update_now() |
| 1161 | { |
| 1162 | #if defined(__x86_64__) && defined(__linux__) && defined(ENABLE_MIMIC_VDSO) |
| 1163 | if (likely(__mimic_vdso_time_x86)) |
| 1164 | return photon::now = __mimic_vdso_time_x86.get_now(); |
| 1165 | #endif |
| 1166 | struct timespec tv; |
| 1167 | #ifdef CLOCK_BOOTTIME |
| 1168 | clock_gettime(CLOCK_BOOTTIME, &tv); |
| 1169 | #else |
| 1170 | clock_gettime(CLOCK_MONOTONIC, &tv); |
| 1171 | #endif |
| 1172 | auto _now = tv.tv_sec * 1000ul * 1000ul + tv.tv_nsec / 1000ul; |
| 1173 | now = _now; // can not ```return now = ...;``` in debug |
| 1174 | return _now; // mode because ```now``` is a volatile variable |
| 1175 | } |
| 1176 | __attribute__((always_inline)) |
| 1177 | static inline uint32_t _rdtsc() |
| 1178 | { |