#ifndef bl_time_h
#define bl_time_h
#include <stdint.h>
int64_t bl_time();
#endif
#include "bl_time.h"
#if defined(WIN32) && !defined(__cplusplus)
#define inline __inline
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <sys/time.h>
#endif
#ifdef WIN32
inline void set_low(int64_t* value, int low) {
*value &= (int64_t)0xffffffff << 32;
*value |= (int64_t)(uint64_t)(uint32_t)low;
}
inline void set_high(int64_t* value, int high) {
*value &= (int64_t)(uint64_t)(uint32_t)0xffffffff;
*value |= (int64_t)high << 32;
}
inline int64_t int64_t_from(int h, int l) {
int64_t result = 0;
set_high(&result, h);
set_low(&result, l);
return result;
}
static int64_t _offset = 116444736000000000;
int64_t offset() {
return _offset;
}
int64_t bl_time()
{
FILETIME wt;
GetSystemTimeAsFileTime(&wt);
return (int64_t_from(wt.dwHighDateTime, wt.dwLowDateTime) - offset()) / 10000;
}
#else
int64_t bl_time()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * (uint64_t)1000000 + tv.tv_usec;
}
#endif
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于