libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

mhd_sys_options.h (21842B)


      1 /* SPDX-License-Identifier: LGPL-2.1-or-later OR (GPL-2.0-or-later WITH eCos-exception-2.0) */
      2 /*
      3   This file is part of GNU libmicrohttpd.
      4   Copyright (C) 2016-2025 Karlson2k (Evgeny Grin)
      5 
      6   GNU libmicrohttpd is free software; you can redistribute it and/or
      7   modify it under the terms of the GNU Lesser General Public
      8   License as published by the Free Software Foundation; either
      9   version 2.1 of the License, or (at your option) any later version.
     10 
     11   GNU libmicrohttpd is distributed in the hope that it will be useful,
     12   but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14   Lesser General Public License for more details.
     15 
     16   Alternatively, you can redistribute GNU libmicrohttpd and/or
     17   modify it under the terms of the GNU General Public License as
     18   published by the Free Software Foundation; either version 2 of
     19   the License, or (at your option) any later version, together
     20   with the eCos exception, as follows:
     21 
     22     As a special exception, if other files instantiate templates or
     23     use macros or inline functions from this file, or you compile this
     24     file and link it with other works to produce a work based on this
     25     file, this file does not by itself cause the resulting work to be
     26     covered by the GNU General Public License. However the source code
     27     for this file must still be made available in accordance with
     28     section (3) of the GNU General Public License v2.
     29 
     30     This exception does not invalidate any other reasons why a work
     31     based on this file might be covered by the GNU General Public
     32     License.
     33 
     34   You should have received copies of the GNU Lesser General Public
     35   License and the GNU General Public License along with this library;
     36   if not, see <https://www.gnu.org/licenses/>.
     37 */
     38 
     39 /**
     40  * @file src/include/mhd_sys_options.h
     41  * @brief  additional automatic macros for mhd_config.h
     42  * @author Karlson2k (Evgeny Grin)
     43  *
     44  * This file includes mhd_config.h and adds automatic macros based on values
     45  * in mhd_config.h, compiler built-in macros and commandline-defined macros
     46  * (but not based on values defined in other headers). Works also as a guard
     47  * to prevent double inclusion of mhd_config.h
     48  *
     49  * This file must be included always before other headers as this header
     50  * defines macros that control behaviour of other included headers.
     51  */
     52 
     53 #ifndef MHD_SYS_OPTIONS_H
     54 #define MHD_SYS_OPTIONS_H 1
     55 
     56 #ifndef HAVE_CONFIG_H
     57 #  ifndef _MSC_VER
     58 #error HAVE_CONFIG_H must be defined
     59 #  endif
     60 #endif
     61 
     62 #ifdef _WIN64
     63 /* workaround for some broken compilers */
     64 #  ifndef _WIN32
     65 #    define _WIN32 1
     66 #  endif
     67 #endif
     68 
     69 #include "mhd_config.h"
     70 
     71 /**
     72  * Macro to make it easy to mark text for translation. Note that
     73  * we do not actually call gettext() in MHD, but we do make it
     74  * easy to create a ".po" file so that applications that do want
     75  * to translate error messages can do so.
     76  */
     77 #define _(String) (String)
     78 
     79 #ifdef HAVE_ATTR_VISIBILITY_DEFAULT
     80 #  define MHD_VISIBILITY_EXTERN __attribute__((visibility ("default")))
     81 #else
     82 #  define MHD_VISIBILITY_EXTERN         /* empty */
     83 #endif
     84 
     85 #if ! defined(_WIN32) || \
     86   (! defined(DLL_EXPORT)    /* Defined by libtool for shared version */ \
     87   && ! defined(MHD_W32DLL) /* Defined by MS VS projects for MHD DLL */)
     88 #  define MHD_EXPORTED  /* empty */
     89 #else
     90 #  define MHD_EXPORTED __declspec(dllexport)
     91 #endif
     92 
     93 #if defined(HAVE_ATTR_USED) \
     94   && (defined(PIC) || defined(DLL_EXPORT) || defined(MHD_W32DLL))
     95 /* Used externally, only for functions in shared library */
     96 #  define MHD_EXTERN_USED __attribute__((used))
     97 #else
     98 #  define MHD_EXTERN_USED       /* empty */
     99 #endif
    100 
    101 #if defined(HAVE_ATTR_EXTERN_VISIBLE) \
    102   && (defined(PIC) || defined(DLL_EXPORT) || defined(MHD_W32DLL))
    103 #  define mhd_EXTERNALLY_ACCESSIBLE __attribute__ ((externally_visible))
    104 #else
    105 #  define mhd_EXTERNALLY_ACCESSIBLE     /* empty */
    106 #endif
    107 
    108 #if defined(MHD_EXTERN_) && defined(BUILDING_MHD_LIB)
    109 #  undef MHD_EXTERN_
    110 #endif /* MHD_EXTERN_ && BUILDING_MHD_LIB */
    111 
    112 #ifndef MHD_EXTERN_
    113 #  ifdef BUILDING_MHD_LIB
    114 /* Building MHD itself */
    115 #    define MHD_EXTERN_ \
    116         extern MHD_VISIBILITY_EXTERN MHD_EXPORTED \
    117         mhd_EXTERNALLY_ACCESSIBLE MHD_EXTERN_USED
    118 #  else  /* ! BUILDING_MHD_LIB */
    119 /* Test or example code, using MHD as a library */
    120 #    define MHD_EXTERN_ extern
    121 #  endif /* ! BUILDING_MHD_LIB */
    122 #endif  /* ! MHD_EXTERN_ */
    123 
    124 #ifdef HAVE_ATTR_VISIBILITY_HIDDEN
    125 /* To be used with internal non-static functions, that can be potentially used
    126  * externally via function pointers */
    127 #  define MHD_VISIBILITY_HIDDEN __attribute__((visibility ("hidden")))
    128 #else
    129 /* To be used with internal non-static functions, that can be potentially used
    130  * externally via function pointers */
    131 #  define MHD_VISIBILITY_HIDDEN         /* empty */
    132 #endif
    133 
    134 #ifdef HAVE_ATTR_VISIBILITY_INTERNAL
    135 /* To be used with internal non-static functions */
    136 #  define MHD_VISIBILITY_INTERNAL __attribute__((visibility ("internal")))
    137 #else
    138 /* To be used with internal non-static functions */
    139 #  define MHD_VISIBILITY_INTERNAL MHD_VISIBILITY_HIDDEN
    140 #endif
    141 
    142 /* To be used with internal non-static functions */
    143 #define MHD_INTERNAL MHD_VISIBILITY_INTERNAL
    144 
    145 #ifdef HAVE_ATTR_PURE
    146 #  define MHD_FN_PURE_ __attribute__((pure))
    147 #else
    148 #  define MHD_FN_PURE_  /* empty */
    149 #endif
    150 
    151 #ifdef HAVE_ATTR_CONST
    152 #  define MHD_FN_CONST_ __attribute__((const))
    153 #else
    154 #  define MHD_FN_CONST_ MHD_FN_PURE_
    155 #endif
    156 
    157 #ifdef HAVE_ATTR_WARN_UNUSED_RES
    158 #  define MHD_FN_MUST_CHECK_RESULT_ __attribute__ ((warn_unused_result))
    159 #else
    160 #  define MHD_FN_MUST_CHECK_RESULT_     /* empty */
    161 #endif
    162 
    163 #ifdef HAVE_ATTR_RET_NONNULL
    164 #  define MHD_FN_RETURNS_NONNULL_ __attribute__ ((returns_nonnull))
    165 #else
    166 #  define MHD_FN_RETURNS_NONNULL_       /* empty */
    167 #endif
    168 
    169 #ifdef HAVE_ATTR_NONNULL_NUM
    170 #  define MHD_FN_PAR_NONNULL_(param_num) __attribute__ ((nonnull (param_num)))
    171 #else
    172 #  define MHD_FN_PAR_NONNULL_(param_num)        /* empty */
    173 #endif
    174 
    175 #ifdef HAVE_ATTR_NONNULL
    176 #  define MHD_FN_PAR_NONNULL_ALL_ __attribute__ ((nonnull))
    177 #else
    178 #  define MHD_FN_PAR_NONNULL_ALL_       /* empty */
    179 #endif
    180 
    181 #ifdef HAVE_ATTR_ACCESS_READ
    182 #  define MHD_FN_PAR_IN_(param_num) \
    183         __attribute__ ((access (read_only,param_num)))
    184 #else
    185 #  define MHD_FN_PAR_IN_(param_num)     /* empty */
    186 #endif
    187 
    188 #ifdef HAVE_ATTR_ACCESS_READ_SIZE
    189 #  define MHD_FN_PAR_IN_SIZE_(param_num,size_num) \
    190         __attribute__ ((access (read_only,param_num,size_num)))
    191 #else
    192 #  define MHD_FN_PAR_IN_SIZE_(param_num,size_num)       /* empty */
    193 #endif
    194 
    195 #ifdef HAVE_ATTR_ACCESS_READ_WRITE
    196 #  define MHD_FN_PAR_OUT_(param_num) \
    197         __attribute__ ((access (write_only,param_num)))
    198 #else
    199 #  define MHD_FN_PAR_OUT_(param_num)    /* empty */
    200 #endif
    201 
    202 #ifdef HAVE_ATTR_ACCESS_WRITE
    203 #  define MHD_FN_PAR_OUT_SIZE_(param_num,size_num) \
    204         __attribute__ ((access (write_only,param_num,size_num)))
    205 #else
    206 #  define MHD_FN_PAR_OUT_SIZE_(param_num,size_num)      /* empty */
    207 #endif
    208 
    209 #ifdef HAVE_ATTR_ACCESS_READ_WRITE
    210 #  define MHD_FN_PAR_INOUT_(param_num) \
    211         __attribute__ ((access (read_write,param_num)))
    212 #else
    213 #  define MHD_FN_PAR_INOUT_(param_num)  /* empty */
    214 #endif
    215 
    216 #ifdef HAVE_ATTR_ACCESS_READ_WRITE_SIZE
    217 #  define MHD_FN_PAR_INOUT_SIZE_(param_num,size_num) \
    218         __attribute__ ((access (read_write,param_num,size_num)))
    219 #else
    220 #  define MHD_FN_PAR_INOUT_SIZE_(param_num,size_num)    /* empty */
    221 #endif
    222 
    223 #ifdef HAVE_ATTR_FD_ARG_READ
    224 #  define MHD_FN_PAR_FD_READ_(param_num) \
    225         __attribute__ ((fd_arg_read (param_num)))
    226 #else
    227 #  define MHD_FN_PAR_FD_READ_(param_num)        /* empty */
    228 #endif
    229 
    230 #ifdef HAVE_ATTR_NULL_TERM_STR
    231 #  define MHD_FN_PAR_CSTR_(param_num) \
    232         __attribute__ ((null_terminated_string_arg (param_num)))
    233 #else
    234 #  define MHD_FN_PAR_CSTR_(param_num)   /* empty */
    235 #endif
    236 
    237 #ifdef HAVE_FUNC_PARAM_ARR_STATIC_FIXED
    238 #  define MHD_FN_PAR_FIX_ARR_SIZE_(size)  static (size)
    239 #else
    240 #  define MHD_FN_PAR_FIX_ARR_SIZE_(size)  size
    241 #endif
    242 
    243 #ifdef HAVE_FUNC_PARAM_ARR_STATIC_VAR
    244 #  define MHD_FN_PAR_DYN_ARR_SIZE_(size)  static (size)
    245 #else
    246 #  define MHD_FN_PAR_DYN_ARR_SIZE_(size)  1
    247 #endif
    248 
    249 #ifdef HAVE_ATTR_FUNC_ASSUME_ALIGNED
    250 #  define mhd_FN_RET_ALIGNED(align) __attribute__((assume_aligned (align)))
    251 #else
    252 #  define mhd_FN_RET_ALIGNED(align)     /* empty */
    253 #endif
    254 
    255 #ifdef HAVE_ATTR_FUNC_ALLOC_SIZE
    256 /**
    257  * Indicates that returned pointer points to object with the size specified
    258  * by parameter number @a param_num.
    259  */
    260 #  define mhd_FN_RET_SIZED(param_num) __attribute__((alloc_size (param_num)))
    261 #else
    262 /**
    263  * Indicates that returned pointer points to object with the size specified
    264  * by parameter number @a param_num.
    265  */
    266 #  define mhd_FN_RET_SIZED(param_num)   /* empty */
    267 #endif
    268 
    269 #ifdef HAVE_ATTR_FUNC_MALLOC
    270 /**
    271  * Indicates that returned pointer is unique and does not alias any other
    272  * pointers.
    273  */
    274 #  define mhd_FN_RET_UNALIASED __attribute__((malloc))
    275 #else
    276 /**
    277  * Indicates that returned pointer is unique and does not alias any other
    278  * pointers.
    279  */
    280 #  define mhd_FN_RET_UNALIASED  /* empty */
    281 #endif
    282 
    283 #ifdef HAVE_ATTR_FUNC_MALLOC_DEALLOC
    284 /**
    285  * Indicates that function creates the object that mast be destructed by
    286  * another function @a destructor.
    287  */
    288 #  define mhd_FN_OBJ_CONSTRUCTOR(destructor) \
    289         __attribute__((malloc (destructor)))
    290 #else
    291 /**
    292  * Indicates that function creates the object that mast be destructed by
    293  * another function @a destructor.
    294  */
    295   #  define mhd_FN_OBJ_CONSTRUCTOR(destructor)  /* empty */
    296 #endif
    297 
    298 #ifdef HAVE_ATTR_ENUM_EXTNS_CLOSED
    299 #  define MHD_FIXED_ENUM_ __attribute__((enum_extensibility (closed)))
    300 #else
    301 #  define MHD_FIXED_ENUM_       /* empty */
    302 #endif
    303 
    304 #ifdef HAVE_ATTR_FLAG_ENUM
    305 #  define MHD_FLAGS_ENUM_ __attribute__((flag_enum))
    306 #else
    307 #  define MHD_FLAGS_ENUM_       /* empty */
    308 #endif /* MHD_FLAGS_ENUM_ */
    309 
    310 #define MHD_FIXED_FLAGS_ENUM_ MHD_FIXED_ENUM_ MHD_FLAGS_ENUM_
    311 
    312 /* 'inline' and 'restrict' are defined in mhd_config.h if needed */
    313 #define MHD_INLINE inline
    314 
    315 #define MHD_RESTRICT restrict
    316 
    317 #ifdef BUILDING_MHD_LIB
    318 #  define MHD_FIXED_ENUM_APP_SET_ /* empty */ /* handle unknown values set by the app */
    319 #else
    320 #  define MHD_FIXED_ENUM_APP_SET_ MHD_FIXED_ENUM_
    321 #endif
    322 
    323 #ifdef BUILDING_MHD_LIB
    324 #  define MHD_FLAGS_ENUM_APP_SET_ MHD_FLAGS_ENUM_
    325 #else
    326 #  define MHD_FLAGS_ENUM_APP_SET_ MHD_FLAGS_ENUM_
    327 #endif
    328 
    329 #ifdef BUILDING_MHD_LIB
    330 #  define MHD_FIXED_FLAGS_ENUM_APP_SET_ MHD_FLAGS_ENUM_ /* handle unknown values set by the app */
    331 #else
    332 #  define MHD_FIXED_FLAGS_ENUM_APP_SET_ MHD_FIXED_FLAGS_ENUM_
    333 #endif
    334 
    335 #ifdef BUILDING_MHD_LIB
    336 #  define MHD_FIXED_ENUM_MHD_SET_ MHD_FIXED_ENUM_
    337 #else
    338 #  define MHD_FIXED_ENUM_MHD_SET_ /* empty */ /* enum can be extended in next MHD versions */
    339 #endif
    340 
    341 #ifdef BUILDING_MHD_LIB
    342 #  define MHD_FLAGS_ENUM_MHD_SET_ MHD_FLAGS_ENUM_
    343 #else
    344 #  define MHD_FLAGS_ENUM_MHD_SET_ MHD_FLAGS_ENUM_
    345 #endif
    346 
    347 #ifdef BUILDING_MHD_LIB
    348 #  define MHD_FIXED_FLAGS_ENUM_MHD_SET_ MHD_FIXED_FLAGS_ENUM_
    349 #else
    350 #  define MHD_FIXED_FLAGS_ENUM_MHD_SET_ MHD_FLAGS_ENUM_ /* enum can be extended in next MHD versions */
    351 #endif
    352 
    353 #ifdef BUILDING_MHD_LIB
    354 #  define MHD_FIXED_ENUM_MHD_APP_SET_ /* empty */ /* handle unknown values set by the app */
    355 #else
    356 #  define MHD_FIXED_ENUM_MHD_APP_SET_ /* empty */ /* enum can be extended in next MHD versions */
    357 #endif
    358 
    359 #ifdef BUILDING_MHD_LIB
    360 #  define MHD_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_
    361 #else
    362 #  define MHD_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_
    363 #endif
    364 
    365 #ifdef BUILDING_MHD_LIB
    366 #  define MHD_FIXED_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_ /* handle unknown values set by the app */
    367 #else
    368 #  define MHD_FIXED_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_ /* enum can be extended in next MHD versions */
    369 #endif
    370 
    371 // TODO: support warnings mute
    372 #ifdef HAVE_ENUM_BASE_TYPE_WARNLESS
    373 #  define mhd_USE_ENUM_BASE_T   1
    374 #endif
    375 #ifdef mhd_USE_ENUM_BASE_T
    376 #  define mhd_ENUM_BASE_T(fixed_type) : fixed_type
    377 #else
    378 #  define mhd_ENUM_BASE_T(fixed_type) /* empty */
    379 #endif
    380 
    381 /**
    382  * Automatic string with the name of the current function
    383  */
    384 #if defined(HAVE___FUNC__)
    385 #  define MHD_FUNC_       __func__
    386 #  define MHD_HAVE_MHD_FUNC_ 1
    387 #elif defined(HAVE___FUNCTION__)
    388 #  define MHD_FUNC_       __FUNCTION__
    389 #  define MHD_HAVE_MHD_FUNC_ 1
    390 #elif defined(HAVE___PRETTY_FUNCTION__)
    391 #  define MHD_FUNC_       __PRETTY_FUNCTION__
    392 #  define MHD_HAVE_MHD_FUNC_ 1
    393 #else
    394 #  define MHD_FUNC_       "**name unavailable**"
    395 #  ifdef MHD_HAVE_MHD_FUNC_
    396 #    undef MHD_HAVE_MHD_FUNC_
    397 #  endif /* MHD_HAVE_MHD_FUNC_ */
    398 #endif
    399 
    400 /* Some platforms (FreeBSD, Solaris, W32) allow to override
    401    default FD_SETSIZE by defining it before including
    402    headers. */
    403 #ifdef FD_SETSIZE
    404 /* FD_SETSIZE defined in command line or in mhd_config.h */
    405 #elif defined(_WIN32) || defined(__CYGWIN__)
    406 /* Platform with WinSock and without overridden FD_SETSIZE */
    407 #  ifdef _WIN64
    408 #    define FD_SETSIZE 4096 /* Override default small value (64) */
    409 #  else
    410 #    define FD_SETSIZE 1024 /* Override default small value (64) */
    411 #  endif
    412 #else  /* !FD_SETSIZE && !W32 */
    413 /* System default value of FD_SETSIZE is used */
    414 #  define MHD_FD_SETSIZE_IS_DEFAULT_ 1
    415 #endif /* !FD_SETSIZE && !W32 */
    416 
    417 #if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE) || \
    418   defined(HAVE_DARWIN_SENDFILE)
    419 /* Have any supported sendfile() function. */
    420 #  define mhd_USE_SENDFILE 1
    421 #endif /* HAVE_LINUX_SENDFILE || HAVE_FREEBSD_SENDFILE
    422           || HAVE_DARWIN_SENDFILE */
    423 
    424 #if defined(mhd_THREADS_KIND_POSIX) || defined(mhd_THREADS_KIND_W32)
    425 #  ifndef MHD_SUPPORT_THREADS
    426 #    define MHD_SUPPORT_THREADS 1
    427 #  endif
    428 #endif /* mhd_THREADS_KIND_POSIX || mhd_THREADS_KIND_W32 */
    429 
    430 #if defined(_WIN32) && ! defined(__CYGWIN__)
    431 /**
    432  * Defined if the platform is native W32.
    433  * Not define on Cygwin.
    434  */
    435 #  define mhd_W32_NATIVE        1
    436 #endif
    437 /**
    438  * Macro to drop 'const' qualifier from pointer.
    439  * Try to avoid compiler warning.
    440  * To be used *only* to deal with broken external APIs, which require non-const
    441  * pointer to unmodifiable data.
    442  * Must not be used to transform pointers for internal MHD needs.
    443  */
    444 #ifdef HAVE_UINTPTR_T
    445 #  define mhd_DROP_CONST(ptr)  ((void *) ((uintptr_t) ((const void *) (ptr))))
    446 #elif defined(HAVE_INTPTR_T)
    447 #  define mhd_DROP_CONST(ptr)  ((void *) ((intptr_t) ((const void *) (ptr))))
    448 #else
    449 #  define mhd_DROP_CONST(ptr)  ((void *) ((const void *) (ptr)))
    450 #endif
    451 
    452 /**
    453  * Cast signed integer to pointer
    454  */
    455 #if defined(HAVE_INTPTR_T)
    456 #  define mhd_INT_TO_PTR(i)  ((void *) ((intptr_t) (i)))
    457 #else
    458 #  define mhd_INT_TO_PTR(i)  ((void *) (i))
    459 #endif
    460 
    461 /**
    462  * Cast unsigned integer to pointer
    463  */
    464 #if defined(HAVE_UINTPTR_T)
    465 #  define mhd_UINT_TO_PTR(i)  ((void *) ((uintptr_t) (i)))
    466 #else
    467 #  define mhd_UINT_TO_PTR(i)  ((void *) (i))
    468 #endif
    469 
    470 
    471 #if defined(OS390)
    472 #define _OPEN_THREADS
    473 #define _OPEN_SYS_SOCK_IPV6
    474 #define _OPEN_MSGQ_EXT
    475 #define _LP64
    476 #endif
    477 
    478 #if defined(_WIN32) && ! defined(__CYGWIN__)
    479 /* Declare POSIX-compatible names */
    480 #  define _CRT_DECLARE_NONSTDC_NAMES 1
    481 /* Do not warn about POSIX name usage */
    482 #  define _CRT_NONSTDC_NO_WARNINGS 1
    483 #  ifndef _WIN32_WINNT
    484 #    define _WIN32_WINNT 0x0600
    485 #  else /* _WIN32_WINNT */
    486 #    if _WIN32_WINNT < 0x0501
    487 #error "Headers for Windows XP or later are required"
    488 #    endif /* _WIN32_WINNT < 0x0501 */
    489 #  endif /* _WIN32_WINNT */
    490 #  ifndef WIN32_LEAN_AND_MEAN
    491 /* Do not include unneeded parts of W32 headers. */
    492 #    define WIN32_LEAN_AND_MEAN 1
    493 #  endif /* !WIN32_LEAN_AND_MEAN */
    494 #endif /* _WIN32 && ! __CYGWIN__ */
    495 
    496 #if defined(__MINGW32__)
    497 #  ifndef __USE_MINGW_ANSI_STDIO
    498 #    define __USE_MINGW_ANSI_STDIO 0 /* Force use native printf, the code is well-adapted */
    499 #  endif
    500 #endif
    501 
    502 #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS)
    503 #define RESTRICT __restrict__
    504 #endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */
    505 
    506 #if defined(__linux__) && \
    507   (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64) || defined(HAVE_PREAD64))
    508 #  if ! defined(_LARGEFILE64_SOURCE)
    509 /* On Linux, special macro is required to enable definitions of some xxx64 functions */
    510 #    define _LARGEFILE64_SOURCE 1
    511 #  endif
    512 #endif
    513 
    514 #ifdef HAVE_C11_GMTIME_S
    515 /* Special macro is required to enable C11 definition of gmtime_s() function */
    516 #define __STDC_WANT_LIB_EXT1__ 1
    517 #endif /* HAVE_C11_GMTIME_S */
    518 
    519 /* Ensure that exactly one of the two macros is always defined */
    520 #if defined(NDEBUG) && defined(_DEBUG)
    521 #error Both _DEBUG and NDEBUG are defined
    522 #elif ! defined(_DEBUG) && ! defined(NDEBUG)
    523 #  ifndef DEBUG /* Used by some toolchains */
    524 #    define NDEBUG 1 /* Use NDEBUG by default */
    525 #  else  /* DEBUG */
    526 #    define _DEBUG 1 /* Non-standard macro */
    527 #  endif /* DEBUG */
    528 #endif /* !_DEBUG && !NDEBUG */
    529 
    530 #if ! defined(MHD_CC_OPTIMISE_FOR_SIZE) \
    531   && ! defined(MHD_CC_OPTIMISE_FOR_SPEED)
    532 #  if defined(__OPTIMIZE_SIZE__) || defined(__OPTIMISE_SPACE)
    533 #    define MHD_CC_OPTIMISE_FOR_SIZE   1
    534 #  elif defined(__OPTIMIZE__) || defined(__OPTIMISE_TIME)
    535 #    define MHD_CC_OPTIMISE_FOR_SPEED   1
    536 #  endif /* __OPTIMIZE__ */
    537 #elif defined(MHD_CC_OPTIMISE_FOR_SIZE) && defined(MHD_CC_OPTIMISE_FOR_SPEED)
    538 #error MHD_CC_OPTIMISE_FOR_SIZE and MHD_CC_OPTIMISE_FOR_SPEED are both defined.
    539 #endif
    540 
    541 #if defined(MHD_FAVOR_FAST_CODE) && defined(MHD_FAVOR_SMALL_CODE)
    542 #error MHD_FAVOR_FAST_CODE and MHD_FAVOR_SMALL_CODE are both defined.
    543 #error Cannot favor speed and size at the same time.
    544 #endif /* MHD_FAVOR_FAST_CODE && MHD_FAVOR_SMALL_CODE */
    545 
    546 /* Define MHD_FAVOR_FAST_CODE to force fast code path or
    547    define MHD_FAVOR_SMALL_CODE to choose compact code path */
    548 #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE)
    549 /* Try to guess automatically user preferences */
    550 #  if defined(MHD_CC_OPTIMISE_FOR_SPEED)
    551 #    define MHD_FAVOR_FAST_CODE         1
    552 #  elif defined(MHD_CC_OPTIMISE_FOR_SIZE)
    553 #    define MHD_FAVOR_SMALL_CODE        1
    554 #  endif /* __OPTIMIZE__ */
    555 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */
    556 
    557 #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE)
    558 /* Use faster code by default */
    559 #  define MHD_FAVOR_FAST_CODE 1
    560 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */
    561 
    562 #if defined(MHD_FAVOR_SMALL_CODE) && defined(mhd_static_inline)
    563 #  undef mhd_static_inline
    564 #  define mhd_static_inline static inline /* give compiler more freedom */
    565 #endif
    566 
    567 #ifndef MHD_ASAN_ACTIVE
    568 #if (defined(__GNUC__) || defined(_MSC_VER)) && defined(__SANITIZE_ADDRESS__)
    569 #define MHD_ASAN_ACTIVE 1
    570 #elif defined(__has_feature)
    571 #if __has_feature (address_sanitizer)
    572 #define MHD_ASAN_ACTIVE 1
    573 #endif /* __has_feature(address_sanitizer) */
    574 #endif /* __has_feature */
    575 #endif /* MHD_ASAN_ACTIVE */
    576 
    577 #if defined(MHD_ASAN_ACTIVE) && defined(HAVE_SANITIZER_ASAN_INTERFACE_H) && \
    578   (defined(FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS) || \
    579   (defined(FUNC_ATTR_PTRCOMPARE_WORKS) && \
    580   defined(FUNC_ATTR_PTRSUBTRACT_WORKS)) || \
    581   defined(FUNC_ATTR_NOSANITIZE_WORKS))
    582 #  ifndef MHD_ASAN_POISON_ACTIVE
    583 /* User ASAN poisoning could be used */
    584 #    warning User memory poisoning is not active
    585 #  endif /* ! MHD_ASAN_POISON_ACTIVE */
    586 #else  /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H &&
    587            (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS))   */
    588 #  ifdef MHD_ASAN_POISON_ACTIVE
    589 #error User memory poisoning is active, but conditions are not suitable
    590 #  endif /* MHD_ASAN_POISON_ACTIVE */
    591 #endif /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H &&
    592            (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS))   */
    593 
    594 #ifndef _MSC_FULL_VER
    595 #  define mhd_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE /* empty */
    596 #  define mhd_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE /* empty */
    597 #else  /* _MSC_FULL_VER */
    598 #  define mhd_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE \
    599         __pragma(runtime_checks("c", off))
    600 #  define mhd_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE \
    601         __pragma(runtime_checks("c", restore))
    602 #endif /* _MSC_FULL_VER */
    603 
    604 
    605 #if ! defined(mhd_W32_NATIVE)
    606 /**
    607  * Indicate that suppression of SIGPIPE is required for some network
    608  * system calls.
    609  */
    610 #  define mhd_SEND_SPIPE_SUPPRESS_NEEDED     1
    611 #endif
    612 
    613 #ifndef NDEBUG
    614 #  ifndef MHD_NO_TLS_DEBUG_MESSAGES
    615 #    ifndef mhd_USE_TLS_DEBUG_MESSAGES
    616 /**
    617  * Enable debugging output on TLS library (if possible)
    618  */
    619 #      define mhd_USE_TLS_DEBUG_MESSAGES    1
    620 #    endif
    621 #  endif
    622 #endif
    623 
    624 #ifndef mhd_DEBUG_POLLING_FDS
    625 /* Use debug-print for FDs polling */
    626 /* #  define mhd_DEBUG_POLLING_FDS 1 */
    627 #endif
    628 
    629 #ifndef mhd_DEBUG_SUSPEND_RESUME
    630 /* Use debug-print for suspending and resuming of the requests */
    631 /* #  define mhd_DEBUG_SUSPEND_RESUME 1 */
    632 #endif
    633 
    634 #ifndef mhd_DEBUG_CONN_ADD_CLOSE
    635 /* Use debug-print for adding and closing of the connections */
    636 /* #  define mhd_DEBUG_CONN_ADD_CLOSE 1 */
    637 #endif
    638 
    639 #ifndef MHD_AUTH_DIGEST_DEF_TIMEOUT
    640 #  define MHD_AUTH_DIGEST_DEF_TIMEOUT 90
    641 #endif /* ! MHD_AUTH_DIGEST_DEF_TIMEOUT */
    642 #ifndef MHD_AUTH_DIGEST_DEF_MAX_NC
    643 #  define MHD_AUTH_DIGEST_DEF_MAX_NC 1000
    644 #endif /* ! MHD_AUTH_DIGEST_DEF_MAX_NC */
    645 
    646 #ifndef mhd_HAVE_TLS_THREAD_CLEANUP
    647 #  ifdef MHD_SUPPORT_OPENSSL
    648 /**
    649  * If defined then mhd_tls_thread_cleanup() is a real function.
    650  * If not defined then mhd_tls_thread_cleanup() is an empty macro
    651  */
    652 #    define mhd_HAVE_TLS_THREAD_CLEANUP         1
    653 #  endif
    654 #endif
    655 
    656 /* Eclipse parse compatibility */
    657 #ifdef __CDT_PARSER__
    658 #  undef MHD_NORETURN_
    659 #  define MHD_NORETURN_ __attribute__((__noreturn__))
    660 #  undef mhd_FALLTHROUGH
    661 #  define mhd_FALLTHROUGH ((void) 0)
    662 #  undef _Atomic
    663 #  define _Atomic /* empty */
    664 #  undef MHD_HAVE_C_CONSTEXPR
    665 #  if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 202311)
    666 #    define bool    _Bool
    667 #    define true    1
    668 #    define false   0
    669 #  elif defined __has_include
    670 #    if __has_include (<stdbool.h>)
    671 #      define HAVE_STDBOOL_H    1
    672 #    endif
    673 #  endif
    674 #  define mhd_ENUM_BASE_T(base) /* nothing */
    675 #  if ((__STDC_VERSION__ + 0) >= 202311)
    676 #    define alignof _Alignof
    677 #  endif
    678 #  define __auto_type auto
    679 #endif
    680 
    681 /* Avoid interference with third-party headers */
    682 #ifdef HAVE_CONFIG_H
    683 #  undef HAVE_CONFIG_H
    684 #endif
    685 
    686 #endif /* MHD_SYS_OPTIONS_H */