ap_config.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file ap_config.h
  18. * @brief Symbol export macros and hook functions
  19. */
  20. #ifndef AP_CONFIG_H
  21. #define AP_CONFIG_H
  22. #include "ap_hooks.h"
  23. /* Although this file doesn't declare any hooks, declare the exports group here */
  24. /**
  25. * @defgroup exports Apache exports
  26. * @ingroup APACHE_CORE
  27. */
  28. #ifdef DOXYGEN
  29. /* define these just so doxygen documents them */
  30. /**
  31. * AP_DECLARE_STATIC is defined when including Apache's Core headers,
  32. * to provide static linkage when the dynamic library may be unavailable.
  33. *
  34. * @see AP_DECLARE_EXPORT
  35. *
  36. * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
  37. * including Apache's Core headers, to import and link the symbols from the
  38. * dynamic Apache Core library and assure appropriate indirection and calling
  39. * conventions at compile time.
  40. */
  41. # define AP_DECLARE_STATIC
  42. /**
  43. * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
  44. * library, so that all public symbols are exported.
  45. *
  46. * @see AP_DECLARE_STATIC
  47. */
  48. # define AP_DECLARE_EXPORT
  49. #endif /* def DOXYGEN */
  50. #if !defined(WIN32)
  51. /**
  52. * Apache Core dso functions are declared with AP_DECLARE(), so they may
  53. * use the most appropriate calling convention. Hook functions and other
  54. * Core functions with variable arguments must use AP_DECLARE_NONSTD().
  55. * @code
  56. * AP_DECLARE(rettype) ap_func(args)
  57. * @endcode
  58. */
  59. #define AP_DECLARE(type) type
  60. /**
  61. * Apache Core dso variable argument and hook functions are declared with
  62. * AP_DECLARE_NONSTD(), as they must use the C language calling convention.
  63. * @see AP_DECLARE
  64. * @code
  65. * AP_DECLARE_NONSTD(rettype) ap_func(args [...])
  66. * @endcode
  67. */
  68. #define AP_DECLARE_NONSTD(type) type
  69. /**
  70. * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA.
  71. * This assures the appropriate indirection is invoked at compile time.
  72. *
  73. * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for
  74. * declarations within headers to properly import the variable.
  75. * @code
  76. * AP_DECLARE_DATA type apr_variable
  77. * @endcode
  78. */
  79. #define AP_DECLARE_DATA
  80. #elif defined(AP_DECLARE_STATIC)
  81. #define AP_DECLARE(type) type __stdcall
  82. #define AP_DECLARE_NONSTD(type) type
  83. #define AP_DECLARE_DATA
  84. #elif defined(AP_DECLARE_EXPORT)
  85. #define AP_DECLARE(type) __declspec(dllexport) type __stdcall
  86. #define AP_DECLARE_NONSTD(type) __declspec(dllexport) type
  87. #define AP_DECLARE_DATA __declspec(dllexport)
  88. #else
  89. #define AP_DECLARE(type) __declspec(dllimport) type __stdcall
  90. #define AP_DECLARE_NONSTD(type) __declspec(dllimport) type
  91. #define AP_DECLARE_DATA __declspec(dllimport)
  92. #endif
  93. #if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC)
  94. /**
  95. * Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA.
  96. *
  97. * Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols
  98. * declared with AP_MODULE_DECLARE_DATA are always exported.
  99. * @code
  100. * module AP_MODULE_DECLARE_DATA mod_tag
  101. * @endcode
  102. */
  103. #if defined(WIN32)
  104. #define AP_MODULE_DECLARE(type) type __stdcall
  105. #else
  106. #define AP_MODULE_DECLARE(type) type
  107. #endif
  108. #define AP_MODULE_DECLARE_NONSTD(type) type
  109. #define AP_MODULE_DECLARE_DATA
  110. #else
  111. /**
  112. * AP_MODULE_DECLARE_EXPORT is a no-op. Unless contradicted by the
  113. * AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined.
  114. *
  115. * The old SHARED_MODULE compile-time symbol is now the default behavior,
  116. * so it is no longer referenced anywhere with Apache 2.0.
  117. */
  118. #define AP_MODULE_DECLARE_EXPORT
  119. #define AP_MODULE_DECLARE(type) __declspec(dllexport) type __stdcall
  120. #define AP_MODULE_DECLARE_NONSTD(type) __declspec(dllexport) type
  121. #define AP_MODULE_DECLARE_DATA __declspec(dllexport)
  122. #endif
  123. #include "os.h"
  124. #if (!defined(WIN32) && !defined(NETWARE)) || defined(__MINGW32__)
  125. #include "ap_config_auto.h"
  126. #endif
  127. #include "ap_config_layout.h"
  128. /* Where the main/parent process's pid is logged */
  129. #ifndef DEFAULT_PIDLOG
  130. #define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid"
  131. #endif
  132. #if defined(NETWARE)
  133. #define AP_NONBLOCK_WHEN_MULTI_LISTEN 1
  134. #endif
  135. #if defined(AP_ENABLE_DTRACE) && HAVE_SYS_SDT_H
  136. #include <sys/sdt.h>
  137. #else
  138. #undef _DTRACE_VERSION
  139. #endif
  140. #ifdef _DTRACE_VERSION
  141. #include "apache_probes.h"
  142. #else
  143. #include "apache_noprobes.h"
  144. #endif
  145. /* If APR has OTHER_CHILD logic, use reliable piped logs. */
  146. #if APR_HAS_OTHER_CHILD
  147. #define AP_HAVE_RELIABLE_PIPED_LOGS TRUE
  148. #endif
  149. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  150. #define AP_HAVE_C99
  151. #endif
  152. /* Presume that the compiler supports C99-style designated
  153. * initializers if using GCC (but not G++), or for any other compiler
  154. * which claims C99 support. */
  155. #if (defined(__GNUC__) && !defined(__cplusplus)) || defined(AP_HAVE_C99)
  156. #define AP_HAVE_DESIGNATED_INITIALIZER
  157. #endif
  158. #ifndef __has_attribute /* check for supported attributes on clang */
  159. #define __has_attribute(x) 0
  160. #endif
  161. #if (defined(__GNUC__) && __GNUC__ >= 4) || __has_attribute(sentinel)
  162. #define AP_FN_ATTR_SENTINEL __attribute__((sentinel))
  163. #else
  164. #define AP_FN_ATTR_SENTINEL
  165. #endif
  166. #if ( defined(__GNUC__) && \
  167. (__GNUC__ >= 4 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))) \
  168. || __has_attribute(warn_unused_result)
  169. #define AP_FN_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  170. #else
  171. #define AP_FN_ATTR_WARN_UNUSED_RESULT
  172. #endif
  173. #if ( defined(__GNUC__) && \
  174. (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)) \
  175. || __has_attribute(alloc_size)
  176. #define AP_FN_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
  177. #define AP_FN_ATTR_ALLOC_SIZE2(x,y) __attribute__((alloc_size(x,y)))
  178. #else
  179. #define AP_FN_ATTR_ALLOC_SIZE(x)
  180. #define AP_FN_ATTR_ALLOC_SIZE2(x,y)
  181. #endif
  182. #endif /* AP_CONFIG_H */