GNU libmicrohttpd 1.0.0
Loading...
Searching...
No Matches
mhd_options.h
Go to the documentation of this file.
1/*
2 This file is part of libmicrohttpd
3 Copyright (C) 2016-2021 Karlson2k (Evgeny Grin)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*/
19
30
31#ifndef MHD_OPTIONS_H
32#define MHD_OPTIONS_H 1
33
34#include "MHD_config.h"
35
42#define _(String) (String)
43
44#if defined(_MHD_EXTERN) && ! defined(BUILDING_MHD_LIB)
45#undef _MHD_EXTERN
46#endif /* _MHD_EXTERN && ! BUILDING_MHD_LIB */
47
48#ifndef _MHD_EXTERN
49#if defined(BUILDING_MHD_LIB) && defined(_WIN32) && \
50 (defined(DLL_EXPORT) || defined(MHD_W32DLL))
51#define _MHD_EXTERN __declspec(dllexport) extern
52#else /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */
53#define _MHD_EXTERN extern
54#endif /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */
55#endif /* ! _MHD_EXTERN */
56
57/* Some platforms (FreeBSD, Solaris, W32) allow to override
58 default FD_SETSIZE by defining it before including
59 headers. */
60#ifdef FD_SETSIZE
61/* FD_SETSIZE defined in command line or in MHD_config.h */
62#elif defined(_WIN32) || defined(__CYGWIN__)
63/* Platform with WinSock and without overridden FD_SETSIZE */
64#define FD_SETSIZE 2048 /* Override default small value (64) */
65#else /* !FD_SETSIZE && !W32 */
66/* System default value of FD_SETSIZE is used */
67#define _MHD_FD_SETSIZE_IS_DEFAULT 1
68#endif /* !FD_SETSIZE && !W32 */
69
70#if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE) || \
71 defined(HAVE_DARWIN_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
72/* Have any supported sendfile() function. */
73#define _MHD_HAVE_SENDFILE
74#endif /* HAVE_LINUX_SENDFILE || HAVE_FREEBSD_SENDFILE ||
75 HAVE_DARWIN_SENDFILE || HAVE_SOLARIS_SENDFILE */
76#if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
77#define MHD_LINUX_SOLARIS_SENDFILE 1
78#endif /* HAVE_LINUX_SENDFILE || HAVE_SOLARIS_SENDFILE */
79
80#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
81# ifndef MHD_USE_THREADS
82# define MHD_USE_THREADS 1
83# endif
84#endif /* MHD_USE_POSIX_THREADS || MHD_USE_W32_THREADS */
85
86#if defined(OS390)
87#define _OPEN_THREADS
88#define _OPEN_SYS_SOCK_IPV6
89#define _OPEN_MSGQ_EXT
90#define _LP64
91#endif
92
93#if defined(_WIN32) && ! defined(__CYGWIN__)
94/* Declare POSIX-compatible names */
95#define _CRT_DECLARE_NONSTDC_NAMES 1
96/* Do not warn about POSIX name usage */
97#define _CRT_NONSTDC_NO_WARNINGS 1
98#ifndef _WIN32_WINNT
99#define _WIN32_WINNT 0x0600
100#else /* _WIN32_WINNT */
101#if _WIN32_WINNT < 0x0501
102#error "Headers for Windows XP or later are required"
103#endif /* _WIN32_WINNT < 0x0501 */
104#endif /* _WIN32_WINNT */
105#ifndef WIN32_LEAN_AND_MEAN
106/* Do not include unneeded parts of W32 headers. */
107#define WIN32_LEAN_AND_MEAN 1
108#endif /* !WIN32_LEAN_AND_MEAN */
109#endif /* _WIN32 && ! __CYGWIN__ */
110
111#if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
112#define RESTRICT __restrict__
113#endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */
114
115#if defined(LINUX) && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && \
116 ! defined(_LARGEFILE64_SOURCE)
117/* On Linux, special macro is required to enable definitions of some xxx64 functions */
118#define _LARGEFILE64_SOURCE 1
119#endif
120
121#ifdef HAVE_C11_GMTIME_S
122/* Special macro is required to enable C11 definition of gmtime_s() function */
123#define __STDC_WANT_LIB_EXT1__ 1
124#endif /* HAVE_C11_GMTIME_S */
125
126#if defined(MHD_FAVOR_FAST_CODE) && defined(MHD_FAVOR_SMALL_CODE)
127#error \
128 MHD_FAVOR_FAST_CODE and MHD_FAVOR_SMALL_CODE are both defined. Cannot favor speed and size at the same time.
129#endif /* MHD_FAVOR_FAST_CODE && MHD_FAVOR_SMALL_CODE */
130
131/* Define MHD_FAVOR_FAST_CODE to force fast code path or
132 define MHD_FAVOR_SMALL_CODE to choose compact code path */
133#if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE)
134/* Try to detect user preferences */
135/* Defined by GCC and many compatible compilers */
136#if defined(__OPTIMIZE_SIZE__)
137#define MHD_FAVOR_SMALL_CODE 1
138#elif defined(__OPTIMIZE__)
139#define MHD_FAVOR_FAST_CODE 1
140#endif /* __OPTIMIZE__ */
141#endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */
142
143#if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE)
144/* Use faster code by default */
145#define MHD_FAVOR_FAST_CODE 1
146#endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */
147
148#ifndef MHD_ASAN_ACTIVE
149#if (defined(__GNUC__) || defined(_MSC_VER)) && defined(__SANITIZE_ADDRESS__)
150#define MHD_ASAN_ACTIVE 1
151#elif defined(__has_feature)
152#if __has_feature (address_sanitizer)
153#define MHD_ASAN_ACTIVE 1
154#endif /* __has_feature(address_sanitizer) */
155#endif /* __has_feature */
156#endif /* MHD_ASAN_ACTIVE */
157
158#if defined(MHD_ASAN_ACTIVE) && defined(HAVE_SANITIZER_ASAN_INTERFACE_H) && \
159 (defined(FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS) || \
160 (defined(FUNC_ATTR_PTRCOMPARE_WORKS) && \
161 defined(FUNC_ATTR_PTRSUBTRACT_WORKS)) || \
162 defined(FUNC_ATTR_NOSANITIZE_WORKS))
163#ifndef MHD_ASAN_POISON_ACTIVE
164/* User ASAN poisoning could be used */
165#warning User memory poisoning is not active
166#endif /* ! MHD_ASAN_POISON_ACTIVE */
167#else /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H &&
168 (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */
169#ifdef MHD_ASAN_POISON_ACTIVE
170#error User memory poisoning is active, but conditions are not suitable
171#endif /* MHD_ASAN_POISON_ACTIVE */
172#endif /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H &&
173 (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */
174
175#ifndef _MSC_FULL_VER
176# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ /* empty */
177# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ /* empty */
178#else /* _MSC_FULL_VER */
179# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE_ \
180 __pragma(runtime_checks("c", off))
181# define MHD_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE_ \
182 __pragma(runtime_checks("c", restore))
183#endif /* _MSC_FULL_VER */
184
188#if defined(HAVE___FUNC__)
189#define MHD_FUNC_ __func__
190#define MHD_HAVE_MHD_FUNC_ 1
191#elif defined(HAVE___FUNCTION__)
192#define MHD_FUNC_ __FUNCTION__
193#define MHD_HAVE_MHD_FUNC_ 1
194#elif defined(HAVE___PRETTY_FUNCTION__)
195#define MHD_FUNC_ __PRETTY_FUNCTION__
196#define MHD_HAVE_MHD_FUNC_ 1
197#else
198#define MHD_FUNC_ "**name unavailable**"
199#ifdef MHD_HAVE_MHD_FUNC_
200#undef MHD_HAVE_MHD_FUNC_
201#endif /* MHD_HAVE_MHD_FUNC_ */
202#endif
203
204/* Un-define some HAVE_DECL_* macro if they equal zero.
205 This should allow safely use #ifdef in the code.
206 Define HAS_DECL_* macros only if matching HAVE_DECL_* macro
207 has non-zero value. Unlike HAVE_DECL_*, macros HAS_DECL_*
208 cannot have zero value. */
209#ifdef HAVE_DECL__SC_NPROCESSORS_ONLN
210# if 0 == HAVE_DECL__SC_NPROCESSORS_ONLN
211# undef HAVE_DECL__SC_NPROCESSORS_ONLN
212# else /* 0 != HAVE_DECL__SC_NPROCESSORS_ONLN */
213# define HAS_DECL__SC_NPROCESSORS_ONLN 1
214# endif /* 0 != HAVE_DECL__SC_NPROCESSORS_ONLN */
215#endif /* HAVE_DECL__SC_NPROCESSORS_ONLN */
216
217#ifdef HAVE_DECL__SC_NPROCESSORS_CONF
218# if 0 == HAVE_DECL__SC_NPROCESSORS_CONF
219# undef HAVE_DECL__SC_NPROCESSORS_CONF
220# else /* 0 != HAVE_DECL__SC_NPROCESSORS_CONF */
221# define HAS_DECL__SC_NPROCESSORS_CONF 1
222# endif /* 0 != HAVE_DECL__SC_NPROCESSORS_CONF */
223#endif /* HAVE_DECL__SC_NPROCESSORS_CONF */
224
225#ifdef HAVE_DECL__SC_NPROC_ONLN
226# if 0 == HAVE_DECL__SC_NPROC_ONLN
227# undef HAVE_DECL__SC_NPROC_ONLN
228# else /* 0 != HAVE_DECL__SC_NPROC_ONLN */
229# define HAS_DECL__SC_NPROC_ONLN 1
230# endif /* 0 != HAVE_DECL__SC_NPROC_ONLN */
231#endif /* HAVE_DECL__SC_NPROC_ONLN */
232
233#ifdef HAVE_DECL__SC_CRAY_NCPU
234# if 0 == HAVE_DECL__SC_CRAY_NCPU
235# undef HAVE_DECL__SC_CRAY_NCPU
236# else /* 0 != HAVE_DECL__SC_CRAY_NCPU */
237# define HAS_DECL__SC_CRAY_NCPU 1
238# endif /* 0 != HAVE_DECL__SC_CRAY_NCPU */
239#endif /* HAVE_DECL__SC_CRAY_NCPU */
240
241#ifdef HAVE_DECL_CTL_HW
242# if 0 == HAVE_DECL_CTL_HW
243# undef HAVE_DECL_CTL_HW
244# else /* 0 != HAVE_DECL_CTL_HW */
245# define HAS_DECL_CTL_HW 1
246# endif /* 0 != HAVE_DECL_CTL_HW */
247#endif /* HAVE_DECL_CTL_HW */
248
249#ifdef HAVE_DECL_HW_NCPUONLINE
250# if 0 == HAVE_DECL_HW_NCPUONLINE
251# undef HAVE_DECL_HW_NCPUONLINE
252# else /* 0 != HAVE_DECL_HW_NCPUONLINE */
253# define HAS_DECL_HW_NCPUONLINE 1
254# endif /* 0 != HAVE_DECL_HW_NCPUONLINE */
255#endif /* HAVE_DECL_HW_NCPUONLINE */
256
257#ifdef HAVE_DECL_HW_AVAILCPU
258# if 0 == HAVE_DECL_HW_AVAILCPU
259# undef HAVE_DECL_HW_AVAILCPU
260# else /* 0 != HAVE_DECL_HW_AVAILCPU */
261# define HAS_DECL_HW_AVAILCPU 1
262# endif /* 0 != HAVE_DECL_HW_AVAILCPU */
263#endif /* HAVE_DECL_HW_AVAILCPU */
264
265#ifdef HAVE_DECL_HW_NCPU
266# if 0 == HAVE_DECL_HW_NCPU
267# undef HAVE_DECL_HW_NCPU
268# else /* 0 != HAVE_DECL_HW_NCPU */
269# define HAS_DECL_HW_NCPU 1
270# endif /* 0 != HAVE_DECL_HW_NCPU */
271#endif /* HAVE_DECL_HW_NCPU */
272
273#ifdef HAVE_DECL_CPU_SETSIZE
274# if 0 == HAVE_DECL_CPU_SETSIZE
275# undef HAVE_DECL_CPU_SETSIZE
276# else /* 0 != HAVE_DECL_CPU_SETSIZE */
277# define HAS_DECL_CPU_SETSIZE 1
278# endif /* 0 != HAVE_DECL_CPU_SETSIZE */
279#endif /* HAVE_DECL_CPU_SETSIZE */
280
281#ifndef MHD_DAUTH_DEF_TIMEOUT_
282# define MHD_DAUTH_DEF_TIMEOUT_ 90
283#endif /* ! MHD_DAUTH_DEF_TIMEOUT_ */
284#ifndef MHD_DAUTH_DEF_MAX_NC_
285# define MHD_DAUTH_DEF_MAX_NC_ 1000
286#endif /* ! MHD_DAUTH_DEF_MAX_NC_ */
287
288#endif /* MHD_OPTIONS_H */