]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - ports/winnt/include/config.h
Vendor import of ntp-4.2.8p8.
[FreeBSD/FreeBSD.git] / ports / winnt / include / config.h
1 /* 
2  * ports/winnt/include/config.h - static Windows config.h
3  *
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".
8  */
9
10 #ifndef CONFIG_H
11 #define CONFIG_H
12
13 /*
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)
21  *  1300: MSVC++ 7.0
22  *  1200: MSVC++ 6.0  (Visual C++ 6)
23  *  1100: MSVC++ 5.0
24  */
25
26 #if defined(_MSC_VER) && _MSC_VER < 1400
27 #error Minimum supported Microsoft compiler is Visual C++ 2005.
28 #endif
29
30 /*
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.
38  *
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.
43  */
44 #ifndef _WIN32_WINNT
45 #define _WIN32_WINNT 0x0501
46 #endif
47
48 #define __attribute__(x) /* empty */
49 #define _CRT_SECURE_NO_DEPRECATE 1
50
51 /*
52  * ANSI C compliance enabled
53  */
54 #define __STDC__ 1
55
56 /*
57  * Enable the debug build of MS C runtime to dump leaks
58  * at exit time (currently only if run under a debugger).
59  */
60 #if defined(_MSC_VER) && defined(_DEBUG)
61 # define _CRTDBG_MAP_ALLOC
62 # include <stdlib.h>
63 # include <malloc.h>
64 # include <crtdbg.h>
65 /* # define MALLOC_LINT */      /* defers free() */
66 # define EREALLOC_IMPL(ptr, newsz, filenm, loc) \
67          _realloc_dbg(ptr, newsz, _NORMAL_BLOCK, filenm, loc)
68 #endif
69
70 /*
71  * We need to include stdio.h first before we #define snprintf
72  * otherwise we can get errors during the build
73  */
74 #include <stdio.h>
75
76 /* Prevent inclusion of winsock.h in windows.h */
77 #ifndef _WINSOCKAPI_
78 #define _WINSOCKAPI_  
79 #endif
80
81 #ifndef __RPCASYNC_H__
82 #define __RPCASYNC_H__
83 #endif
84
85 /*
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 
90  * within NTP.
91  *
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.
95  */
96 #define timeval sock_timeval
97
98 /* Include Windows headers */
99 #include <windows.h>
100 #include <winsock2.h>
101 #include <ws2tcpip.h>
102
103 #undef timeval  /* see sock_timeval #define and comment above */
104
105 /*
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.
112  */
113 #ifdef _W64
114 /* VC6 can include wspiapi.h only if the SDK is installed */
115 #include <wspiapi.h>
116 #endif
117
118 #undef interface
119 #include <process.h>
120 #include <time.h>               /* time_t for timeval decl */
121 #include <io.h>
122 #include <isc/strerror.h>
123
124 /* ---------------------------------------------------------------------
125  * Above this line are #include lines and the few #define lines
126  * needed before including headers.
127  */
128
129 struct timeval {
130         time_t  tv_sec;
131         long    tv_usec;
132 };
133
134 /*
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.
138  */
139 #ifdef ntohl
140 #error ntohl is already defined in ports/winnt/include/config.h
141 #else
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)
151 #endif
152
153 /*
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
160  * refclock_open().
161  */
162 extern int tty_open(const char *, int, int);
163
164 /*
165  * disable use of __declspec(dllexport) by libisc routines
166  */
167 #define ISC_STATIC_WIN  1
168
169 /*
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.
177  */
178 #ifdef in_addr6
179 #define WANT_IPV6
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 */
185
186 #define NO_OPTION_NAME_WARNINGS
187
188 #if !defined( _W64 )
189   /*
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
193    * a replacement.
194    */
195 typedef DWORD ULONG_PTR;
196 /* VC6 doesn't know about socklen_t, except if the SDK is installed */
197 typedef int socklen_t;
198 #endif  /* _W64 */
199
200 #define ISC_PLATFORM_NEEDIN6ADDRANY
201 #define HAVE_SOCKADDR_IN6
202
203 /*
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 
206  */
207 #define GETSOCKNAME_SOCKLEN_TYPE socklen_t
208
209 /*
210  * Older SDKs do not define SO_EXCLUSIVEADDRUSE in winsock2.h
211  */
212 #ifndef SO_EXCLUSIVEADDRUSE
213 #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
214 #endif
215
216 #if defined _MSC_VER && _MSC_VER < 1400
217 /*
218  * Use 32-bit time definitions for versions prior to VS 2005
219  * VS 2005 defaults to 64-bit time
220  */
221 # define SIZEOF_TIME_T 4
222 #else
223 # define SIZEOF_TIME_T 8
224 #endif
225
226
227 /*
228  * An attempt to cut down the number of warnings generated during compilation.
229  * All of these should be benign to disable.
230  */
231
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 */
235
236 /*
237  * Windows NT Configuration Values
238  */
239 #if defined _DEBUG /* Use VC standard macro definitions */
240 # define DEBUG 1
241 #endif
242
243 #define __windows__ 1
244 /* Define if you have the ANSI C header files.  */
245 #define STDC_HEADERS 1
246
247 #define OPEN_BCAST_SOCKET               1       /* for ntp_io.c */
248 #define TYPEOF_IP_MULTICAST_LOOP        BOOL
249 #define SETSOCKOPT_ARG_CAST             (const char *)
250 #define HAVE_RANDOM 
251 #define SAVECONFIG                      1
252
253 /*
254  * Multimedia timer enable
255  */
256 #define USE_MM_TIMER
257
258 /* check for OpenSSL */
259 #ifdef OPENSSL
260 # define USE_OPENSSL_CRYPTO_RAND 1
261 # define AUTOKEY
262 #endif
263 extern void arc4random_buf(void *buf, size_t nbytes);
264
265 /*
266  * Keywords and functions that Microsoft maps
267  * to other names
268  */
269 #define inline          __inline
270 #define stricmp         _stricmp
271 #define strcasecmp      _stricmp
272 #define isascii         __isascii
273 #define finite          _finite
274 #define random          rand
275 #define srandom         srand
276 #define fdopen          _fdopen
277 #define read            _read
278 #define open            _open
279 #ifndef close
280 #define close           _close
281 #endif
282 #define write           _write
283 #define strdup          _strdup
284 #define alloca          _alloca
285 #define stat            _stat           /*struct stat from  <sys/stat.h> */
286 #define fstat           _fstat
287 #define unlink          _unlink
288 /*
289  * punt on fchmod on Windows
290  */
291 #define fchmod(x,y)     {}
292 #define lseek           _lseek
293 #define pipe            _pipe
294 #define dup2            _dup2
295 /*
296  * scale, unix sleep is seconds, Windows Sleep is msec
297  */
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
305 /*
306  * symbol returning the name of the current function
307  */
308 #define __func__        __FUNCTION__
309
310 typedef int pid_t;              /* PID is an int */
311 typedef int ssize_t;    /* ssize is an int */
312
313 /*
314  * Map the stream to the file number
315  */
316 #define STDOUT_FILENO   _fileno(stdout)
317 #define STDERR_FILENO   _fileno(stderr)
318
319 /*
320  * To minimize Windows-specific changes to the rest of the NTP code,
321  * particularly reference clocks, ntp_stdlib.h will
322  *
323  * #define strerror(e) ntp_strerror(e)
324  *
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.
329  */
330 #define NTP_REDEFINE_STRERROR
331
332 #define MCAST                           /* Enable Multicast Support */
333 #define MULTICAST_NONEWSOCKET           /* Don't create a new socket for mcast address */
334
335 # define REFCLOCK                       /* from ntpd.mak */
336
337 /* #define CLOCK_PARSE  */
338 #define CLOCK_ACTS
339 #define CLOCK_ARBITER
340 #define CLOCK_ARCRON_MSF
341 #define OWN_PPS_NTP_TIMESTAMP_FROM_COUNTER      /* timepps.h */
342 #define HAVE_TIMEPPS_H
343 #define HAVE_PPSAPI
344 #define CLOCK_ATOM
345 #define CLOCK_CHU
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
351 #define CLOCK_LOCAL
352 #define CLOCK_NMEA
353 #define CLOCK_ONCORE
354 #define CLOCK_PALISADE          /* from ntpd.mak */
355 #define CLOCK_PARSE
356 /* parse component drivers */
357 #define CLOCK_COMPUTIME
358 #define CLOCK_DCF7000
359 #define CLOCK_HOPF6021
360 #define CLOCK_MEINBERG
361 #define CLOCK_RAWDCF
362 #define CLOCK_RCC8000
363 #define CLOCK_SCHMID
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
373
374 #define NTP_LITTLE_ENDIAN               /* from libntp.mak */
375 #define NTP_POSIX_SOURCE
376
377 #define SYSLOG_FILE                     /* from libntp.mak */
378
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
383
384 #if defined(_MSC_VER) && _MSC_VER >= 1900
385 #define HAVE_WINT_T                             1
386 #endif
387
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
393
394 /* libntp/snprintf.c doesn't know %I64d */
395 #define ISC_PLATFORM_QUADFORMAT "ll"
396
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
404
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 */
413
414 # define HAVE_STRUCT_TIMESPEC
415 # define HAVE_IO_COMPLETION_PORT
416 # define ISC_PLATFORM_NEEDNTOP
417 # define ISC_PLATFORM_NEEDPTON
418
419 #define HAVE_BSD_NICE                   /* emulate BSD setpriority() */
420
421 #define HW_WANT_RPL_VSNPRINTF           1
422 #define vsnprintf                       rpl_vsnprintf
423 #include <stdarg.h>
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
430
431 typedef char *caddr_t;
432
433 #ifdef _WCTYPE_T_DEFINED        /* see vc/include/crtdefs.h */
434 #define HAVE_WINT_T                     1
435 #endif
436
437 #ifndef _INTPTR_T_DEFINED
438 typedef long intptr_t;
439 #define _INTPTR_T_DEFINED
440 #endif
441 #define HAVE_INTPTR_T                   1
442
443 #ifndef _UINTPTR_T_DEFINED
444 typedef unsigned long uintptr_t;
445 #define _UINTPTR_T_DEFINED
446 #endif
447 #define HAVE_UINTPTR_T                  1
448
449 #if !defined( _W64 )
450   /*
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
454    * a replacement.
455    */
456   typedef DWORD DWORD_PTR;
457 #endif
458
459 #define NEED_S_CHAR_TYPEDEF
460
461
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] */
467 #else
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
476 #endif
477 #endif
478
479 #if !defined (MISSING_STDBOOL_H)
480 # define HAVE_STDBOOL_H
481 #endif
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;
490
491   typedef __int16 int16_t;
492   typedef unsigned __int16 uint16_t;
493
494   typedef __int32 int32_t;
495   typedef unsigned __int32 uint32_t;
496
497   typedef __int64 int64_t;
498   typedef unsigned __int64 uint64_t;
499 #endif
500
501
502 /* Directory separator, usually / or \ */
503 #define DIR_SEP '\\'
504
505 #define POSIX_SHELL     "/bin/sh"       /* libopts/makeshell.c */
506
507 #define ULONG_CONST(a) a ## UL
508
509 #define NOKMEM
510 #define RETSIGTYPE void
511
512 #ifndef STR_SYSTEM
513 #define STR_SYSTEM "Windows"
514 #endif
515
516 #ifndef STR_PROCESSOR
517
518 #define STRINGIZE(arg)  #arg
519
520 #ifdef _M_IX86
521 #ifndef _M_IX86_FP
522 #define STR_PROCESSOR "x86"
523 #else
524 #if !_M_IX86_FP 
525 #define STR_PROCESSOR "x86"
526 #else 
527 #if _M_IX86_FP > 2
528 #define STR_PROCESSOR "x86-FP-" STRINGIZE(_M_IX86_FP)
529 #else
530 #if _M_IX86_FP == 2
531 #define STR_PROCESSOR "x86-SSE2"
532 #else
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) */
539
540 #ifdef _M_IA64
541 #define STR_PROCESSOR "Itanium"
542 #endif
543
544 #ifdef _M_X64
545 #define STR_PROCESSOR "x64"
546 #endif
547
548 #endif /* !defined(STR_PROCESSOR) */
549
550 #undef STRINGIZE
551
552 #define  SIOCGIFFLAGS SIO_GET_INTERFACE_LIST /* used in ntp_io.c */
553
554 /* Bug 2978 mitigation -- unless defined elsewhere, do it here*/
555 #ifndef DYNAMIC_INTERLEAVE
556 # define DYNAMIC_INTERLEAVE 0
557 #endif
558
559 /*
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
563  * line of hyphens.
564  * ---------------------------------------------------------------------
565  */
566
567 /*
568  * Include standard stat information
569  */
570 #include <isc/stat.h>
571
572 #endif  /* CONFIG_H */