#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);
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