xref: /netbsd-src/external/bsd/ntp/dist/sntp/libopts/compat/windows-config.h (revision 7788a0781fe6ff2cce37368b4578a7ade0850cb1)
1 /*	$NetBSD: windows-config.h,v 1.1.1.2 2012/01/31 21:27:55 kardel Exp $	*/
2 
3 
4 /*
5  * Time-stamp:        "2010-02-24 08:39:04 bkorb"
6  *
7  *  This file is part of AutoGen.
8  *
9  *  AutoGen Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
10  *
11  *  AutoGen is free software: you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License as published by the
13  *  Free Software Foundation, either version 3 of the License, or
14  *  (at your option) any later version.
15  *
16  *  AutoGen is distributed in the hope that it will be useful, but
17  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19  *  See the GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License along
22  *  with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 #ifndef WINDOWS_CONFIG_HACKERY
25 #define WINDOWS_CONFIG_HACKERY 1
26 
27 /*
28  * The definitions below have been stolen from NTP's config.h for Windows.
29  * However, they may be kept here in order to keep libopts independent from
30  * the NTP project.
31  */
32 #ifndef __windows__
33 #  define __windows__ 4
34 #endif
35 
36 /*
37  * Miscellaneous functions that Microsoft maps
38  * to other names
39  *
40  * #define inline __inline
41  * #define vsnprintf _vsnprintf
42  */
43 #define snprintf _snprintf
44 /*
45  * #define stricmp _stricmp
46  * #define strcasecmp _stricmp
47  * #define isascii __isascii
48  * #define finite _finite
49  * #define random      rand
50  * #define srandom     srand
51  */
52 
53 #define SIZEOF_INT   4
54 #define SIZEOF_CHARP 4
55 #define SIZEOF_LONG  4
56 #define SIZEOF_SHORT 2
57 
58 typedef unsigned long uintptr_t;
59 
60 /*
61  * # define HAVE_NET_IF_H
62  * # define QSORT_USES_VOID_P
63  * # define HAVE_SETVBUF
64  * # define HAVE_VSPRINTF
65  * # define HAVE_SNPRINTF
66  * # define HAVE_VSNPRINTF
67  * # define HAVE_PROTOTYPES             /* from ntpq.mak * /
68  * # define HAVE_MEMMOVE
69  * # define HAVE_TERMIOS_H
70  * # define HAVE_ERRNO_H
71  * # define HAVE_STDARG_H
72  * # define HAVE_NO_NICE
73  * # define HAVE_MKTIME
74  * # define TIME_WITH_SYS_TIME
75  * # define HAVE_IO_COMPLETION_PORT
76  * # define ISC_PLATFORM_NEEDNTOP
77  * # define ISC_PLATFORM_NEEDPTON
78  * # define NEED_S_CHAR_TYPEDEF
79  * # define USE_PROTOTYPES              /* for ntp_types.h * /
80  *
81  * #define ULONG_CONST(a) a ## UL
82  */
83 
84 #define HAVE_LIMITS_H   1
85 #define HAVE_STRDUP     1
86 #define HAVE_STRCHR     1
87 #define HAVE_FCNTL_H    1
88 
89 /*
90  * VS.NET's version of wspiapi.h has a bug in it
91  * where it assigns a value to a variable inside
92  * an if statement. It should be comparing them.
93  * We prevent inclusion since we are not using this
94  * code so we don't have to see the warning messages
95  */
96 #ifndef _WSPIAPI_H_
97 #define _WSPIAPI_H_
98 #endif
99 
100 /* Prevent inclusion of winsock.h in windows.h */
101 #ifndef _WINSOCKAPI_
102 #define _WINSOCKAPI_
103 #endif
104 
105 #ifndef __RPCASYNC_H__
106 #define __RPCASYNC_H__
107 #endif
108 
109 /* Include Windows headers */
110 #include <windows.h>
111 #include <winsock2.h>
112 #include <limits.h>
113 
114 /*
115  * Compatibility declarations for Windows, assuming SYS_WINNT
116  * has been defined.
117  */
118 #define strdup  _strdup
119 #define stat    _stat       /* struct stat from <sys/stat.h> */
120 #define unlink  _unlink
121 #define fchmod( _x, _y );
122 #define ssize_t SSIZE_T
123 
124 #include <io.h>
125 #define open    _open
126 #define close   _close
127 #define read    _read
128 #define write   _write
129 #define lseek   _lseek
130 #define pipe    _pipe
131 #define dup2    _dup2
132 
133 #define O_RDWR     _O_RDWR
134 #define O_RDONLY   _O_RDONLY
135 #define O_EXCL     _O_EXCL
136 
137 #ifndef S_ISREG
138 #  define S_IFREG _S_IFREG
139 #  define       S_ISREG(mode)   (((mode) & S_IFREG) == S_IFREG)
140 #endif
141 
142 #ifndef S_ISDIR
143 #  define S_IFDIR _S_IFDIR
144 #  define       S_ISDIR(mode)   (((mode) & S_IFDIR) == S_IFDIR)
145 #endif
146 
147 #endif /* WINDOWS_CONFIG_HACKERY */
148