X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fp9y%2Fp9y.cpp;h=4716bfbd8760460a685dc578f93062006fad03cf;hb=2aab18117a2b078dd0eb366f3766a1fef06da695;hp=1c5c4ac982206582f005fae8d5319d02c3cd654a;hpb=7781e7d0bf9fc0d986308838a3e1e47d0df3c019;p=awesomized%2Flibmemcached diff --git a/src/p9y/p9y.cpp b/src/p9y/p9y.cpp index 1c5c4ac9..4716bfbd 100644 --- a/src/p9y/p9y.cpp +++ b/src/p9y/p9y.cpp @@ -1,6 +1,7 @@ #include "libgen.hpp" #if defined P9Y_NEED_BASENAME # if defined _WIN32 +# include char *basename(const char *filename) { static char base[_MAX_PATH * 2], ext[_MAX_PATH], *ptr; (void) _splitpath_s(filename, NULL, 0, NULL, 0, base, _MAX_PATH, ext, _MAX_PATH); @@ -146,3 +147,27 @@ int poll(struct pollfd fds[], nfds_t nfds, int tmo) { return ret; } #endif // P9Y_NEED_POLL + +#include "clock_gettime.hpp" +#ifdef P9Y_NEED_CLOCK_GETTIME +# ifdef _WIN32 + +static inline __int64 wintime2unixtime(__int64 wintime) { + return wintime - 116444736000000000i64; +} + +int clock_gettime(int, struct timespec *spec) +{ + __int64 wintime, unixtime; + + GetSystemTimeAsFileTime((FILETIME*) &wintime); + unixtime = wintime2unixtime(wintime); + + + spec->tv_sec = unixtime / 10000000i64; + spec->tv_nsec = unixtime % 10000000i64 * 100; + + return 0; +} +# endif // _WIN32 +#endif // P9Y_NEED_CLOCK_GETTIME