1 /* 2 This file is part of libmicrohttpd 3 Copyright (C) 2016 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 20 /** 21 * @file include/mhd_options.h 22 * @brief additional automatic macros for MHD_config.h 23 * @author Karlson2k (Evgeny Grin) 24 * 25 * This file includes MHD_config.h and adds automatic macros based on values 26 * in MHD_config.h, compiler built-in macros and commandline-defined macros 27 * (but not based on values defined in other headers). Works also as a guard 28 * to prevent double inclusion of MHD_config.h 29 */ 30 31 #ifndef MHD_OPTIONS_H 32 #define MHD_OPTIONS_H 1 33 34 #include "MHD_config.h" 35 36 /** 37 * Macro to make it easy to mark text for translation. Note that 38 * we do not actually call gettext() in MHD, but we do make it 39 * easy to create a ".po" file so that applications that do want 40 * to translate error messages can do so. 41 */ 42 #define _(String) (String) 43 44 45 46 #ifndef _MHD_EXTERN 47 #if defined(BUILDING_MHD_LIB) && defined(_WIN32) && \ 48 (defined(DLL_EXPORT) || defined(MHD_W32DLL)) 49 #define _MHD_EXTERN __declspec(dllexport) extern 50 #else /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */ 51 #define _MHD_EXTERN extern 52 #endif /* !BUILDING_MHD_LIB || !_WIN32 || (!DLL_EXPORT && !MHD_W32DLL) */ 53 #endif /* ! _MHD_EXTERN */ 54 55 /* Some platforms (FreeBSD, Solaris, W32) allow to override 56 default FD_SETSIZE by defining it before including 57 headers. */ 58 #ifdef FD_SETSIZE 59 /* FD_SETSIZE defined in command line or in MHD_config.h */ 60 #elif defined(_WIN32) && !defined(__CYGWIN__) 61 /* Platform with WinSock and without overridden FD_SETSIZE */ 62 #define FD_SETSIZE 2048 /* Override default small value */ 63 #else /* !FD_SETSIZE && !WinSock*/ 64 /* System default value of FD_SETSIZE is used */ 65 #define _MHD_FD_SETSIZE_IS_DEFAULT 1 66 #endif /* !FD_SETSIZE && !WinSock*/ 67 68 #if OS390 69 #define _OPEN_THREADS 70 #define _OPEN_SYS_SOCK_IPV6 71 #define _OPEN_MSGQ_EXT 72 #define _LP64 73 #endif 74 75 #if defined(_WIN32) 76 #ifndef _WIN32_WINNT 77 #define _WIN32_WINNT 0x0501 78 #else /* _WIN32_WINNT */ 79 #if _WIN32_WINNT < 0x0501 80 #error "Headers for Windows XP or later are required" 81 #endif /* _WIN32_WINNT < 0x0501 */ 82 #endif /* _WIN32_WINNT */ 83 #ifndef WIN32_LEAN_AND_MEAN 84 /* Do not include unneeded parts of W32 headers. */ 85 #define WIN32_LEAN_AND_MEAN 1 86 #endif /* !WIN32_LEAN_AND_MEAN */ 87 #endif /* _WIN32 */ 88 89 #if defined(__VXWORKS__) || defined(__vxworks) || defined(OS_VXWORKS) 90 #define RESTRICT __restrict__ 91 #endif /* __VXWORKS__ || __vxworks || OS_VXWORKS */ 92 93 #if LINUX+0 && (defined(HAVE_SENDFILE64) || defined(HAVE_LSEEK64)) && ! defined(_LARGEFILE64_SOURCE) 94 /* On Linux, special macro is required to enable definitions of some xxx64 functions */ 95 #define _LARGEFILE64_SOURCE 1 96 #endif 97 98 #ifdef HAVE_C11_GMTIME_S 99 /* Special macro is required to enable C11 definition of gmtime_s() function */ 100 #define __STDC_WANT_LIB_EXT1__ 1 101 #endif /* HAVE_C11_GMTIME_S */ 102 103 #if defined(MHD_FAVOR_FAST_CODE) && defined(MHD_FAVOR_SMALL_CODE) 104 #error MHD_FAVOR_FAST_CODE and MHD_FAVOR_SMALL_CODE are both defined. Cannot favor speed and size at the same time. 105 #endif /* MHD_FAVOR_FAST_CODE && MHD_FAVOR_SMALL_CODE */ 106 107 /* Define MHD_FAVOR_FAST_CODE to force fast code path or 108 define MHD_FAVOR_SMALL_CODE to choose compact code path */ 109 #if !defined(MHD_FAVOR_FAST_CODE) && !defined(MHD_FAVOR_SMALL_CODE) 110 /* Try to detect user preferences */ 111 /* Defined by GCC and many compatible compilers */ 112 #ifdef __OPTIMIZE_SIZE__ 113 #define MHD_FAVOR_SMALL_CODE 1 114 #elif __OPTIMIZE__ 115 #define MHD_FAVOR_FAST_CODE 1 116 #endif /* __OPTIMIZE__ */ 117 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ 118 119 #if !defined(MHD_FAVOR_FAST_CODE) && !defined(MHD_FAVOR_SMALL_CODE) 120 /* Use faster code by default */ 121 #define MHD_FAVOR_FAST_CODE 1 122 #endif /* !MHD_FAVOR_FAST_CODE && !MHD_FAVOR_SMALL_CODE */ 123 124 #endif /* MHD_OPTIONS_H */ 125