Updates from HEAD
[openssl.git] / crypto / bio / bss_dgram.c
index 2717d77956f8fe17c5fea5afbf005124f4f1944f..9d2b78d3a285a10d4ad7135f390c0c6eac5ce306 100644 (file)
 
 #include <stdio.h>
 #include <errno.h>
+#include <sys/time.h>
 #define USE_SOCKETS
 #include "cryptlib.h"
 
 #include <openssl/bio.h>
 
+#ifdef OPENSSL_SYS_WIN32
+#include <sys/timeb.h>
+#endif
+
 #define IP_MTU      14 /* linux is lame */
 
 #ifdef WATT32
@@ -204,11 +209,12 @@ static int dgram_read(BIO *b, char *out, int outl)
                        {
                        if (data->hstimeout.tv_sec > 0 || data->hstimeout.tv_usec > 0)
                                {
+                               struct timeval curtime;
 #ifdef OPENSSL_SYS_WIN32
-                               struct timeb tb;
-                               ftime(&tb);
-                               curtime.tv_sec = tb.time;
-                               curtime.tv_usec = tb.millitm * 1000;
+                               struct _timeb tb;
+                               _ftime(&tb);
+                               curtime.tv_sec = (long)tb.time;
+                               curtime.tv_usec = (long)tb.millitm * 1000;
 #else
                                gettimeofday(&curtime, NULL);
 #endif
@@ -374,10 +380,10 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
                if (num > 0)
                        {
 #ifdef OPENSSL_SYS_WIN32
-                       struct timeb tb;
-                       ftime(&tb);
-                       data->hstimeout.tv_sec = tb.time;
-                       data->hstimeout.tv_usec = tb.millitm * 1000;
+                       struct _timeb tb;
+                       _ftime(&tb);
+                       data->hstimeout.tv_sec = (long)tb.time;
+                       data->hstimeout.tv_usec = (long)tb.millitm * 1000;
 #else
                        gettimeofday(&(data->hstimeout), NULL);
 #endif