From: Danny Mayer Date: Sun, 18 Mar 2007 06:35:16 +0000 (-0400) Subject: Bug #787 Bug fixes for 64-bit time_t on Windows X-Git-Tag: NTP_4_2_5P20~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bbae7afea1c6e4e1f36582c10ec007d274901cb;p=thirdparty%2Fntp.git Bug #787 Bug fixes for 64-bit time_t on Windows bk: 45fcdda4J6k_zlTBAzEJeTywesGvwQ --- diff --git a/ports/winnt/include/config.h b/ports/winnt/include/config.h index 43f3fc0fe..ad3c98a90 100644 --- a/ports/winnt/include/config.h +++ b/ports/winnt/include/config.h @@ -25,9 +25,34 @@ typedef int socklen_t; /* VS 6.0 doesn't know about socklen_t */ typedef unsigned int uintptr_t; #endif +#if _MSC_VER < 1400 +/* + * Use 32-bit time definitions for versions prior to VS 2005 + * VS 2005 defaults to 64-bit time + */ +# define SIZEOF_TIME_T 4 +#else +# define SIZEOF_TIME_T 8 +#endif + #define ISC_PLATFORM_NEEDIN6ADDRANY #define HAVE_SOCKADDR_IN6 +/* + * VS 2005 deprecates a number of standard functions + * Set up the compiler to automatically replace them. + * Note that these are ignored by previous versions + * of the compiler + */ +#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES +#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT +#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1 +#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1 +#define _CRT_SECURE_NO_DEPRECATE 1 + + + + /* * The type of the socklen_t defined for getnameinfo() and getaddrinfo() * is int for VS compilers on Windows but the type is already declared @@ -91,12 +116,6 @@ typedef unsigned int uintptr_t; * Multimedia timer enable */ #define USE_MM_TIMER -/* - * Use 32-bit time definitions - * VS 2005 defaults to 64-bit time - * Leave commented out for now - */ -//#define _USE_32BIT_TIME_T /* Enable OpenSSL */ #define OPENSSL 1 @@ -178,7 +197,6 @@ int NT_set_process_priority(void); /* Define this function */ # define SYSV_TIMEOFDAY /* for ntp_unixtime.h */ # define SIZEOF_SIGNED_CHAR 1 -# define SIZEOF_TIME_T 4 # define SIZEOF_INT 4 /* for ntp_types.h */ //# define HAVE_NET_IF_H diff --git a/ports/winnt/include/ntp_timer.h b/ports/winnt/include/ntp_timer.h index b8c40309f..7649bafd9 100644 --- a/ports/winnt/include/ntp_timer.h +++ b/ports/winnt/include/ntp_timer.h @@ -1,10 +1,10 @@ #if !defined(__NTP_TIMER_H_) #define __NTP_TIMER_H_ -extern void timer_clr_stats P((void)); +extern void timer_clr_stats(void); #if defined(SYS_WINNT) -extern HANDLE get_timer_handle P((void)); +extern HANDLE get_timer_handle(void); #endif diff --git a/ports/winnt/libntp/SetSystemTime.c b/ports/winnt/libntp/SetSystemTime.c index e3e11ee1a..1465719ce 100644 --- a/ports/winnt/libntp/SetSystemTime.c +++ b/ports/winnt/libntp/SetSystemTime.c @@ -12,11 +12,11 @@ ntp_set_tod( { SYSTEMTIME st; struct tm *gmtm; - long x = tv->tv_sec; + const time_t x = tv->tv_sec; long y = tv->tv_usec; (void) tzp; - gmtm = gmtime((const time_t *) &x); + gmtm = gmtime(&x); st.wSecond = (WORD) gmtm->tm_sec; st.wMinute = (WORD) gmtm->tm_min; st.wHour = (WORD) gmtm->tm_hour;