GNU libmicrohttpd 0.9.77
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
31#ifndef MHD_OPTIONS_H
32#define MHD_OPTIONS_H 1
33
34#include "MHD_config.h"
35
42#define _(String) (String)
43
44
45#ifndef _MHD_EXTERN
46#if defined(BUILDING_MHD_LIB) && defined(_WIN32) && \
47 (defined(DLL_EXPORT) || defined(MHD_W32DLL))
48#define _MHD_EXTERN __declspec(dllexport) extern
49#else /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */
50#define _MHD_EXTERN extern
51#endif /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */
52#endif /* ! _MHD_EXTERN */
53
54/* Some platforms (FreeBSD, Solaris, W32) allow to override
55 default FD_SETSIZE by defining it before including
56 headers. */
57#ifdef FD_SETSIZE
58/* FD_SETSIZE defined in command line or in MHD_config.h */
59#elif defined(_WIN32) || defined(__CYGWIN__)
60/* Platform with WinSock and without overridden FD_SETSIZE */
61#define FD_SETSIZE 2048 /* Override default small value (64) */
62#else /* !FD_SETSIZE && !W32 */
63/* System default value of FD_SETSIZE is used */
64#define _MHD_FD_SETSIZE_IS_DEFAULT 1
65#endif /* !FD_SETSIZE && !W32 */
66
67#if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE) || \
68 defined(HAVE_DARWIN_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
69/* Have any supported sendfile() function. */
70#define _MHD_HAVE_SENDFILE
71#endif /* HAVE_LINUX_SENDFILE || HAVE_FREEBSD_SENDFILE ||
72 HAVE_DARWIN_SENDFILE || HAVE_SOLARIS_SENDFILE */
73#if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_SOLARIS_SENDFILE)
74#define MHD_LINUX_SOLARIS_SENDFILE 1
75#endif /* HAVE_LINUX_SENDFILE || HAVE_SOLARIS_SENDFILE */
76
77#if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
78# ifndef MHD_USE_THREADS
79# define MHD_USE_THREADS 1
80# endif
81#endif /* MHD_USE_POSIX_THREADS || MHD_USE_W32_THREADS */
82
83#if OS390
84#define _OPEN_THREADS
85#define _OPEN_SYS_SOCK_IPV6
86#define _OPEN_MSGQ_EXT
87#define _LP64
88#endif
89
90#if defined(_WIN32) && ! defined(__CYGWIN__)
91/* Declare POSIX-compatible names */
92#define _CRT_DECLARE_NONSTDC_NAMES 1
93/* Do not warn about POSIX name usage */
94#define _CRT_NONSTDC_NO_WARNINGS 1
95#ifndef _WIN32_WINNT
96#define _WIN32_WINNT 0x0600
97#else /* _WIN32_WINNT */
98#if _WIN32_WINNT < 0x0501
99#error "Headers for Windows XP or later are required"
100#endif /* _WIN32_WINNT < 0x0501 */
101#endif /* _WIN32_WINNT */
102#ifndef WIN32_LEAN_AND_MEAN
103/* Do not include unneeded parts of W32 headers. */
104#define WIN32_LEAN_AND_MEAN 1
105#endif /* !WIN32_LEAN_AND_MEAN */
106#endif /* _WIN32 && ! __CYGWIN__ */
107
108#if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
109#define RESTRICT __restrict__
110#endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */
111
112#if LINUX + 0 && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && \
113 ! defined(_LARGEFILE64_SOURCE)
114/* On Linux, special macro is required to enable definitions of some xxx64 functions */
115#define _LARGEFILE64_SOURCE 1
116#endif
117
118#ifdef HAVE_C11_GMTIME_S
119/* Special macro is required to enable C11 definition of gmtime_s() function */
120#define __STDC_WANT_LIB_EXT1__ 1
121#endif /* HAVE_C11_GMTIME_S */
122
123#if defined(MHD_FAVOR_FAST_CODE) && defined(MHD_FAVOR_SMALL_CODE)
124#error \
125 MHD_FAVOR_FAST_CODE and MHD_FAVOR_SMALL_CODE are both defined. Cannot favor speed and size at the same time.
126#endif /* MHD_FAVOR_FAST_CODE && MHD_FAVOR_SMALL_CODE */
127
128/* Define MHD_FAVOR_FAST_CODE to force fast code path or
129 define MHD_FAVOR_SMALL_CODE to choose compact code path */
130#if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE)
131/* Try to detect user preferences */
132/* Defined by GCC and many compatible compilers */
133#if defined(__OPTIMIZE_SIZE__)
134#define MHD_FAVOR_SMALL_CODE 1
135#elif defined(__OPTIMIZE__)
136#define MHD_FAVOR_FAST_CODE 1
137#endif /* __OPTIMIZE__ */
138#endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */
139
140#if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE)
141/* Use faster code by default */
142#define MHD_FAVOR_FAST_CODE 1
143#endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */
144
145#ifndef MHD_ASAN_ACTIVE
146#if (defined(__GNUC__) || defined(_MSC_VER)) && defined(__SANITIZE_ADDRESS__)
147#define MHD_ASAN_ACTIVE 1
148#elif defined(__has_feature)
149#if __has_feature (address_sanitizer)
150#define MHD_ASAN_ACTIVE 1
151#endif /* __has_feature(address_sanitizer) */
152#endif /* __has_feature */
153#endif /* MHD_ASAN_ACTIVE */
154
155#if defined(MHD_ASAN_ACTIVE) && defined(HAVE_SANITIZER_ASAN_INTERFACE_H) && \
156 (defined(FUNC_ATTR_PTRCOMPARE_WOKRS) || defined(FUNC_ATTR_NOSANITIZE_WORKS))
157#ifndef MHD_ASAN_POISON_ACTIVE
158/* Manual ASAN poisoning could be used */
159#warning User memory poisoning is not active
160#endif /* ! MHD_ASAN_POISON_ACTIVE */
161#else /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H &&
162 (FUNC_ATTR_PTRCOMPARE_WOKRS || FUNC_ATTR_NOSANITIZE_WORKS)) */
163#ifdef MHD_ASAN_POISON_ACTIVE
164#error User memory poisoning is active, but conditions are not suitable
165#endif /* MHD_ASAN_POISON_ACTIVE */
166#endif /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H &&
167 (FUNC_ATTR_PTRCOMPARE_WOKRS || FUNC_ATTR_NOSANITIZE_WORKS)) */
168
169
173#if defined(HAVE___FUNC__)
174#define MHD_FUNC_ __func__
175#elif defined(HAVE___FUNCTION__)
176#define MHD_FUNC_ __FUNCTION__
177#elif defined(HAVE___PRETTY_FUNCTION__)
178#define MHD_FUNC_ __PRETTY_FUNCTION__
179#else
180#define MHD_FUNC_ "**name unavailable**"
181#endif
182
183
184#endif /* MHD_OPTIONS_H */