]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Bug #787 Bug fixes for 64-bit time_t on Windows
authorDanny Mayer <mayer@ntp.org>
Sun, 18 Mar 2007 06:35:16 +0000 (02:35 -0400)
committerDanny Mayer <mayer@ntp.org>
Sun, 18 Mar 2007 06:35:16 +0000 (02:35 -0400)
bk: 45fcdda4J6k_zlTBAzEJeTywesGvwQ

ports/winnt/include/config.h
ports/winnt/include/ntp_timer.h
ports/winnt/libntp/SetSystemTime.c

index 43f3fc0feb1a75a4d44c8c641daf36bfb328ea56..ad3c98a905e3aa6a6e8531dc2fe7a528777e7fad 100644 (file)
@@ -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
index b8c40309fd2384dca43cb13d2c83f8df6b2c2ae5..7649bafd9b5a2417e3bd3cf017fd368a792c7f78 100644 (file)
@@ -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
 
 
index e3e11ee1a76f6d951fd6fb49a93fc0b97a92af62..1465719ce9f06f4b2b55a91d1b39d8ea48426751 100644 (file)
@@ -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;