mhd_sys_options.h (22144B)
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 #if defined(MICROHTTPD2_H) || defined(MICROHTTPD2_PORTABILITY_H) 57 #error the header "mhd_sys_options.h" must be included before any other header 58 #endif 59 60 #ifndef HAVE_CONFIG_H 61 # ifndef _MSC_VER 62 #error HAVE_CONFIG_H must be defined 63 # endif 64 #endif 65 66 #ifdef _WIN64 67 /* workaround for some broken compilers */ 68 # ifndef _WIN32 69 # define _WIN32 1 70 # endif 71 #endif 72 73 #include "mhd_config.h" 74 75 #ifdef HAVE_ATTR_VISIBILITY_DEFAULT 76 # define MHD_VISIBILITY_EXTERN __attribute__((visibility ("default"))) 77 #else 78 # define MHD_VISIBILITY_EXTERN /* empty */ 79 #endif 80 81 #if ! defined(_WIN32) || \ 82 (! defined(DLL_EXPORT) /* Defined by libtool for shared version */ \ 83 && ! defined(MHD_W32DLL) /* Defined by MS VS projects for MHD DLL */) 84 # define MHD_EXPORTED /* empty */ 85 #else 86 # define MHD_EXPORTED __declspec(dllexport) 87 #endif 88 89 #if defined(HAVE_ATTR_USED) \ 90 && (defined(PIC) || defined(DLL_EXPORT) || defined(MHD_W32DLL)) 91 /* Used externally, only for functions in shared library */ 92 # define MHD_EXTERN_USED __attribute__((used)) 93 #else 94 # define MHD_EXTERN_USED /* empty */ 95 #endif 96 97 #if defined(HAVE_ATTR_EXTERN_VISIBLE) \ 98 && (defined(PIC) || defined(DLL_EXPORT) || defined(MHD_W32DLL)) 99 # define mhd_EXTERNALLY_ACCESSIBLE __attribute__ ((externally_visible)) 100 #else 101 # define mhd_EXTERNALLY_ACCESSIBLE /* empty */ 102 #endif 103 104 #if defined(MHD_EXTERN_) && defined(BUILDING_MHD_LIB) 105 # undef MHD_EXTERN_ 106 #endif /* MHD_EXTERN_ && BUILDING_MHD_LIB */ 107 108 #ifndef MHD_EXTERN_ 109 # ifdef BUILDING_MHD_LIB 110 /* Building MHD itself */ 111 # define MHD_EXTERN_ \ 112 extern MHD_VISIBILITY_EXTERN MHD_EXPORTED \ 113 mhd_EXTERNALLY_ACCESSIBLE MHD_EXTERN_USED 114 # else /* ! BUILDING_MHD_LIB */ 115 /* Test or example code, using MHD as a library */ 116 # define MHD_EXTERN_ extern 117 # endif /* ! BUILDING_MHD_LIB */ 118 #endif /* ! MHD_EXTERN_ */ 119 120 #ifdef HAVE_ATTR_VISIBILITY_HIDDEN 121 /* To be used with internal non-static functions, that can be potentially used 122 * externally via function pointers */ 123 # define MHD_VISIBILITY_HIDDEN __attribute__((visibility ("hidden"))) 124 #else 125 /* To be used with internal non-static functions, that can be potentially used 126 * externally via function pointers */ 127 # define MHD_VISIBILITY_HIDDEN /* empty */ 128 #endif 129 130 #ifdef HAVE_ATTR_VISIBILITY_INTERNAL 131 /* To be used with internal non-static functions */ 132 # define MHD_VISIBILITY_INTERNAL __attribute__((visibility ("internal"))) 133 #else 134 /* To be used with internal non-static functions */ 135 # define MHD_VISIBILITY_INTERNAL MHD_VISIBILITY_HIDDEN 136 #endif 137 138 /* To be used with internal non-static functions */ 139 #define MHD_INTERNAL MHD_VISIBILITY_INTERNAL 140 141 #ifdef HAVE_ATTR_PURE 142 # define MHD_FN_PURE_ __attribute__((pure)) 143 #else 144 # define MHD_FN_PURE_ /* empty */ 145 #endif 146 147 #ifdef HAVE_ATTR_CONST 148 # define MHD_FN_CONST_ __attribute__((const)) 149 #else 150 # define MHD_FN_CONST_ MHD_FN_PURE_ 151 #endif 152 153 #ifdef HAVE_ATTR_WARN_UNUSED_RES 154 # define MHD_FN_MUST_CHECK_RESULT_ __attribute__ ((warn_unused_result)) 155 #else 156 # define MHD_FN_MUST_CHECK_RESULT_ /* empty */ 157 #endif 158 159 #ifdef HAVE_ATTR_RET_NONNULL 160 # define MHD_FN_RETURNS_NONNULL_ __attribute__ ((returns_nonnull)) 161 #else 162 # define MHD_FN_RETURNS_NONNULL_ /* empty */ 163 #endif 164 165 #ifdef HAVE_ATTR_NONNULL_NUM 166 # define MHD_FN_PAR_NONNULL_(param_num) __attribute__ ((nonnull (param_num))) 167 #else 168 # define MHD_FN_PAR_NONNULL_(param_num) /* empty */ 169 #endif 170 171 #ifdef HAVE_ATTR_NONNULL 172 # define MHD_FN_PAR_NONNULL_ALL_ __attribute__ ((nonnull)) 173 #else 174 # define MHD_FN_PAR_NONNULL_ALL_ /* empty */ 175 #endif 176 177 #ifdef HAVE_ATTR_ACCESS_READ 178 # define MHD_FN_PAR_IN_(param_num) \ 179 __attribute__ ((access (read_only,param_num))) 180 #else 181 # define MHD_FN_PAR_IN_(param_num) /* empty */ 182 #endif 183 184 #ifdef HAVE_ATTR_ACCESS_READ_SIZE 185 # define MHD_FN_PAR_IN_SIZE_(param_num,size_num) \ 186 __attribute__ ((access (read_only,param_num,size_num))) 187 #else 188 # define MHD_FN_PAR_IN_SIZE_(param_num,size_num) /* empty */ 189 #endif 190 191 #ifdef HAVE_ATTR_ACCESS_READ_WRITE 192 # define MHD_FN_PAR_OUT_(param_num) \ 193 __attribute__ ((access (write_only,param_num))) 194 #else 195 # define MHD_FN_PAR_OUT_(param_num) /* empty */ 196 #endif 197 198 #ifdef HAVE_ATTR_ACCESS_WRITE 199 # define MHD_FN_PAR_OUT_SIZE_(param_num,size_num) \ 200 __attribute__ ((access (write_only,param_num,size_num))) 201 #else 202 # define MHD_FN_PAR_OUT_SIZE_(param_num,size_num) /* empty */ 203 #endif 204 205 #ifdef HAVE_ATTR_ACCESS_READ_WRITE 206 # define MHD_FN_PAR_INOUT_(param_num) \ 207 __attribute__ ((access (read_write,param_num))) 208 #else 209 # define MHD_FN_PAR_INOUT_(param_num) /* empty */ 210 #endif 211 212 #ifdef HAVE_ATTR_ACCESS_READ_WRITE_SIZE 213 # define MHD_FN_PAR_INOUT_SIZE_(param_num,size_num) \ 214 __attribute__ ((access (read_write,param_num,size_num))) 215 #else 216 # define MHD_FN_PAR_INOUT_SIZE_(param_num,size_num) /* empty */ 217 #endif 218 219 #ifdef HAVE_ATTR_FD_ARG_READ 220 # define MHD_FN_PAR_FD_READ_(param_num) \ 221 __attribute__ ((fd_arg_read (param_num))) 222 #else 223 # define MHD_FN_PAR_FD_READ_(param_num) /* empty */ 224 #endif 225 226 #ifdef HAVE_ATTR_NULL_TERM_STR 227 # define MHD_FN_PAR_CSTR_(param_num) \ 228 __attribute__ ((null_terminated_string_arg (param_num))) 229 #else 230 # define MHD_FN_PAR_CSTR_(param_num) /* empty */ 231 #endif 232 233 #ifdef HAVE_FUNC_PARAM_ARR_STATIC_FIXED 234 # define MHD_FN_PAR_FIX_ARR_SIZE_(size) static (size) 235 #else 236 # define MHD_FN_PAR_FIX_ARR_SIZE_(size) size 237 #endif 238 239 #ifdef HAVE_FUNC_PARAM_ARR_STATIC_VAR 240 # define MHD_FN_PAR_DYN_ARR_SIZE_(size) static (size) 241 #else 242 # define MHD_FN_PAR_DYN_ARR_SIZE_(size) 1 243 #endif 244 245 #ifdef HAVE_ATTR_FUNC_ASSUME_ALIGNED 246 # define mhd_FN_RET_ALIGNED(align) __attribute__((assume_aligned (align))) 247 #else 248 # define mhd_FN_RET_ALIGNED(align) /* empty */ 249 #endif 250 251 #ifdef HAVE_ATTR_FUNC_ALLOC_SIZE 252 /** 253 * Indicates that returned pointer points to object with the size specified 254 * by parameter number @a param_num. 255 */ 256 # define mhd_FN_RET_SIZED(param_num) __attribute__((alloc_size (param_num))) 257 #else 258 /** 259 * Indicates that returned pointer points to object with the size specified 260 * by parameter number @a param_num. 261 */ 262 # define mhd_FN_RET_SIZED(param_num) /* empty */ 263 #endif 264 265 #ifdef HAVE_ATTR_FUNC_MALLOC 266 /** 267 * Indicates that returned pointer is unique and does not alias any other 268 * pointers. 269 */ 270 # define mhd_FN_RET_UNALIASED __attribute__((malloc)) 271 #else 272 /** 273 * Indicates that returned pointer is unique and does not alias any other 274 * pointers. 275 */ 276 # define mhd_FN_RET_UNALIASED /* empty */ 277 #endif 278 279 #ifdef HAVE_ATTR_FUNC_MALLOC_DEALLOC 280 /** 281 * Indicates that function creates the object that mast be destructed by 282 * another function @a destructor. 283 */ 284 # define mhd_FN_OBJ_CONSTRUCTOR(destructor) \ 285 __attribute__((malloc (destructor))) 286 #else 287 /** 288 * Indicates that function creates the object that mast be destructed by 289 * another function @a destructor. 290 */ 291 # define mhd_FN_OBJ_CONSTRUCTOR(destructor) /* empty */ 292 #endif 293 294 #ifdef HAVE_ATTR_ENUM_EXTNS_CLOSED 295 # define MHD_FIXED_ENUM_ __attribute__((enum_extensibility (closed))) 296 #else 297 # define MHD_FIXED_ENUM_ /* empty */ 298 #endif 299 300 #ifdef HAVE_ATTR_FLAG_ENUM 301 # define MHD_FLAGS_ENUM_ __attribute__((flag_enum)) 302 #else 303 # define MHD_FLAGS_ENUM_ /* empty */ 304 #endif /* MHD_FLAGS_ENUM_ */ 305 306 #define MHD_FIXED_FLAGS_ENUM_ MHD_FIXED_ENUM_ MHD_FLAGS_ENUM_ 307 308 /* 'inline' and 'restrict' are defined in mhd_config.h if needed */ 309 #define MHD_INLINE inline 310 311 #define MHD_RESTRICT restrict 312 313 #ifdef BUILDING_MHD_LIB 314 # define MHD_FIXED_ENUM_APP_SET_ /* empty */ /* handle unknown values set by the app */ 315 #else 316 # define MHD_FIXED_ENUM_APP_SET_ MHD_FIXED_ENUM_ 317 #endif 318 319 #ifdef BUILDING_MHD_LIB 320 # define MHD_FLAGS_ENUM_APP_SET_ MHD_FLAGS_ENUM_ 321 #else 322 # define MHD_FLAGS_ENUM_APP_SET_ MHD_FLAGS_ENUM_ 323 #endif 324 325 #ifdef BUILDING_MHD_LIB 326 # define MHD_FIXED_FLAGS_ENUM_APP_SET_ MHD_FLAGS_ENUM_ /* handle unknown values set by the app */ 327 #else 328 # define MHD_FIXED_FLAGS_ENUM_APP_SET_ MHD_FIXED_FLAGS_ENUM_ 329 #endif 330 331 #ifdef BUILDING_MHD_LIB 332 # define MHD_FIXED_ENUM_MHD_SET_ MHD_FIXED_ENUM_ 333 #else 334 # define MHD_FIXED_ENUM_MHD_SET_ /* empty */ /* enum can be extended in next MHD versions */ 335 #endif 336 337 #ifdef BUILDING_MHD_LIB 338 # define MHD_FLAGS_ENUM_MHD_SET_ MHD_FLAGS_ENUM_ 339 #else 340 # define MHD_FLAGS_ENUM_MHD_SET_ MHD_FLAGS_ENUM_ 341 #endif 342 343 #ifdef BUILDING_MHD_LIB 344 # define MHD_FIXED_FLAGS_ENUM_MHD_SET_ MHD_FIXED_FLAGS_ENUM_ 345 #else 346 # define MHD_FIXED_FLAGS_ENUM_MHD_SET_ MHD_FLAGS_ENUM_ /* enum can be extended in next MHD versions */ 347 #endif 348 349 #ifdef BUILDING_MHD_LIB 350 # define MHD_FIXED_ENUM_MHD_APP_SET_ /* empty */ /* handle unknown values set by the app */ 351 #else 352 # define MHD_FIXED_ENUM_MHD_APP_SET_ /* empty */ /* enum can be extended in next MHD versions */ 353 #endif 354 355 #ifdef BUILDING_MHD_LIB 356 # define MHD_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_ 357 #else 358 # define MHD_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_ 359 #endif 360 361 #ifdef BUILDING_MHD_LIB 362 # define MHD_FIXED_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_ /* handle unknown values set by the app */ 363 #else 364 # define MHD_FIXED_FLAGS_ENUM_MHD_APP_SET_ MHD_FLAGS_ENUM_ /* enum can be extended in next MHD versions */ 365 #endif 366 367 // TODO: support warnings mute 368 #ifdef HAVE_ENUM_BASE_TYPE_WARNLESS 369 # define mhd_USE_ENUM_BASE_T 1 370 #endif 371 #ifdef mhd_USE_ENUM_BASE_T 372 # define mhd_ENUM_BASE_T(fixed_type) : fixed_type 373 #else 374 # define mhd_ENUM_BASE_T(fixed_type) /* empty */ 375 #endif 376 377 /** 378 * Automatic string with the name of the current function 379 */ 380 #if defined(HAVE___FUNC__) 381 # define MHD_FUNC_ __func__ 382 # define MHD_HAVE_MHD_FUNC_ 1 383 #elif defined(HAVE___FUNCTION__) 384 # define MHD_FUNC_ __FUNCTION__ 385 # define MHD_HAVE_MHD_FUNC_ 1 386 #elif defined(HAVE___PRETTY_FUNCTION__) 387 # define MHD_FUNC_ __PRETTY_FUNCTION__ 388 # define MHD_HAVE_MHD_FUNC_ 1 389 #else 390 # define MHD_FUNC_ "**name unavailable**" 391 # ifdef MHD_HAVE_MHD_FUNC_ 392 # undef MHD_HAVE_MHD_FUNC_ 393 # endif /* MHD_HAVE_MHD_FUNC_ */ 394 #endif 395 396 /* Some platforms (FreeBSD, Solaris, W32) allow to override 397 default FD_SETSIZE by defining it before including 398 headers. */ 399 #ifdef FD_SETSIZE 400 /* FD_SETSIZE defined in command line or in mhd_config.h */ 401 #elif defined(_WIN32) || defined(__CYGWIN__) 402 /* Platform with WinSock and without overridden FD_SETSIZE */ 403 # ifdef _WIN64 404 # define FD_SETSIZE 4096 /* Override default small value (64) */ 405 # else 406 # define FD_SETSIZE 1024 /* Override default small value (64) */ 407 # endif 408 #else /* !FD_SETSIZE && !W32 */ 409 /* System default value of FD_SETSIZE is used */ 410 # define MHD_FD_SETSIZE_IS_DEFAULT_ 1 411 #endif /* !FD_SETSIZE && !W32 */ 412 413 #if defined(HAVE_LINUX_SENDFILE) || defined(HAVE_FREEBSD_SENDFILE) || \ 414 defined(HAVE_DARWIN_SENDFILE) 415 /* Have any supported sendfile() function. */ 416 # define mhd_USE_SENDFILE 1 417 #endif /* HAVE_LINUX_SENDFILE || HAVE_FREEBSD_SENDFILE 418 || HAVE_DARWIN_SENDFILE */ 419 420 #if defined(mhd_THREADS_KIND_POSIX) || defined(mhd_THREADS_KIND_W32) 421 # ifndef MHD_SUPPORT_THREADS 422 # define MHD_SUPPORT_THREADS 1 423 # endif 424 #endif /* mhd_THREADS_KIND_POSIX || mhd_THREADS_KIND_W32 */ 425 426 #if defined(_WIN32) && ! defined(__CYGWIN__) 427 /** 428 * Defined if the platform is native W32. 429 * Not define on Cygwin. 430 */ 431 # define mhd_W32_NATIVE 1 432 #endif 433 /** 434 * Macro to drop 'const' qualifier from pointer. 435 * Try to avoid compiler warning. 436 * To be used *only* to deal with broken external APIs, which require non-const 437 * pointer to unmodifiable data. 438 * Must not be used to transform pointers for internal MHD needs. 439 */ 440 #ifdef HAVE_UINTPTR_T 441 # define mhd_DROP_CONST(ptr) ((void *) ((uintptr_t) ((const void *) (ptr)))) 442 #elif defined(HAVE_INTPTR_T) 443 # define mhd_DROP_CONST(ptr) ((void *) ((intptr_t) ((const void *) (ptr)))) 444 #else 445 # define mhd_DROP_CONST(ptr) ((void *) ((const void *) (ptr))) 446 #endif 447 448 /** 449 * Cast signed integer to pointer 450 */ 451 #if defined(HAVE_INTPTR_T) 452 # define mhd_INT_TO_PTR(i) ((void *) ((intptr_t) (i))) 453 #else 454 # define mhd_INT_TO_PTR(i) ((void *) (i)) 455 #endif 456 457 /** 458 * Cast unsigned integer to pointer 459 */ 460 #if defined(HAVE_UINTPTR_T) 461 # define mhd_UINT_TO_PTR(i) ((void *) ((uintptr_t) (i))) 462 #else 463 # define mhd_UINT_TO_PTR(i) ((void *) (i)) 464 #endif 465 466 /* *************************************************************** * 467 * Macros to enable various features in the system headers * 468 * *************************************************************** */ 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 #if defined(__sun) || defined(__illumos__) 520 # ifndef _REENTRANT 521 # define _REENTRANT 1 /* Could be optional, given that POSIX_C_SOURCE is defined */ 522 # endif 523 #endif 524 525 /* Ensure that exactly one of the two macros is always defined */ 526 #if defined(NDEBUG) && defined(_DEBUG) 527 #error Both _DEBUG and NDEBUG are defined 528 #elif ! defined(_DEBUG) && ! defined(NDEBUG) 529 # ifndef DEBUG /* Used by some toolchains */ 530 # define NDEBUG 1 /* Use NDEBUG by default */ 531 # else /* DEBUG */ 532 # define _DEBUG 1 /* Non-standard macro */ 533 # endif /* DEBUG */ 534 #endif /* !_DEBUG && !NDEBUG */ 535 536 #if ! defined(MHD_CC_OPTIMISE_FOR_SIZE) \ 537 && ! defined(MHD_CC_OPTIMISE_FOR_SPEED) 538 # if defined(__OPTIMIZE_SIZE__) || defined(__OPTIMISE_SPACE) 539 # define MHD_CC_OPTIMISE_FOR_SIZE 1 540 # elif defined(__OPTIMIZE__) || defined(__OPTIMISE_TIME) 541 # define MHD_CC_OPTIMISE_FOR_SPEED 1 542 # endif /* __OPTIMIZE__ */ 543 #elif defined(MHD_CC_OPTIMISE_FOR_SIZE) && defined(MHD_CC_OPTIMISE_FOR_SPEED) 544 #error MHD_CC_OPTIMISE_FOR_SIZE and MHD_CC_OPTIMISE_FOR_SPEED are both defined. 545 #endif 546 547 #if defined(MHD_FAVOR_FAST_CODE) && defined(MHD_FAVOR_SMALL_CODE) 548 #error MHD_FAVOR_FAST_CODE and MHD_FAVOR_SMALL_CODE are both defined. 549 #error Cannot favor speed and size at the same time. 550 #endif /* MHD_FAVOR_FAST_CODE && MHD_FAVOR_SMALL_CODE */ 551 552 /* Define MHD_FAVOR_FAST_CODE to force fast code path or 553 define MHD_FAVOR_SMALL_CODE to choose compact code path */ 554 #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE) 555 /* Try to guess automatically user preferences */ 556 # if defined(MHD_CC_OPTIMISE_FOR_SPEED) 557 # define MHD_FAVOR_FAST_CODE 1 558 # elif defined(MHD_CC_OPTIMISE_FOR_SIZE) 559 # define MHD_FAVOR_SMALL_CODE 1 560 # endif /* __OPTIMIZE__ */ 561 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ 562 563 #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE) 564 /* Use faster code by default */ 565 # define MHD_FAVOR_FAST_CODE 1 566 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ 567 568 #if defined(MHD_FAVOR_SMALL_CODE) && defined(mhd_static_inline) 569 # undef mhd_static_inline 570 # define mhd_static_inline static inline /* give compiler more freedom */ 571 #endif 572 573 #ifndef MHD_ASAN_ACTIVE 574 # ifdef __SANITIZE_ADDRESS__ 575 # define MHD_ASAN_ACTIVE 1 576 # elif defined(__has_feature) 577 # if __has_feature (address_sanitizer) 578 # define MHD_ASAN_ACTIVE 1 579 # endif /* __has_feature(address_sanitizer) */ 580 # endif /* __has_feature */ 581 #endif /* ! MHD_ASAN_ACTIVE */ 582 583 #if defined(MHD_ASAN_ACTIVE) && defined(HAVE_SANITIZER_ASAN_INTERFACE_H) && \ 584 (defined(FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS) || \ 585 (defined(FUNC_ATTR_PTRCOMPARE_WORKS) && \ 586 defined(FUNC_ATTR_PTRSUBTRACT_WORKS)) || \ 587 defined(FUNC_ATTR_NOSANITIZE_WORKS)) 588 # ifndef MHD_ASAN_POISON_ACTIVE 589 /* User ASAN poisoning could be used */ 590 # warning User memory poisoning is not active 591 # endif /* ! MHD_ASAN_POISON_ACTIVE */ 592 #else /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H && 593 (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */ 594 # ifdef MHD_ASAN_POISON_ACTIVE 595 #error User memory poisoning is active, but conditions are not suitable 596 # endif /* MHD_ASAN_POISON_ACTIVE */ 597 #endif /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H && 598 (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */ 599 600 #ifndef _MSC_FULL_VER 601 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE /* empty */ 602 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE /* empty */ 603 #else /* _MSC_FULL_VER */ 604 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE \ 605 __pragma(runtime_checks("c", off)) 606 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE \ 607 __pragma(runtime_checks("c", restore)) 608 #endif /* _MSC_FULL_VER */ 609 610 611 #if ! defined(mhd_W32_NATIVE) 612 /** 613 * Indicate that suppression of SIGPIPE is required for some network 614 * system calls. 615 */ 616 # define mhd_SEND_SPIPE_SUPPRESS_NEEDED 1 617 #endif 618 619 #ifndef NDEBUG 620 # ifndef MHD_NO_TLS_DEBUG_MESSAGES 621 # ifndef mhd_USE_TLS_DEBUG_MESSAGES 622 /** 623 * Enable debugging output on TLS library (if possible) 624 */ 625 # define mhd_USE_TLS_DEBUG_MESSAGES 1 626 # endif 627 # endif 628 #endif 629 630 /* Manual overrides for debug-printing */ 631 632 #ifndef MHD_USE_TRACE_POLLING_FDS 633 /* Use debug-print for FDs polling */ 634 /* # define MHD_USE_TRACE_POLLING_FDS 1 */ 635 #endif 636 637 #ifndef MHD_USE_TRACE_CONN_ADD_CLOSE 638 /* Use debug-print for adding and closing of the connections */ 639 /* # define MHD_USE_TRACE_CONN_ADD_CLOSE 1 */ 640 #endif 641 642 #ifndef MHD_USE_TRACE_SUSPEND_RESUME 643 /* Use debug-print for suspending and resuming of the requests */ 644 /* # define MHD_USE_TRACE_SUSPEND_RESUME 1 */ 645 #endif 646 647 #ifndef MHD_AUTH_DIGEST_DEF_TIMEOUT 648 # define MHD_AUTH_DIGEST_DEF_TIMEOUT 90 649 #endif /* ! MHD_AUTH_DIGEST_DEF_TIMEOUT */ 650 #ifndef MHD_AUTH_DIGEST_DEF_MAX_NC 651 # define MHD_AUTH_DIGEST_DEF_MAX_NC 1000 652 #endif /* ! MHD_AUTH_DIGEST_DEF_MAX_NC */ 653 654 #ifndef mhd_HAVE_TLS_THREAD_CLEANUP 655 # ifdef MHD_SUPPORT_OPENSSL 656 /** 657 * If defined then mhd_tls_thread_cleanup() is a real function. 658 * If not defined then mhd_tls_thread_cleanup() is an empty macro 659 */ 660 # define mhd_HAVE_TLS_THREAD_CLEANUP 1 661 # endif 662 #endif 663 664 /* Eclipse parse compatibility */ 665 #ifdef __CDT_PARSER__ 666 # undef MHD_NORETURN_ 667 # define MHD_NORETURN_ __attribute__((__noreturn__)) 668 # undef mhd_FALLTHROUGH 669 # define mhd_FALLTHROUGH ((void) 0) 670 # undef _Atomic 671 # define _Atomic /* empty */ 672 # undef MHD_HAVE_C_CONSTEXPR 673 # if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 202311) 674 # define bool _Bool 675 # define true 1 676 # define false 0 677 # elif defined __has_include 678 # if __has_include (<stdbool.h>) 679 # define HAVE_STDBOOL_H 1 680 # endif 681 # endif 682 # define mhd_ENUM_BASE_T(base) /* nothing */ 683 # if ((__STDC_VERSION__ + 0) >= 202311) 684 # define alignof _Alignof 685 # endif 686 # define __auto_type auto 687 #endif 688 689 /* Avoid interference with third-party headers */ 690 #ifdef HAVE_CONFIG_H 691 # undef HAVE_CONFIG_H 692 #endif 693 694 #endif /* MHD_SYS_OPTIONS_H */