Annotation of embedaddon/ntp/ports/winnt/include/config.h, revision 1.1.1.1
1.1 misho 1: /* config.h for Windows NT */
2:
3: #ifndef CONFIG_H
4: #define CONFIG_H
5:
6: /*
7: * For newer compilers we may we want newer prototypes from Windows
8: * so we target _WIN32_WINNT at WINXP, but we also want our binary to
9: * run on NT 4, so newer functions are runtime linked and the linker
10: * /version:0x0400 * switch is used to override the .exe file minimum
11: * version. For older compilers we leave it at NT 4.0.
12: */
13: #ifndef _WIN32_WINNT
14: #if _MSC_VER > 1400 /* At least VS 2005 */
15: #define _WIN32_WINNT 0x0501
16: #else /* NT 4.0 */
17: #define _WIN32_WINNT 0x0400
18: #endif
19: #endif
20:
21:
22: #define _CRT_SECURE_NO_DEPRECATE 1
23: /*
24: * ANSI C compliance enabled
25: */
26: #define __STDC__ 1
27:
28: /*
29: * Enable the debug build of MS C runtime to dump leaks
30: * at exit time (currently only if run under a debugger).
31: */
32: #if defined(_MSC_VER) && defined(_DEBUG)
33: #define _CRTDBG_MAP_ALLOC
34: #include <stdlib.h>
35: #include <malloc.h>
36: #include <crtdbg.h>
37: /* #define MALLOC_LINT */ /* defers free() */
38: # define EREALLOC_IMPL(ptr, newsz, filenm, loc) \
39: _realloc_dbg(ptr, newsz, _NORMAL_BLOCK, filenm, loc)
40: #endif
41:
42: /*
43: * We need to include stdio.h first before we #define snprintf
44: * otherwise we can get errors during the build
45: */
46: #include <stdio.h>
47:
48: /* Prevent inclusion of winsock.h in windows.h */
49: #ifndef _WINSOCKAPI_
50: #define _WINSOCKAPI_
51: #endif
52:
53: #ifndef __RPCASYNC_H__
54: #define __RPCASYNC_H__
55: #endif
56:
57: /*
58: * VS.NET's version of wspiapi.h has a bug in it
59: * where it assigns a value to a variable inside
60: * an if statement. It should be comparing them.
61: * We prevent inclusion since we are not using this
62: * code so we don't have to see the warning messages
63: */
64: #ifndef _WSPIAPI_H_
65: /* #define _WSPIAPI_H_ */ /* need these wrappers for ntpd.exe to load on w2k */
66: #endif
67:
68: /*
69: * On Unix struct sock_timeval is equivalent to struct timeval.
70: * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long
71: * as required by Windows' socket() interface timeout argument, while
72: * timeval.tv_sec is time_t for the more common use as a UTC time
73: * within NTP.
74: *
75: * winsock.h unconditionally defines struct timeval with long tv_sec
76: * instead of time_t tv_sec. We redirect its declaration to struct
77: * sock_timeval instead of struct timeval with a #define.
78: */
79: #define timeval sock_timeval
80:
81: /* Include Windows headers */
82: #include <windows.h>
83: #include <winsock2.h>
84: #include <ws2tcpip.h>
85:
86: #undef timeval /* see sock_timeval #define and comment above */
87:
88: /*
89: * Some definitions we are using are missing in the headers
90: * shipping with VC6. However, if the SDK is installed then the
91: * SDK's headers may declare the missing types. This is at least
92: * the case in the Oct 2001 SDK. That SDK and all subsequent
93: * versions also define the symbol _W64, so we can use that one
94: * to determine whether some types need to be defined, or not.
95: */
96: #ifdef _W64
97: /* VC6 can include wspiapi.h only if the SDK is installed */
98: #include <wspiapi.h>
99: #endif
100:
101: #undef interface
102: #include <process.h>
103: #include <time.h> /* time_t for timeval decl */
104:
105: /* ---------------------------------------------------------------------
106: * Above this line are #include lines and the few #define lines
107: * needed before including headers.
108: */
109:
110: struct timeval {
111: time_t tv_sec;
112: long tv_usec;
113: };
114:
115: /*
116: * On Unix open() works for tty (serial) devices just fine, while on
117: * Windows refclock serial devices are opened using CreateFile, a lower
118: * level than the CRT-provided descriptors, because the C runtime lacks
119: * tty APIs. For refclocks which wish to use open() as well as or
120: * instead of refclock_open(), tty_open() is equivalent to open() on
121: * Unix and implemented in the Windows port similarly to
122: * refclock_open().
123: */
124: extern int tty_open(char *, int, int);
125:
126: /*
127: * disable use of __declspec(dllexport) by libisc routines
128: */
129: #define ISC_STATIC_WIN 1
130:
131: /*
132: * ntp_rfc2553.h has cruft under #ifdef SYS_WINNT which is
133: * appropriate for older Microsoft IPv6 definitions, such
134: * as in_addr6 being the struct type. We can differentiate
135: * the RFC2553-compliant newer headers because they have
136: * #define in_addr6 in6_addr
137: * for backward compatibility. With the newer headers,
138: * we define ISC_PLATFORM_HAVEIPV6 and disable the cruft.
139: */
140: #ifdef in_addr6
141: #define WANT_IPV6
142: #define ISC_PLATFORM_HAVEIPV6
143: #define ISC_PLATFORM_HAVESCOPEID
144: #define HAVE_STRUCT_SOCKADDR_STORAGE
145: #define ISC_PLATFORM_HAVEIN6PKTINFO
146: #endif /* in_addr6 / RFC2553-compliant IPv6 headers */
147:
148: #define NO_OPTION_NAME_WARNINGS
149:
150: #if !defined( _W64 )
151: /*
152: * if ULONG_PTR needs to be defined then the build environment
153: * is pure 32 bit Windows. Since ULONG_PTR and DWORD have
154: * the same size in 32 bit Windows we can safely define
155: * a replacement.
156: */
157: typedef DWORD ULONG_PTR;
158: /* VC6 doesn't know about socklen_t, except if the SDK is installed */
159: typedef int socklen_t;
160: #endif /* _W64 */
161:
162: #define ISC_PLATFORM_NEEDIN6ADDRANY
163: #define HAVE_SOCKADDR_IN6
164:
165: /*
166: * The type of the socklen_t defined for getnameinfo() and getaddrinfo()
167: * is int for VS compilers on Windows but the type is already declared
168: */
169: #define GETSOCKNAME_SOCKLEN_TYPE socklen_t
170:
171: /*
172: * Older SDKs do not define SO_EXCLUSIVEADDRUSE in winsock2.h
173: */
174: #ifndef SO_EXCLUSIVEADDRUSE
175: #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
176: #endif
177:
178: /*
179: * Define this macro to control the behavior of connection
180: * resets on UDP sockets. See Microsoft KnowledgeBase Article Q263823
181: * for details.
182: * Based on that article, it is surprising that a much newer winsock2.h
183: * does not define SIO_UDP_CONNRESET (the one that comes with VS 2008).
184: * NOTE: This requires that Windows 2000 systems install Service Pack 2
185: * or later.
186: */
187: #ifndef SIO_UDP_CONNRESET
188: #define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
189: #endif
190:
191: #if defined _MSC_VER && _MSC_VER < 1400
192: /*
193: * Use 32-bit time definitions for versions prior to VS 2005
194: * VS 2005 defaults to 64-bit time
195: */
196: # define SIZEOF_TIME_T 4
197: #else
198: # define SIZEOF_TIME_T 8
199: #endif
200:
201:
202: /*
203: * An attempt to cut down the number of warnings generated during compilation.
204: * All of these should be benign to disable.
205: */
206:
207: #pragma warning(disable: 4100) /* unreferenced formal parameter */
208: #pragma warning(disable: 4127) /* conditional expression is constant */
209: #pragma warning(disable: 4996) /* more secure replacement available */
210:
211: /*
212: * Windows NT Configuration Values
213: */
214: #if defined _DEBUG /* Use VC standard macro definitions */
215: # define DEBUG 1
216: #endif
217:
218: #define __windows__ 1
219: /* Define if you have the ANSI C header files. */
220: #define STDC_HEADERS 1
221:
222: #define OPEN_BCAST_SOCKET 1 /* for ntp_io.c */
223: #define TYPEOF_IP_MULTICAST_LOOP BOOL
224: #define SETSOCKOPT_ARG_CAST (const char *)
225: #define HAVE_RANDOM
226: #define MAXHOSTNAMELEN 64
227: #define AUTOKEY
228: #define SAVECONFIG 1
229:
230: /*
231: * Multimedia timer enable
232: */
233: #define USE_MM_TIMER
234:
235: /* Enable OpenSSL */
236: #define OPENSSL 1
237:
238: /*
239: * Keywords and functions that Microsoft maps
240: * to other names
241: */
242: #define inline __inline
243: #define vsnprintf _vsnprintf
244: #define snprintf _snprintf
245: #define stricmp _stricmp
246: #define strcasecmp _stricmp
247: #define isascii __isascii
248: #define finite _finite
249: #define random rand
250: #define srandom srand
251: #define fdopen _fdopen
252: #define read _read
253: #define open _open
254: #ifndef close
255: #define close _close
256: #endif
257: #define write _write
258: #define strdup _strdup
259: #define stat _stat /*struct stat from <sys/stat.h> */
260: #define fstat _fstat
261: #define unlink _unlink
262: /*
263: * punt on fchmod on Windows
264: */
265: #define fchmod(x,y) {}
266: #define lseek _lseek
267: #define pipe _pipe
268: #define dup2 _dup2
269: /*
270: * scale, unix sleep is seconds, Windows Sleep is msec
271: */
272: #define sleep(x) Sleep((unsigned)(x) * 1000)
273: #define fileno _fileno
274: #define isatty _isatty
275: #define mktemp _mktemp
276: #define getpid _getpid
277: #define timegm _mkgmtime
278:
279: typedef int pid_t; /* PID is an int */
280: typedef int ssize_t; /* ssize is an int */
281: typedef __int32 int32_t; /* define a typedef for int32_t */
282: #define HAVE_INT32_T 1
283:
284: /*
285: * Map the stream to the file number
286: */
287: #define STDOUT_FILENO _fileno(stdout)
288: #define STDERR_FILENO _fileno(stderr)
289:
290: /*
291: * To minimize Windows-specific changes to the rest of the NTP code,
292: * particularly reference clocks, ntp_stdlib.h will
293: *
294: * #define strerror(e) ntp_strerror(e)
295: *
296: * to deal with our mixture of C runtime (open, write) and Windows
297: * (sockets, serial ports) error codes. This is an ugly hack because
298: * both use the lowest values differently, but particularly for ntpd,
299: * it's not a problem.
300: */
301: #define NTP_REDEFINE_STRERROR
302:
303: # define MCAST /* Enable Multicast Support */
304: # define MULTICAST_NONEWSOCKET /* Don't create a new socket for mcast address */
305:
306: # define REFCLOCK /* from ntpd.mak */
307:
308: /* # define CLOCK_PARSE */
309: # define CLOCK_ARBITER
310: # define CLOCK_ARCRON_MSF
311: # define OWN_PPS_NTP_TIMESTAMP_FROM_COUNTER /* timepps.h */
312: # define HAVE_TIMEPPS_H
313: # define HAVE_PPSAPI
314: # define CLOCK_ATOM
315: # define CLOCK_CHRONOLOG
316: # define CLOCK_DUMBCLOCK
317: # define CLOCK_HOPF_SERIAL /* device 38, hopf DCF77/GPS serial line receiver */
318: # define CLOCK_HOPF_PCI /* device 39, hopf DCF77/GPS PCI-Bus receiver */
319: # define CLOCK_JUPITER
320: # define CLOCK_LOCAL
321: # define CLOCK_NMEA
322: # define CLOCK_ONCORE
323: # define CLOCK_PALISADE /* from ntpd.mak */
324: /* # define CLOCK_SHM */
325: # define CLOCK_SPECTRACOM /* refclock_wwvb.c */
326: # define CLOCK_TRIMBLEDC
327: # define CLOCK_TRIMTSIP 1
328: # define CLOCK_TRUETIME
329:
330: # define NTP_LITTLE_ENDIAN /* from libntp.mak */
331: # define NTP_POSIX_SOURCE
332:
333: # define SYSLOG_FILE /* from libntp.mak */
334: # define HAVE_GETCLOCK
335:
336: # define SIZEOF_SIGNED_CHAR 1
337: # define SIZEOF_INT 4 /* for ntp_types.h */
338:
339: # define QSORT_USES_VOID_P
340: # define HAVE_SETVBUF
341: # define HAVE_VSPRINTF
342: # define HAVE_SNPRINTF
343: # define HAVE_VSNPRINTF
344: # define HAVE_PROTOTYPES /* from ntpq.mak */
345: # define HAVE_MEMMOVE
346: # define HAVE_TERMIOS_H
347: # define HAVE_ERRNO_H
348: # define HAVE_STDARG_H
349: # define HAVE_NO_NICE
350: # define HAVE_MKTIME
351: # define HAVE_TIMEGM 1 /* actually _mkgmtime */
352: # define HAVE_STRUCT_TIMESPEC
353: # define TIME_WITH_SYS_TIME
354: # define HAVE_IO_COMPLETION_PORT
355: # define ISC_PLATFORM_NEEDNTOP
356: # define ISC_PLATFORM_NEEDPTON
357: # define HAVE_VPRINTF
358:
359: #define HAVE_LIMITS_H 1
360: #define HAVE_STRDUP 1
361: #define HAVE_STRCHR 1
362: #define HAVE_FCNTL_H 1
363: #define HAVE_SYS_RESOURCE_H
364: #define HAVE_BSD_NICE /* emulate BSD setpriority() */
365:
366: typedef char *caddr_t;
367:
368: #ifdef _WCTYPE_T_DEFINED /* see vc/include/crtdefs.h */
369: #define HAVE_WINT_T
370: #endif
371:
372: #ifndef _INTPTR_T_DEFINED
373: typedef long intptr_t;
374: #define _INTPTR_T_DEFINED
375: #endif
376: #define HAVE_INTPTR_T
377:
378: #ifndef _UINTPTR_T_DEFINED
379: typedef unsigned long uintptr_t;
380: #define _UINTPTR_T_DEFINED
381: #endif
382: #define HAVE_UINTPTR_T
383:
384: #if !defined( _W64 )
385: /*
386: * if DWORD_PTR needs to be defined then the build environment
387: * is pure 32 bit Windows. Since DWORD_PTR and DWORD have
388: * the same size in 32 bit Windows we can safely define
389: * a replacement.
390: */
391: typedef DWORD DWORD_PTR;
392: #endif
393:
394: #define NEED_S_CHAR_TYPEDEF
395:
396: #define USE_PROTOTYPES /* for ntp_types.h */
397:
398: /* Directory separator, usually / or \ */
399: #define DIR_SEP '\\'
400:
401: #define POSIX_SHELL "/bin/sh" /* libopts/makeshell.c */
402:
403: #define ULONG_CONST(a) a ## UL
404:
405: #define NOKMEM
406: #define RETSIGTYPE void
407:
408: #ifndef STR_SYSTEM
409: #define STR_SYSTEM "Windows"
410: #endif
411:
412: #ifndef STR_PROCESSOR
413:
414: #define STRINGIZE(arg) #arg
415:
416: #ifdef _M_IX86
417: #ifndef _M_IX86_FP
418: #define STR_PROCESSOR "x86"
419: #else
420: #if !_M_IX86_FP
421: #define STR_PROCESSOR "x86"
422: #else
423: #if _M_IX86_FP > 2
424: #define STR_PROCESSOR "x86-FP-" STRINGIZE(_M_IX86_FP)
425: #else
426: #if _M_IX86_FP == 2
427: #define STR_PROCESSOR "x86-SSE2"
428: #else
429: #define STR_PROCESSOR "x86-SSE"
430: #endif /* _M_IX86 == 2 */
431: #endif /* _M_IX86_FP > 2 */
432: #endif /* !_M_IX86_FP */
433: #endif /* !defined(_M_IX86_FP) */
434: #endif /* !defined(_M_IX86) */
435:
436: #ifdef _M_IA64
437: #define STR_PROCESSOR "Itanium"
438: #endif
439:
440: #ifdef _M_X64
441: #define STR_PROCESSOR "x64"
442: #endif
443:
444: #endif /* !defined(STR_PROCESSOR) */
445:
446: #define SIOCGIFFLAGS SIO_GET_INTERFACE_LIST /* used in ntp_io.c */
447: /*
448: * Below this line are includes which must happen after the bulk of
449: * config.h is processed. If you need to add another #include to this
450: * file the preferred location is near the top, above the similar
451: * line of hyphens.
452: * ---------------------------------------------------------------------
453: */
454:
455: /*
456: * Include standard stat information
457: */
458: #include <isc/stat.h>
459:
460: #endif /* CONFIG_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>