diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-12-01 16:57:49 +0100 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-12-01 16:57:49 +0100 |
commit | f83f837de7ca51306a538e6b5185d231193a30f0 (patch) | |
tree | 00f96b63fbdc92979873119577e366558e42bc5c /libssh/misc.c | |
parent | 48b719cf68db72f77a650e235ffa87bdd925ed6b (diff) | |
download | libssh-f83f837de7ca51306a538e6b5185d231193a30f0.tar.gz libssh-f83f837de7ca51306a538e6b5185d231193a30f0.tar.xz libssh-f83f837de7ca51306a538e6b5185d231193a30f0.zip |
Added gettimeofday for Windows.
Thanks to Patrick Spendrin.
Diffstat (limited to 'libssh/misc.c')
-rw-r--r-- | libssh/misc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libssh/misc.c b/libssh/misc.c index 63ba946..f2bd5ed 100644 --- a/libssh/misc.c +++ b/libssh/misc.c @@ -95,6 +95,22 @@ char *ssh_get_user_home_dir(void) { return 1; } + +#define SSH_USEC_IN_SEC 1000000LL +#define SSH_SECONDS_SINCE_1601 11644473600LL + +int gettimeofday(struct timeval *__p, void *__t) { + union { + unsigned long long ns100; /* time since 1 Jan 1601 in 100ns units */ + FILETIME ft; + } now; + + GetSystemTimeAsFileTime (&now.ft); + __p->tv_usec = (long) ((now.ns100 / 10LL) % SSH_USEC_IN_SEC); + __p->tv_sec = (long)(((now.ns100 / 10LL ) / SSH_USEC_IN_SEC) - SSH_SECONDS_SINCE_1601); + + return (0); +} #else /* _WIN32 */ char *ssh_get_user_home_dir(void) { char *szPath = NULL; |