From: Dave Hart Date: Tue, 17 Mar 2009 18:15:41 +0000 (+0000) Subject: config.h: X-Git-Tag: NTP_4_2_5P160~10^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bc6ab4fb110c9d6be223a4baae9791d3dcc6f73;p=thirdparty%2Fntp.git config.h: now works with VC6 and VC9 compilers, declares DWORD_PTR for VC6 bk: 49bfe8cdzLeYCm9TRrpin-URO2vYjw --- diff --git a/ports/winnt/include/config.h b/ports/winnt/include/config.h index 2a68fbbed..d91566251 100644 --- a/ports/winnt/include/config.h +++ b/ports/winnt/include/config.h @@ -4,64 +4,122 @@ #define __CONFIG_H /* - * IPv6 requirements + * we want newer prototypes from Windows so we target _WIN32_WINNT + * at WINXP, but we also want our binary to run on NT 4, so newer + * functions are runtime linked and the linker /version:0x0400 + * switch is used to override the .exe file minimum version. + * + * NOTE VC6 .dsw/.dsp files need to add /version:0x0400 to the link + * command lines, I've done it for VC9. Then remove these two lines. */ +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif + +#define _CRT_SECURE_NO_DEPRECATE 1 /* - * For VS.NET most of the IPv6 types and structures are defined + * ANSI C compliance enabled */ -#if _MSC_VER > 1200 -#define HAVE_STRUCT_SOCKADDR_STORAGE -#define ISC_PLATFORM_HAVEIPV6 -#define ISC_PLATFORM_HAVEIN6PKTINFO -#define NO_OPTION_NAME_WARNINGS -#else -typedef int socklen_t; /* VS 6.0 doesn't know about socklen_t */ +#define __STDC__ 1 + +/* + * We need to include string.h first before we override strerror + * otherwise we can get errors during the build + */ +#include + +/* + * We need to include stdio.h first before we #define snprintf + * otherwise we can get errors during the build + */ +#include + +/* Prevent inclusion of winsock.h in windows.h */ +#ifndef _WINSOCKAPI_ +#define _WINSOCKAPI_ #endif -#define HAVE_UINTPTR_T +#ifndef __RPCASYNC_H__ +#define __RPCASYNC_H__ +#endif /* - * Some types don't exist in VS V6 + * VS.NET's version of wspiapi.h has a bug in it + * where it assigns a value to a variable inside + * an if statement. It should be comparing them. + * We prevent inclusion since we are not using this + * code so we don't have to see the warning messages */ -#if _MSC_VER < 1300 -typedef unsigned int uintptr_t; +#ifndef _WSPIAPI_H_ +//#define _WSPIAPI_H_ // need these wrappers for ntpd.exe to load on w2k #endif -#if _MSC_VER < 1400 +/* Include Windows headers */ +#include +#include + /* - * Use 32-bit time definitions for versions prior to VS 2005 - * VS 2005 defaults to 64-bit time + * Some definitions we are using are missing in the headers + * shipping with VC6. However, if the SDK is installed then the + * SDK's headers may declare the missing types. This is at least + * the case in the Oct 2001 SDK. That SDK and all subsequent + * versions also define the symbol _W64, so we can use that one + * to determine whether some types need to be defined, or not. */ -# define SIZEOF_TIME_T 4 -#else -# define SIZEOF_TIME_T 8 +#ifdef _W64 +/* VC6 can include wspiapi.h only if the SDK is installed */ +#include #endif -#define ISC_PLATFORM_NEEDIN6ADDRANY -#define HAVE_SOCKADDR_IN6 +//#include /* must come after ws2tcpip.h */ +#undef interface +#include + +/* --------------------------------------------------------------------- + * Above this line are #include lines and the few #define lines + * needed before including headers. + */ /* - * 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 + * IPv6 requirements */ /* -#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES -#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT -#undef _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1 -#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 1 -#define _CRT_SECURE_NO_DEPRECATE 1 -*/ + * For VS.NET most of the IPv6 types and structures are defined. + * This should depend on the contrents of the available headers, + * not on the compiler version. + */ +#if defined _MSC_VER && _MSC_VER > 1200 +#define HAVE_STRUCT_SOCKADDR_STORAGE +#define ISC_PLATFORM_HAVEIPV6 +#define ISC_PLATFORM_HAVEIN6PKTINFO +#define NO_OPTION_NAME_WARNINGS +#endif +#ifndef _W64 +/* VC6 doesn't know about socklen_t, except if the SDK is installed */ +typedef int socklen_t; +#endif +#define ISC_PLATFORM_NEEDIN6ADDRANY +#define HAVE_SOCKADDR_IN6 /* * The type of the socklen_t defined for getnameinfo() and getaddrinfo() - * is int for VS compilers on Windows but the type is already declared + * is int for VS compilers on Windows but the type is already declared */ #define GETSOCKNAME_SOCKLEN_TYPE socklen_t + +#if defined _MSC_VER && _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 + + /* * An attempt to cut down the number of warnings generated during compilation. * All of these should be benign to disable. @@ -70,6 +128,7 @@ typedef unsigned int uintptr_t; #pragma warning(disable: 4100) /* unreferenced formal parameter */ #pragma warning(disable: 4101) /* unreferenced local variable */ #pragma warning(disable: 4127) /* conditional expression is constant */ +#pragma warning(disable: 4996) /* more secure replacement available */ /* * Windows NT Configuration Values @@ -77,42 +136,21 @@ typedef unsigned int uintptr_t; #if defined _DEBUG /* Use VC standard macro definitions */ # define DEBUG 1 #endif -#if !defined _WIN32_WINNT || _WIN32_WINNT < 0x0400 -# error Please define _WIN32_WINNT in the project settings/makefile -#endif #define __windows__ 1 -/* - * ANSI C compliance enabled - */ -#define __STDC__ 1 /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 -/* Prevent inclusion of winsock.h in windows.h */ -#ifndef _WINSOCKAPI_ -#define _WINSOCKAPI_ -#endif - -#ifndef __RPCASYNC_H__ -#define __RPCASYNC_H__ -#endif - -/* - * VS.NET's version of wspiapi.h has a bug in it - * where it assigns a value to a variable inside - * an if statement. It should be comparing them. - * We prevent inclusion since we are not using this - * code so we don't have to see the warning messages +/* + * FORCE_DNSRETRY will allow associations to come up later + * if DNS isn't available at first. See bug #1117. */ -#ifndef _WSPIAPI_H_ -#define _WSPIAPI_H_ -#endif +#define FORCE_DNSRETRY 1 #define OPEN_BCAST_SOCKET 1 /* for ntp_io.c */ -#define TYPEOF_IP_MULTICAST_LOOP BOOL +#define TYPEOF_IP_MULTICAST_LOOP BOOL #define SETSOCKOPT_ARG_CAST (const char *) -#define HAVE_RANDOM +#define HAVE_RANDOM #define MAXHOSTNAMELEN 64 #define AUTOKEY @@ -125,38 +163,46 @@ typedef unsigned int uintptr_t; #define OPENSSL 1 /* - * Include standard stat information + * Keywords and functions that Microsoft maps + * to other names */ -#include +#define inline __inline +#define vsnprintf _vsnprintf +#define snprintf _snprintf +#define stricmp _stricmp +#define strcasecmp _stricmp +#define isascii __isascii +#define finite _finite +#define random rand +#define srandom srand +#define fdopen _fdopen +#define read _read +#define open _open +#ifndef close +#define close _close +#endif +#define write _write +#define strdup _strdup +#define stat _stat /*struct stat from */ +#define unlink _unlink /* - * Miscellaneous functions that Microsoft maps - * to other names + * punt on fchmod on Windows */ -#define inline __inline -#define vsnprintf _vsnprintf -#define snprintf _snprintf -#define stricmp _stricmp -#define strcasecmp _stricmp -#define isascii __isascii -#define finite _finite -#define random rand -#define srandom srand -#define fdopen _fdopen -#define read _read -#define open _open -#define close _close -#define write _write -#define strdup _strdup -#define stat _stat /* struct stat from */ -#define unlink _unlink -#define fchmod( _x, _y ); -#define lseek _lseek -#define pipe _pipe -#define dup2 _dup2 -#define sleep(x) Sleep((DWORD) x * 1000 /* milliseconds */ ); - -#define pid_t int /* PID is an int */ -#define ssize_t int /* ssize is an int */ +#define fchmod(x,y) {} +#define lseek _lseek +#define pipe _pipe +#define dup2 _dup2 +/* + * scale, unix sleep is seconds, Windows Sleep is msec + */ +#define sleep(x) Sleep((unsigned)(x) * 1000) +#define fileno _fileno +#define isatty _isatty +#define mktemp _mktemp +#define getpid _getpid + +typedef int pid_t; /* PID is an int */ +typedef int ssize_t; /* ssize is an int */ typedef __int32 int32_t; /* define a typedef for int32_t */ #define HAVE_INT32_T 1 @@ -166,14 +212,8 @@ typedef __int32 int32_t; /* define a typedef for int32_t */ #define STDOUT_FILENO _fileno(stdout) #define STDERR_FILENO _fileno(stderr) -/* - * We need to include string.h first before we override strerror - * otherwise we can get errors during the build - */ -#include /* Point to a local version for error string handling */ # define strerror NTstrerror - char *NTstrerror(int errnum); int NT_set_process_priority(void); /* Define this function */ @@ -184,8 +224,10 @@ int NT_set_process_priority(void); /* Define this function */ # define REFCLOCK /* from ntpd.mak */ # define CLOCK_LOCAL /* from ntpd.mak */ -//# define CLOCK_PARSE +/* # define CLOCK_PARSE */ /* # define CLOCK_ATOM */ +/* # define HAVE_TIMEPPS_H */ +/* # define HAVE_PPSAPI */ /* # define CLOCK_SHM */ /* from ntpd.mak */ # define CLOCK_HOPF_SERIAL /* device 38, hopf DCF77/GPS serial line receiver */ # define CLOCK_HOPF_PCI /* device 39, hopf DCF77/GPS PCI-Bus receiver */ @@ -202,10 +244,9 @@ int NT_set_process_priority(void); /* Define this function */ # define SYSLOG_FILE /* from libntp.mak */ # define SYSV_TIMEOFDAY /* for ntp_unixtime.h */ -# define SIZEOF_SIGNED_CHAR 1 -# define SIZEOF_INT 4 /* for ntp_types.h */ +# define SIZEOF_SIGNED_CHAR 1 +# define SIZEOF_INT 4 /* for ntp_types.h */ -//# define HAVE_NET_IF_H # define QSORT_USES_VOID_P # define HAVE_SETVBUF # define HAVE_VSPRINTF @@ -224,30 +265,111 @@ int NT_set_process_priority(void); /* Define this function */ # define ISC_PLATFORM_NEEDPTON # define HAVE_VPRINTF -#define HAVE_LIMITS_H 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_FCNTL_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_FCNTL_H 1 +#ifndef _INTPTR_T_DEFINED +typedef long intptr_t; +#define _INTPTR_T_DEFINED +#endif +#define HAVE_INTPTR_T -# define NEED_S_CHAR_TYPEDEF +#ifndef _UINTPTR_T_DEFINED +typedef unsigned long uintptr_t; +#define _UINTPTR_T_DEFINED +#endif +#define HAVE_UINTPTR_T + +#if !defined( _W64 ) + /* + * if DWORD_PTR needs to be defined then the build environment + * is pure 32 bit Windows. Since DWORD_PTR and DWORD have + * the same size in 32 bit Windows we can safely define + * a replacement. + */ + typedef DWORD DWORD_PTR; +#endif -# define USE_PROTOTYPES /* for ntp_types.h */ +#define NEED_S_CHAR_TYPEDEF + +#define USE_PROTOTYPES /* for ntp_types.h */ /* Directory separator, usually / or \ */ -#define DIR_SEP '\\' +#define DIR_SEP '\\' + #define ULONG_CONST(a) a ## UL -# define NOKMEM -# define RETSIGTYPE void -# ifndef STR_SYSTEM -# define STR_SYSTEM "WINDOWS/NT" -# endif +#define NOKMEM +#define RETSIGTYPE void + +#ifndef STR_SYSTEM +#define STR_SYSTEM "Windows" +#endif + +#ifndef STR_PROCESSOR + +#define STRINGIZE(arg) #arg + +#ifdef _M_IX86 +#ifndef _M_IX86_FP +#define STR_PROCESSOR "x86" +#else +#if !_M_IX86_FP +#define STR_PROCESSOR "x86" +#else +#if _M_IX86_FP > 2 +#define STR_PROCESSOR "x86-FP-" STRINGIZE(_M_IX86_FP) +#else +#if _M_IX86_FP == 2 +#define STR_PROCESSOR "x86-SSE2" +#else +#define STR_PROCESSOR "x86-SSE" +#endif /* _M_IX86 == 2 */ +#endif /* _M_IX86_FP > 2 */ +#endif /* !_M_IX86_FP */ +#endif /* !defined(_M_IX86_FP) */ +#endif /* !defined(_M_IX86) */ + +#ifdef _M_IA64 +#define STR_PROCESSOR "Itanium" +#endif + +#ifdef _M_X64 +#define STR_PROCESSOR "x64" +#endif + +#endif /* !defined(STR_PROCESSOR) */ + #define SIOCGIFFLAGS SIO_GET_INTERFACE_LIST /* used in ntp_io.c */ -/* Include Windows headers */ -#include -#include +/* + * _beginthreadex takes sames args as CreateThread but + * initializes per-thread CRT state before invoking the + * thread function, and calls _endthreadex on its + * return instead of ExitThread. _MSC_VER 1200 is VC6, + * it probably goes back further so the test might + * need changing if someone builds with ancient MSC. + */ +#if !defined(_MSC_VER) || (_MSC_VER < 1200) +#define _beginthreadex CreateThread +#define _endthreadex ExitThread +#endif + +/* + * Below this line are includes which must happen after the bulk of + * config.h is processed. If you need to add another #include to this + * file the preferred location is near the top, above the similar + * line of hyphens. + * --------------------------------------------------------------------- + */ + +/* + * Include standard stat information + */ +#include +#include -#endif /* __config */ +#endif /* __CONFIG_H */