2 * ports/winnt/include/config.h - static Windows config.h
4 * On most systems config.h is generated by the configure script.
5 * For the Windows port, it's hand-maintained. Compilers earlier
6 * than Visual C++ 2005 are no longer supported, enabling
7 * portable use of "long long" and "%lld".
14 * Known predifined MS compiler version codes:
15 * 1800: MSVC++ 12.0 (Visual Studio 2013)
16 * 1700: MSVC++ 11.0 (Visual Studio 2012)
17 * 1600: MSVC++ 10.0 (Visual Studio 2010)
18 * 1500: MSVC++ 9.0 (Visual Studio 2008)
19 * 1400: MSVC++ 8.0 (Visual Studio 2005)
20 * 1310: MSVC++ 7.1 (Visual Studio 2003)
22 * 1200: MSVC++ 6.0 (Visual C++ 6)
26 #if defined(_MSC_VER) && _MSC_VER < 1400
27 #error Minimum supported Microsoft compiler is Visual C++ 2005.
31 * We want structures and prototypes added after Windows NT 4.0 exposed
32 * by Windows header files, so we define _WIN32_WINNT to target Windows
33 * XP (version 5.1). By default, _WIN32_WINNT also controls the minimum
34 * required Windows version to launch the .exe. As we want a single
35 * binary to work on all supported Windows versions, we runtime link
36 * newer functions, and use the linker /version:0x0400 option to
37 * override the .EXE header minimum Windows version.
39 * When using the VC++ 2008 and later compilers, the resulting binaries
40 * will not work on versions earlier than Windows XP, due to runtime
41 * library dependencies. That is, Visual C++ 2005 is the last version
42 * capable of producing binaries usable with Windows NT 4 and 2000.
45 #define _WIN32_WINNT 0x0501
48 #define __attribute__(x) /* empty */
49 #define _CRT_SECURE_NO_DEPRECATE 1
52 * ANSI C compliance enabled
57 * Enable the debug build of MS C runtime to dump leaks
58 * at exit time (currently only if run under a debugger).
60 #if defined(_MSC_VER) && defined(_DEBUG)
61 # define _CRTDBG_MAP_ALLOC
65 /* # define MALLOC_LINT */ /* defers free() */
66 # define EREALLOC_IMPL(ptr, newsz, filenm, loc) \
67 _realloc_dbg(ptr, newsz, _NORMAL_BLOCK, filenm, loc)
71 * We need to include stdio.h first before we #define snprintf
72 * otherwise we can get errors during the build
76 /* Prevent inclusion of winsock.h in windows.h */
81 #ifndef __RPCASYNC_H__
82 #define __RPCASYNC_H__
86 * On Unix struct sock_timeval is equivalent to struct timeval.
87 * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long
88 * as required by Windows' socket() interface timeout argument, while
89 * timeval.tv_sec is time_t for the more common use as a UTC time
92 * winsock.h unconditionally defines struct timeval with long tv_sec
93 * instead of time_t tv_sec. We redirect its declaration to struct
94 * sock_timeval instead of struct timeval with a #define.
96 #define timeval sock_timeval
98 /* Include Windows headers */
100 #include <winsock2.h>
101 #include <ws2tcpip.h>
103 #undef timeval /* see sock_timeval #define and comment above */
106 * Some definitions we are using are missing in the headers
107 * shipping with VC6. However, if the SDK is installed then the
108 * SDK's headers may declare the missing types. This is at least
109 * the case in the Oct 2001 SDK. That SDK and all subsequent
110 * versions also define the symbol _W64, so we can use that one
111 * to determine whether some types need to be defined, or not.
114 /* VC6 can include wspiapi.h only if the SDK is installed */
120 #include <time.h> /* time_t for timeval decl */
122 #include <isc/strerror.h>
124 /* ---------------------------------------------------------------------
125 * Above this line are #include lines and the few #define lines
126 * needed before including headers.
135 * ntohl and friends are actual functions on Windows, use our own
136 * macros instead to save the function call overhead. All releases
137 * of Windows are little-endian.
140 #error ntohl is already defined in ports/winnt/include/config.h
142 #define ntohl(ul) (((u_long)(ul) & 0xff) << 24 | \
143 ((u_long)(ul) & 0xff00) << 8 | \
144 ((u_long)(ul) & 0xff0000) >> 8 | \
145 ((u_long)(ul) & 0xff000000) >> 24)
146 #define htonl(ul) ntohl(ul)
147 #define ntohs(us) ((u_short) \
148 (((u_short)(us) & 0xff) << 8 | \
149 ((u_short)(us) & 0xff00) >> 8))
150 #define htons(us) ntohs(us)
154 * On Unix open() works for tty (serial) devices just fine, while on
155 * Windows refclock serial devices are opened using CreateFile, a lower
156 * level than the CRT-provided descriptors, because the C runtime lacks
157 * tty APIs. For refclocks which wish to use open() as well as or
158 * instead of refclock_open(), tty_open() is equivalent to open() on
159 * Unix and implemented in the Windows port similarly to
162 extern int tty_open(const char *, int, int);
165 * disable use of __declspec(dllexport) by libisc routines
167 #define ISC_STATIC_WIN 1
170 * ntp_rfc2553.h has cruft under #ifdef SYS_WINNT which is
171 * appropriate for older Microsoft IPv6 definitions, such
172 * as in_addr6 being the struct type. We can differentiate
173 * the RFC2553-compliant newer headers because they have
174 * #define in_addr6 in6_addr
175 * for backward compatibility. With the newer headers,
176 * we define ISC_PLATFORM_HAVEIPV6 and disable the cruft.
180 #define ISC_PLATFORM_HAVEIPV6
181 #define ISC_PLATFORM_HAVESCOPEID
182 #define HAVE_STRUCT_SOCKADDR_STORAGE
183 #define ISC_PLATFORM_HAVEIN6PKTINFO
184 #endif /* in_addr6 / RFC2553-compliant IPv6 headers */
186 #define NO_OPTION_NAME_WARNINGS
190 * if ULONG_PTR needs to be defined then the build environment
191 * is pure 32 bit Windows. Since ULONG_PTR and DWORD have
192 * the same size in 32 bit Windows we can safely define
195 typedef DWORD ULONG_PTR;
196 /* VC6 doesn't know about socklen_t, except if the SDK is installed */
197 typedef int socklen_t;
200 #define ISC_PLATFORM_NEEDIN6ADDRANY
201 #define HAVE_SOCKADDR_IN6
204 * The type of the socklen_t defined for getnameinfo() and getaddrinfo()
205 * is int for VS compilers on Windows but the type is already declared
207 #define GETSOCKNAME_SOCKLEN_TYPE socklen_t
210 * Older SDKs do not define SO_EXCLUSIVEADDRUSE in winsock2.h
212 #ifndef SO_EXCLUSIVEADDRUSE
213 #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
216 #if defined _MSC_VER && _MSC_VER < 1400
218 * Use 32-bit time definitions for versions prior to VS 2005
219 * VS 2005 defaults to 64-bit time
221 # define SIZEOF_TIME_T 4
223 # define SIZEOF_TIME_T 8
228 * An attempt to cut down the number of warnings generated during compilation.
229 * All of these should be benign to disable.
232 #pragma warning(disable: 4100) /* unreferenced formal parameter */
233 #pragma warning(disable: 4127) /* conditional expression is constant */
234 #pragma warning(disable: 4996) /* more secure replacement available */
237 * Windows NT Configuration Values
239 #if defined _DEBUG /* Use VC standard macro definitions */
243 #define __windows__ 1
244 /* Define if you have the ANSI C header files. */
245 #define STDC_HEADERS 1
247 #define OPEN_BCAST_SOCKET 1 /* for ntp_io.c */
248 #define TYPEOF_IP_MULTICAST_LOOP BOOL
249 #define SETSOCKOPT_ARG_CAST (const char *)
254 * Multimedia timer enable
258 /* check for OpenSSL */
260 # define USE_OPENSSL_CRYPTO_RAND 1
263 extern void arc4random_buf(void *buf, size_t nbytes);
266 * Keywords and functions that Microsoft maps
269 #define inline __inline
270 #define stricmp _stricmp
271 #define strcasecmp _stricmp
272 #define isascii __isascii
273 #define finite _finite
275 #define srandom srand
276 #define fdopen _fdopen
283 #define strdup _strdup
284 #define alloca _alloca
285 #define stat _stat /*struct stat from <sys/stat.h> */
287 #define unlink _unlink
289 * punt on fchmod on Windows
291 #define fchmod(x,y) {}
296 * scale, unix sleep is seconds, Windows Sleep is msec
298 #define sleep(x) Sleep((unsigned)(x) * 1000)
299 #define fileno _fileno
300 #define isatty _isatty
301 #define mktemp _mktemp
302 #define getpid _getpid
303 #define timegm _mkgmtime
304 #define errno_to_str isc__strerror
306 * symbol returning the name of the current function
308 #define __func__ __FUNCTION__
310 typedef int pid_t; /* PID is an int */
311 typedef int ssize_t; /* ssize is an int */
314 * Map the stream to the file number
316 #define STDOUT_FILENO _fileno(stdout)
317 #define STDERR_FILENO _fileno(stderr)
320 * To minimize Windows-specific changes to the rest of the NTP code,
321 * particularly reference clocks, ntp_stdlib.h will
323 * #define strerror(e) ntp_strerror(e)
325 * to deal with our mixture of C runtime (open, write) and Windows
326 * (sockets, serial ports) error codes. This is an ugly hack because
327 * both use the lowest values differently, but particularly for ntpd,
328 * it's not a problem.
330 #define NTP_REDEFINE_STRERROR
332 #define MCAST /* Enable Multicast Support */
333 #define MULTICAST_NONEWSOCKET /* Don't create a new socket for mcast address */
335 # define REFCLOCK /* from ntpd.mak */
337 /* #define CLOCK_PARSE */
339 #define CLOCK_ARBITER
340 #define CLOCK_ARCRON_MSF
341 #define OWN_PPS_NTP_TIMESTAMP_FROM_COUNTER /* timepps.h */
342 #define HAVE_TIMEPPS_H
346 #define CLOCK_CHRONOLOG
347 #define CLOCK_DUMBCLOCK
348 #define CLOCK_HOPF_SERIAL /* device 38, hopf DCF77/GPS serial line receiver */
349 #define CLOCK_HOPF_PCI /* device 39, hopf DCF77/GPS PCI-Bus receiver */
350 #define CLOCK_JUPITER
354 #define CLOCK_PALISADE /* from ntpd.mak */
356 /* parse component drivers */
357 #define CLOCK_COMPUTIME
358 #define CLOCK_DCF7000
359 #define CLOCK_HOPF6021
360 #define CLOCK_MEINBERG
362 #define CLOCK_RCC8000
364 #define CLOCK_TRIMTAIP
365 #define CLOCK_TRIMTSIP
366 #define CLOCK_VARITEXT
367 #define CLOCK_WHARTON_400A
368 /* end parse component drivers */
369 /* # define CLOCK_SHM */
370 #define CLOCK_SPECTRACOM /* refclock_wwvb.c */
371 #define CLOCK_TRIMBLEDC
372 #define CLOCK_TRUETIME
374 #define NTP_LITTLE_ENDIAN /* from libntp.mak */
375 #define NTP_POSIX_SOURCE
377 #define SYSLOG_FILE /* from libntp.mak */
379 #define HAVE_LONG_LONG_INT 1
380 #define HAVE_UNSIGNED_LONG_LONG_INT 1
381 #define HAVE_SIZE_T 1
382 #define HAVE_PTRDIFF_T 1
384 #if defined(_MSC_VER) && _MSC_VER >= 1900
385 #define HAVE_WINT_T 1
388 # define SIZEOF_SIGNED_CHAR 1
389 # define SIZEOF_SHORT 2
390 # define SIZEOF_INT 4
391 # define SIZEOF_LONG 4
392 # define SIZEOF_LONG_LONG 8
394 /* libntp/snprintf.c doesn't know %I64d */
395 #define ISC_PLATFORM_QUADFORMAT "ll"
397 # define HAVE_ERRNO_H 1
398 # define HAVE_FCNTL_H 1
399 # define HAVE_LIMITS_H 1
400 # define HAVE_STDARG_H 1
401 # define HAVE_SYS_RESOURCE_H 1
402 # define HAVE_SYS_TIME_H 1
403 # define HAVE_TERMIOS_H 1
405 # define HAVE_ALLOCA 1
406 # define HAVE_GETCLOCK 1
407 # define HAVE_MEMMOVE 1
408 # define HAVE_MKTIME 1
409 # define HAVE_SETVBUF 1
410 # define HAVE_STRCHR 1 /* for libopts */
411 # define HAVE_STRDUP 1
412 # define HAVE_TIMEGM 1 /* actually _mkgmtime */
414 # define HAVE_STRUCT_TIMESPEC
415 # define HAVE_IO_COMPLETION_PORT
416 # define ISC_PLATFORM_NEEDNTOP
417 # define ISC_PLATFORM_NEEDPTON
419 #define HAVE_BSD_NICE /* emulate BSD setpriority() */
421 #define HW_WANT_RPL_VSNPRINTF 1
422 #define vsnprintf rpl_vsnprintf
424 int rpl_vsnprintf(char *, size_t, const char *, va_list);
425 #define HW_WANT_RPL_SNPRINTF 1
426 #define snprintf rpl_snprintf
427 int rpl_snprintf(char *, size_t, const char *, ...);
428 #define HAVE_VSNPRINTF 1
429 #define HAVE_SNPRINTF 1
431 typedef char *caddr_t;
433 #ifdef _WCTYPE_T_DEFINED /* see vc/include/crtdefs.h */
434 #define HAVE_WINT_T 1
437 #ifndef _INTPTR_T_DEFINED
438 typedef long intptr_t;
439 #define _INTPTR_T_DEFINED
441 #define HAVE_INTPTR_T 1
443 #ifndef _UINTPTR_T_DEFINED
444 typedef unsigned long uintptr_t;
445 #define _UINTPTR_T_DEFINED
447 #define HAVE_UINTPTR_T 1
451 * if DWORD_PTR needs to be defined then the build environment
452 * is pure 32 bit Windows. Since DWORD_PTR and DWORD have
453 * the same size in 32 bit Windows we can safely define
456 typedef DWORD DWORD_PTR;
459 #define NEED_S_CHAR_TYPEDEF
462 /* C99 exact size integer support. */
463 #if defined(_MSC_VER) && _MSC_VER<1800
464 # define MISSING_INTTYPES_H 1 /* not provided by VS2012 and earlier */
465 # define MISSING_STDBOOL_H 1 /* not provided by VS2012 and earlier */
466 # define MISSING_C99_STRUCT_INIT 1 /* see [Bug 2728] */
468 #if defined(_MSC_VER) && _MSC_VER>=1800
469 /* VS2013 and above support C99 types */
470 # define HAVE_INT8_T 1
471 # define HAVE_UINT8_T 1
472 # define HAVE_INT16_T 1
473 # define HAVE_UINT16_T 1
474 # define HAVE_INT32_T 1
475 # define HAVE_UINT32_T 1
479 #if !defined (MISSING_STDBOOL_H)
480 # define HAVE_STDBOOL_H
482 #if !defined(MISSING_INTTYPES_H)
483 # define HAVE_INTTYPES_H 1
484 #elif !defined(MISSING_STDINT_H)
485 # define HAVE_STDINT_H 1
486 #elif !defined(ADDED_EXACT_SIZE_INTEGERS)
487 # define ADDED_EXACT_SIZE_INTEGERS 1
488 typedef __int8 int8_t;
489 typedef unsigned __int8 uint8_t;
491 typedef __int16 int16_t;
492 typedef unsigned __int16 uint16_t;
494 typedef __int32 int32_t;
495 typedef unsigned __int32 uint32_t;
497 typedef __int64 int64_t;
498 typedef unsigned __int64 uint64_t;
502 /* Directory separator, usually / or \ */
505 #define POSIX_SHELL "/bin/sh" /* libopts/makeshell.c */
507 #define ULONG_CONST(a) a ## UL
510 #define RETSIGTYPE void
513 #define STR_SYSTEM "Windows"
516 #ifndef STR_PROCESSOR
518 #define STRINGIZE(arg) #arg
522 #define STR_PROCESSOR "x86"
525 #define STR_PROCESSOR "x86"
528 #define STR_PROCESSOR "x86-FP-" STRINGIZE(_M_IX86_FP)
531 #define STR_PROCESSOR "x86-SSE2"
533 #define STR_PROCESSOR "x86-SSE"
534 #endif /* _M_IX86 == 2 */
535 #endif /* _M_IX86_FP > 2 */
536 #endif /* !_M_IX86_FP */
537 #endif /* !defined(_M_IX86_FP) */
538 #endif /* !defined(_M_IX86) */
541 #define STR_PROCESSOR "Itanium"
545 #define STR_PROCESSOR "x64"
548 #endif /* !defined(STR_PROCESSOR) */
552 #define SIOCGIFFLAGS SIO_GET_INTERFACE_LIST /* used in ntp_io.c */
554 /* Bug 2978 mitigation -- unless defined elsewhere, do it here*/
555 #ifndef DYNAMIC_INTERLEAVE
556 # define DYNAMIC_INTERLEAVE 0
560 * Below this line are includes which must happen after the bulk of
561 * config.h is processed. If you need to add another #include to this
562 * file the preferred location is near the top, above the similar
564 * ---------------------------------------------------------------------
568 * Include standard stat information
570 #include <isc/stat.h>
572 #endif /* CONFIG_H */