1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
5 */
6
7
8#ifndef _NGX_WIN32_CONFIG_H_INCLUDED_
9#define _NGX_WIN32_CONFIG_H_INCLUDED_
10
11
12#undef  WIN32
13#define WIN32         0x0400
14#define _WIN32_WINNT  0x0501
15
16
17#define STRICT
18#define WIN32_LEAN_AND_MEAN
19
20/* enable getenv() and gmtime() in msvc8 */
21#define _CRT_SECURE_NO_WARNINGS
22#define _CRT_SECURE_NO_DEPRECATE
23
24/* enable gethostbyname() in msvc2015 */
25#if !(NGX_HAVE_INET6)
26#define _WINSOCK_DEPRECATED_NO_WARNINGS
27#endif
28
29/*
30 * we need to include <windows.h> explicitly before <winsock2.h> because
31 * the warning 4201 is enabled in <windows.h>
32 */
33#include <windows.h>
34
35#ifdef _MSC_VER
36#pragma warning(disable:4201)
37#endif
38
39#include <winsock2.h>
40#include <ws2tcpip.h>  /* ipv6 */
41#include <mswsock.h>
42#include <shellapi.h>
43#include <stddef.h>    /* offsetof() */
44
45#ifdef __MINGW64_VERSION_MAJOR
46
47/* GCC MinGW-w64 supports _FILE_OFFSET_BITS */
48#define _FILE_OFFSET_BITS 64
49
50#elif defined __GNUC__
51
52/* GCC MinGW's stdio.h includes sys/types.h */
53#define _OFF_T_
54#define __have_typedef_off_t
55
56#endif
57
58#include <stdio.h>
59#include <stdlib.h>
60#include <stdarg.h>
61#ifdef __GNUC__
62#include <stdint.h>
63#endif
64#include <ctype.h>
65#include <locale.h>
66
67#ifdef __WATCOMC__
68#define _TIME_T_DEFINED
69typedef long  time_t;
70/* OpenWatcom defines time_t as "unsigned long" */
71#endif
72
73#include <time.h>      /* localtime(), strftime() */
74
75
76#ifdef _MSC_VER
77
78/* the end of the precompiled headers */
79#pragma hdrstop
80
81#pragma warning(default:4201)
82
83/* disable some "-W4" level warnings */
84
85/* 'type cast': from function pointer to data pointer */
86#pragma warning(disable:4054)
87
88/* 'type cast': from data pointer to function pointer */
89#pragma warning(disable:4055)
90
91/* 'function' : different 'const' qualifiers */
92#pragma warning(disable:4090)
93
94/* unreferenced formal parameter */
95#pragma warning(disable:4100)
96
97/* FD_SET() and FD_CLR(): conditional expression is constant */
98#pragma warning(disable:4127)
99
100/* conversion from 'type1' to 'type2', possible loss of data */
101#pragma warning(disable:4244)
102
103/* conversion from 'size_t' to 'type', possible loss of data */
104#pragma warning(disable:4267)
105
106/* array is too small to include a terminating null character */
107#pragma warning(disable:4295)
108
109#endif
110
111
112#ifdef __WATCOMC__
113
114/* symbol 'ngx_rbtree_min' has been defined, but not referenced */
115#pragma disable_message(202)
116
117#endif
118
119
120#ifdef __BORLANDC__
121
122/* the end of the precompiled headers */
123#pragma hdrstop
124
125/* functions containing (for|while|some if) are not expanded inline */
126#pragma warn -8027
127
128/* unreferenced formal parameter */
129#pragma warn -8057
130
131/* suspicious pointer arithmetic */
132#pragma warn -8072
133
134#endif
135
136
137#include <ngx_auto_config.h>
138
139
140#define ngx_inline          __inline
141#define ngx_cdecl           __cdecl
142
143
144#ifdef _MSC_VER
145typedef unsigned __int32    uint32_t;
146typedef __int32             int32_t;
147typedef unsigned __int16    uint16_t;
148#define ngx_libc_cdecl      __cdecl
149
150#elif defined __BORLANDC__
151typedef unsigned __int32    uint32_t;
152typedef __int32             int32_t;
153typedef unsigned __int16    uint16_t;
154#define ngx_libc_cdecl      __cdecl
155
156#else /* __WATCOMC__ */
157typedef unsigned int        uint32_t;
158typedef int                 int32_t;
159typedef unsigned short int  uint16_t;
160#define ngx_libc_cdecl
161
162#endif
163
164typedef __int64             int64_t;
165typedef unsigned __int64    uint64_t;
166
167#if __BORLANDC__
168typedef int                 intptr_t;
169typedef u_int               uintptr_t;
170#endif
171
172
173#ifndef __MINGW64_VERSION_MAJOR
174
175/* Windows defines off_t as long, which is 32-bit */
176typedef __int64             off_t;
177#define _OFF_T_DEFINED
178
179#endif
180
181
182#ifdef __WATCOMC__
183
184/* off_t is redefined by sys/types.h used by zlib.h */
185#define __TYPES_H_INCLUDED
186typedef int                 dev_t;
187typedef unsigned int        ino_t;
188
189#elif __BORLANDC__
190
191/* off_t is redefined by sys/types.h used by zlib.h */
192#define __TYPES_H
193
194typedef int                 dev_t;
195typedef unsigned int        ino_t;
196
197#endif
198
199
200#ifndef __GNUC__
201#ifdef _WIN64
202typedef __int64             ssize_t;
203#else
204typedef int                 ssize_t;
205#endif
206#endif
207
208
209typedef uint32_t            in_addr_t;
210typedef u_short             in_port_t;
211typedef int                 sig_atomic_t;
212
213
214#ifdef _WIN64
215
216#define NGX_PTR_SIZE            8
217#define NGX_SIZE_T_LEN          (sizeof("-9223372036854775808") - 1)
218#define NGX_MAX_SIZE_T_VALUE    9223372036854775807
219#define NGX_TIME_T_LEN          (sizeof("-9223372036854775808") - 1)
220#define NGX_TIME_T_SIZE         8
221#define NGX_MAX_TIME_T_VALUE    9223372036854775807
222
223#else
224
225#define NGX_PTR_SIZE            4
226#define NGX_SIZE_T_LEN          (sizeof("-2147483648") - 1)
227#define NGX_MAX_SIZE_T_VALUE    2147483647
228#define NGX_TIME_T_LEN          (sizeof("-2147483648") - 1)
229#define NGX_TIME_T_SIZE         4
230#define NGX_MAX_TIME_T_VALUE    2147483647
231
232#endif
233
234
235#define NGX_OFF_T_LEN           (sizeof("-9223372036854775807") - 1)
236#define NGX_MAX_OFF_T_VALUE     9223372036854775807
237#define NGX_SIG_ATOMIC_T_SIZE   4
238
239
240#define NGX_HAVE_LITTLE_ENDIAN  1
241#define NGX_HAVE_NONALIGNED     1
242
243
244#define NGX_WIN_NT        200000
245
246
247#define NGX_LISTEN_BACKLOG           511
248
249
250#ifndef NGX_HAVE_INHERITED_NONBLOCK
251#define NGX_HAVE_INHERITED_NONBLOCK  1
252#endif
253
254#ifndef NGX_HAVE_CASELESS_FILESYSTEM
255#define NGX_HAVE_CASELESS_FILESYSTEM  1
256#endif
257
258#ifndef NGX_HAVE_WIN32_TRANSMITPACKETS
259#define NGX_HAVE_WIN32_TRANSMITPACKETS  1
260#define NGX_HAVE_WIN32_TRANSMITFILE     0
261#endif
262
263#ifndef NGX_HAVE_WIN32_TRANSMITFILE
264#define NGX_HAVE_WIN32_TRANSMITFILE  1
265#endif
266
267#if (NGX_HAVE_WIN32_TRANSMITPACKETS) || (NGX_HAVE_WIN32_TRANSMITFILE)
268#define NGX_HAVE_SENDFILE  1
269#endif
270
271#ifndef NGX_HAVE_SO_SNDLOWAT
272/* setsockopt(SO_SNDLOWAT) returns error WSAENOPROTOOPT */
273#define NGX_HAVE_SO_SNDLOWAT         0
274#endif
275
276#define NGX_HAVE_GETADDRINFO         1
277
278#define ngx_random               rand
279#define ngx_debug_init()
280
281
282#endif /* _NGX_WIN32_CONFIG_H_INCLUDED_ */
283