mhd_sys_options.h (21723B)
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 #if defined(OS390) 468 #define _OPEN_THREADS 469 #define _OPEN_SYS_SOCK_IPV6 470 #define _OPEN_MSGQ_EXT 471 #define _LP64 472 #endif 473 474 #if defined(_WIN32) && ! defined(__CYGWIN__) 475 /* Declare POSIX-compatible names */ 476 # define _CRT_DECLARE_NONSTDC_NAMES 1 477 /* Do not warn about POSIX name usage */ 478 # define _CRT_NONSTDC_NO_WARNINGS 1 479 # ifndef _WIN32_WINNT 480 # define _WIN32_WINNT 0x0600 481 # else /* _WIN32_WINNT */ 482 # if _WIN32_WINNT < 0x0501 483 #error "Headers for Windows XP or later are required" 484 # endif /* _WIN32_WINNT < 0x0501 */ 485 # endif /* _WIN32_WINNT */ 486 # ifndef WIN32_LEAN_AND_MEAN 487 /* Do not include unneeded parts of W32 headers. */ 488 # define WIN32_LEAN_AND_MEAN 1 489 # endif /* !WIN32_LEAN_AND_MEAN */ 490 #endif /* _WIN32 && ! __CYGWIN__ */ 491 492 #if defined(__MINGW32__) 493 # ifndef __USE_MINGW_ANSI_STDIO 494 # define __USE_MINGW_ANSI_STDIO 0 /* Force use native printf, the code is well-adapted */ 495 # endif 496 #endif 497 498 #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) 499 #define RESTRICT __restrict__ 500 #endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */ 501 502 #if defined(__linux__) && \ 503 (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64) || defined(HAVE_PREAD64)) 504 # if ! defined(_LARGEFILE64_SOURCE) 505 /* On Linux, special macro is required to enable definitions of some xxx64 functions */ 506 # define _LARGEFILE64_SOURCE 1 507 # endif 508 #endif 509 510 #ifdef HAVE_C11_GMTIME_S 511 /* Special macro is required to enable C11 definition of gmtime_s() function */ 512 #define __STDC_WANT_LIB_EXT1__ 1 513 #endif /* HAVE_C11_GMTIME_S */ 514 515 /* Ensure that exactly one of the two macros is always defined */ 516 #if defined(NDEBUG) && defined(_DEBUG) 517 #error Both _DEBUG and NDEBUG are defined 518 #elif ! defined(_DEBUG) && ! defined(NDEBUG) 519 # ifndef DEBUG /* Used by some toolchains */ 520 # define NDEBUG 1 /* Use NDEBUG by default */ 521 # else /* DEBUG */ 522 # define _DEBUG 1 /* Non-standard macro */ 523 # endif /* DEBUG */ 524 #endif /* !_DEBUG && !NDEBUG */ 525 526 #if ! defined(MHD_CC_OPTIMISE_FOR_SIZE) \ 527 && ! defined(MHD_CC_OPTIMISE_FOR_SPEED) 528 # if defined(__OPTIMIZE_SIZE__) || defined(__OPTIMISE_SPACE) 529 # define MHD_CC_OPTIMISE_FOR_SIZE 1 530 # elif defined(__OPTIMIZE__) || defined(__OPTIMISE_TIME) 531 # define MHD_CC_OPTIMISE_FOR_SPEED 1 532 # endif /* __OPTIMIZE__ */ 533 #elif defined(MHD_CC_OPTIMISE_FOR_SIZE) && defined(MHD_CC_OPTIMISE_FOR_SPEED) 534 #error MHD_CC_OPTIMISE_FOR_SIZE and MHD_CC_OPTIMISE_FOR_SPEED are both defined. 535 #endif 536 537 #if defined(MHD_FAVOR_FAST_CODE) && defined(MHD_FAVOR_SMALL_CODE) 538 #error MHD_FAVOR_FAST_CODE and MHD_FAVOR_SMALL_CODE are both defined. 539 #error Cannot favor speed and size at the same time. 540 #endif /* MHD_FAVOR_FAST_CODE && MHD_FAVOR_SMALL_CODE */ 541 542 /* Define MHD_FAVOR_FAST_CODE to force fast code path or 543 define MHD_FAVOR_SMALL_CODE to choose compact code path */ 544 #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE) 545 /* Try to guess automatically user preferences */ 546 # if defined(MHD_CC_OPTIMISE_FOR_SPEED) 547 # define MHD_FAVOR_FAST_CODE 1 548 # elif defined(MHD_CC_OPTIMISE_FOR_SIZE) 549 # define MHD_FAVOR_SMALL_CODE 1 550 # endif /* __OPTIMIZE__ */ 551 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ 552 553 #if ! defined(MHD_FAVOR_FAST_CODE) && ! defined(MHD_FAVOR_SMALL_CODE) 554 /* Use faster code by default */ 555 # define MHD_FAVOR_FAST_CODE 1 556 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ 557 558 #if defined(MHD_FAVOR_SMALL_CODE) && defined(mhd_static_inline) 559 # undef mhd_static_inline 560 # define mhd_static_inline static inline /* give compiler more freedom */ 561 #endif 562 563 #ifndef MHD_ASAN_ACTIVE 564 #if (defined(__GNUC__) || defined(_MSC_VER)) && defined(__SANITIZE_ADDRESS__) 565 #define MHD_ASAN_ACTIVE 1 566 #elif defined(__has_feature) 567 #if __has_feature (address_sanitizer) 568 #define MHD_ASAN_ACTIVE 1 569 #endif /* __has_feature(address_sanitizer) */ 570 #endif /* __has_feature */ 571 #endif /* MHD_ASAN_ACTIVE */ 572 573 #if defined(MHD_ASAN_ACTIVE) && defined(HAVE_SANITIZER_ASAN_INTERFACE_H) && \ 574 (defined(FUNC_PTRCOMPARE_CAST_WORKAROUND_WORKS) || \ 575 (defined(FUNC_ATTR_PTRCOMPARE_WORKS) && \ 576 defined(FUNC_ATTR_PTRSUBTRACT_WORKS)) || \ 577 defined(FUNC_ATTR_NOSANITIZE_WORKS)) 578 # ifndef MHD_ASAN_POISON_ACTIVE 579 /* User ASAN poisoning could be used */ 580 # warning User memory poisoning is not active 581 # endif /* ! MHD_ASAN_POISON_ACTIVE */ 582 #else /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H && 583 (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */ 584 # ifdef MHD_ASAN_POISON_ACTIVE 585 #error User memory poisoning is active, but conditions are not suitable 586 # endif /* MHD_ASAN_POISON_ACTIVE */ 587 #endif /* ! (MHD_ASAN_ACTIVE && HAVE_SANITIZER_ASAN_INTERFACE_H && 588 (FUNC_ATTR_PTRCOMPARE_WORKS || FUNC_ATTR_NOSANITIZE_WORKS)) */ 589 590 #ifndef _MSC_FULL_VER 591 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE /* empty */ 592 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE /* empty */ 593 #else /* _MSC_FULL_VER */ 594 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_DISABLE \ 595 __pragma(runtime_checks("c", off)) 596 # define mhd_DATA_TRUNCATION_RUNTIME_CHECK_RESTORE \ 597 __pragma(runtime_checks("c", restore)) 598 #endif /* _MSC_FULL_VER */ 599 600 601 #if ! defined(mhd_W32_NATIVE) 602 /** 603 * Indicate that suppression of SIGPIPE is required for some network 604 * system calls. 605 */ 606 # define mhd_SEND_SPIPE_SUPPRESS_NEEDED 1 607 #endif 608 609 #ifndef NDEBUG 610 # ifndef MHD_NO_TLS_DEBUG_MESSAGES 611 # ifndef mhd_USE_TLS_DEBUG_MESSAGES 612 /** 613 * Enable debugging output on TLS library (if possible) 614 */ 615 # define mhd_USE_TLS_DEBUG_MESSAGES 1 616 # endif 617 # endif 618 #endif 619 620 #ifndef mhd_DEBUG_POLLING_FDS 621 /* Use debug-print for FDs polling */ 622 /* # define mhd_DEBUG_POLLING_FDS 1 */ 623 #endif 624 625 #ifndef mhd_DEBUG_SUSPEND_RESUME 626 /* Use debug-print for suspending and resuming of the requests */ 627 /* # define mhd_DEBUG_SUSPEND_RESUME 1 */ 628 #endif 629 630 #ifndef mhd_DEBUG_CONN_ADD_CLOSE 631 /* Use debug-print for adding and closing of the connections */ 632 /* # define mhd_DEBUG_CONN_ADD_CLOSE 1 */ 633 #endif 634 635 #ifndef MHD_AUTH_DIGEST_DEF_TIMEOUT 636 # define MHD_AUTH_DIGEST_DEF_TIMEOUT 90 637 #endif /* ! MHD_AUTH_DIGEST_DEF_TIMEOUT */ 638 #ifndef MHD_AUTH_DIGEST_DEF_MAX_NC 639 # define MHD_AUTH_DIGEST_DEF_MAX_NC 1000 640 #endif /* ! MHD_AUTH_DIGEST_DEF_MAX_NC */ 641 642 #ifndef mhd_HAVE_TLS_THREAD_CLEANUP 643 # ifdef MHD_SUPPORT_OPENSSL 644 /** 645 * If defined then mhd_tls_thread_cleanup() is a real function. 646 * If not defined then mhd_tls_thread_cleanup() is an empty macro 647 */ 648 # define mhd_HAVE_TLS_THREAD_CLEANUP 1 649 # endif 650 #endif 651 652 /* Eclipse parse compatibility */ 653 #ifdef __CDT_PARSER__ 654 # undef MHD_NORETURN_ 655 # define MHD_NORETURN_ __attribute__((__noreturn__)) 656 # undef mhd_FALLTHROUGH 657 # define mhd_FALLTHROUGH ((void) 0) 658 # undef _Atomic 659 # define _Atomic /* empty */ 660 # undef MHD_HAVE_C_CONSTEXPR 661 # if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 202311) 662 # define bool _Bool 663 # define true 1 664 # define false 0 665 # elif defined __has_include 666 # if __has_include (<stdbool.h>) 667 # define HAVE_STDBOOL_H 1 668 # endif 669 # endif 670 # define mhd_ENUM_BASE_T(base) /* nothing */ 671 # if ((__STDC_VERSION__ + 0) >= 202311) 672 # define alignof _Alignof 673 # endif 674 # define __auto_type auto 675 #endif 676 677 /* Avoid interference with third-party headers */ 678 #ifdef HAVE_CONFIG_H 679 # undef HAVE_CONFIG_H 680 #endif 681 682 #endif /* MHD_SYS_OPTIONS_H */