prepare v1.1.4
[awesomized/libmemcached] / src / p9y / p9y.cpp
index 1c5c4ac982206582f005fae8d5319d02c3cd654a..4716bfbd8760460a685dc578f93062006fad03cf 100644 (file)
@@ -1,6 +1,7 @@
 #include "libgen.hpp"
 #if defined P9Y_NEED_BASENAME
 # if defined _WIN32
+# include <cstring>
 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