Ticket #119 (closed defect)
Opened 3 years ago
Last modified 3 years ago
Visual Studio C++ doesn't have gettimeofday()
| Reported by: | anonymous | Owned by: | bagder |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | misc | Version: | |
| Keywords: | Cc: | bagder, em1, roadrunn | |
| Blocked By: | Blocks: |
Description
libssh2 cannot be compiled by Visual Studio C++ with LIBSSH2DEBUG defined as gettimeofday() is not supported by Visual Studio C++ ( (I tried 2003 and 200) .
Change History
comment:1 Changed 3 years ago by anonymous
comment:2 Changed 3 years ago by em1
Here's a fix:
--- misc.c.orig 2009-05-14 17:00:34.000000000 +0200
+++ misc.c 2009-09-23 15:38:50.000000000 +0200
@@ -318,7 +318,12 @@
char buffer[1536];
int len;
va_list vargs;
+#ifdef WIN32
+ struct { int tv_sec, tv_usec; } now;
+ DWORD t;
+#else
struct timeval now;
+#endif
static int firstsec;
static const char *const contexts[9] = {
"Unknown",
@@ -339,7 +344,13 @@
/* no such output asked for */
return;
}
+#ifdef WIN32
+ t = timeGetTime ();
+ now.tv_sec = t / 1000;
+ now.tv_usec = (t % 1000) * 1000;
+#else
gettimeofday(&now, NULL);
+#endif
if(!firstsec) {
firstsec = now.tv_sec;
}
comment:3 Changed 3 years ago by anonymous
Note that timeGetTime() needs Winmm.lib.
comment:4 Changed 3 years ago by roadrunn
An alternative fix was checked into git 3 days ago and is in the git daily snapshots from September 20th and later.
comment:5 Changed 3 years ago by bagder
Exactly, this problem is already fixed in git. Case closed!

This is version 1.2 of libssh2.