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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @brief Symbol export macros and hook functions
26 #include "apr_hooks.h"
27 #include "apr_optional_hooks.h"
29 /* Although this file doesn't declare any hooks, declare the hook group here */
31 * @defgroup hooks Apache Hooks
32 * @ingroup APACHE_CORE
36 /* define these just so doxygen documents them */
39 * AP_DECLARE_STATIC is defined when including Apache's Core headers,
40 * to provide static linkage when the dynamic library may be unavailable.
42 * @see AP_DECLARE_EXPORT
44 * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
45 * including Apache's Core headers, to import and link the symbols from the
46 * dynamic Apache Core library and assure appropriate indirection and calling
47 * conventions at compile time.
49 # define AP_DECLARE_STATIC
51 * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
52 * library, so that all public symbols are exported.
54 * @see AP_DECLARE_STATIC
56 # define AP_DECLARE_EXPORT
58 #endif /* def DOXYGEN */
62 * Apache Core dso functions are declared with AP_DECLARE(), so they may
63 * use the most appropriate calling convention. Hook functions and other
64 * Core functions with variable arguments must use AP_DECLARE_NONSTD().
66 * AP_DECLARE(rettype) ap_func(args)
69 #define AP_DECLARE(type) type
72 * Apache Core dso variable argument and hook functions are declared with
73 * AP_DECLARE_NONSTD(), as they must use the C language calling convention.
76 * AP_DECLARE_NONSTD(rettype) ap_func(args [...])
79 #define AP_DECLARE_NONSTD(type) type
82 * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA.
83 * This assures the appropriate indirection is invoked at compile time.
85 * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for
86 * declarations within headers to properly import the variable.
88 * AP_DECLARE_DATA type apr_variable
91 #define AP_DECLARE_DATA
93 #elif defined(AP_DECLARE_STATIC)
94 #define AP_DECLARE(type) type __stdcall
95 #define AP_DECLARE_NONSTD(type) type
96 #define AP_DECLARE_DATA
97 #elif defined(AP_DECLARE_EXPORT)
98 #define AP_DECLARE(type) __declspec(dllexport) type __stdcall
99 #define AP_DECLARE_NONSTD(type) __declspec(dllexport) type
100 #define AP_DECLARE_DATA __declspec(dllexport)
102 #define AP_DECLARE(type) __declspec(dllimport) type __stdcall
103 #define AP_DECLARE_NONSTD(type) __declspec(dllimport) type
104 #define AP_DECLARE_DATA __declspec(dllimport)
107 #if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC)
109 * Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA.
111 * Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols
112 * declared with AP_MODULE_DECLARE_DATA are always exported.
114 * module AP_MODULE_DECLARE_DATA mod_tag
118 #define AP_MODULE_DECLARE(type) type __stdcall
120 #define AP_MODULE_DECLARE(type) type
122 #define AP_MODULE_DECLARE_NONSTD(type) type
123 #define AP_MODULE_DECLARE_DATA
126 * AP_MODULE_DECLARE_EXPORT is a no-op. Unless contradicted by the
127 * AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined.
129 * The old SHARED_MODULE compile-time symbol is now the default behavior,
130 * so it is no longer referenced anywhere with Apache 2.0.
132 #define AP_MODULE_DECLARE_EXPORT
133 #define AP_MODULE_DECLARE(type) __declspec(dllexport) type __stdcall
134 #define AP_MODULE_DECLARE_NONSTD(type) __declspec(dllexport) type
135 #define AP_MODULE_DECLARE_DATA __declspec(dllexport)
139 * Declare a hook function
140 * @param ret The return type of the hook
141 * @param name The hook's name (as a literal)
142 * @param args The arguments the hook function takes, in brackets.
144 #define AP_DECLARE_HOOK(ret,name,args) \
145 APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args)
148 #define AP_IMPLEMENT_HOOK_BASE(name) \
149 APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name)
152 * Implement an Apache core hook that has no return code, and
153 * therefore runs all of the registered functions. The implementation
154 * is called ap_run_<i>name</i>.
156 * @param name The name of the hook
157 * @param args_decl The declaration of the arguments for the hook, for example
159 * @param args_use The arguments for the hook as used in a call, for example
161 * @note If IMPLEMENTing a hook that is not linked into the Apache core,
162 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID.
164 #define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
165 APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use)
168 * Implement an Apache core hook that runs until one of the functions
169 * returns something other than ok or decline. That return value is
170 * then returned from the hook runner. If the hooks run to completion,
171 * then ok is returned. Note that if no hook runs it would probably be
172 * more correct to return decline, but this currently does not do
173 * so. The implementation is called ap_run_<i>name</i>.
175 * @param ret The return type of the hook (and the hook runner)
176 * @param name The name of the hook
177 * @param args_decl The declaration of the arguments for the hook, for example
179 * @param args_use The arguments for the hook as used in a call, for example
181 * @param ok The "ok" return value
182 * @param decline The "decline" return value
183 * @return ok, decline or an error.
184 * @note If IMPLEMENTing a hook that is not linked into the Apache core,
185 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL.
187 #define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
188 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
192 * Implement a hook that runs until a function returns something other than
193 * decline. If all functions return decline, the hook runner returns decline.
194 * The implementation is called ap_run_<i>name</i>.
196 * @param ret The return type of the hook (and the hook runner)
197 * @param name The name of the hook
198 * @param args_decl The declaration of the arguments for the hook, for example
200 * @param args_use The arguments for the hook as used in a call, for example
202 * @param decline The "decline" return value
203 * @return decline or an error.
204 * @note If IMPLEMENTing a hook that is not linked into the Apache core
205 * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST.
207 #define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
208 APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
211 /* Note that the other optional hook implementations are straightforward but
212 * have not yet been needed
216 * Implement an optional hook. This is exactly the same as a standard hook
217 * implementation, except the hook is optional.
218 * @see AP_IMPLEMENT_HOOK_RUN_ALL
220 #define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \
222 APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
226 * Hook an optional hook. Unlike static hooks, this uses a macro instead of a
229 #define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \
230 APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order)
233 #if (!defined(WIN32) && !defined(NETWARE)) || defined(__MINGW32__)
234 #include "ap_config_auto.h"
235 #include "ap_config_layout.h"
238 #define AP_NONBLOCK_WHEN_MULTI_LISTEN 1
241 #if AP_ENABLE_DTRACE && HAVE_SYS_SDT_H
244 #undef _DTRACE_VERSION
247 #ifdef _DTRACE_VERSION
248 #include "apache_probes.h"
250 #include "apache_noprobes.h"
253 /* TODO - We need to put OS detection back to make all the following work */
255 #if defined(SUNOS4) || defined(IRIX) || defined(NEXT) || defined(AUX3) \
256 || defined (UW) || defined(LYNXOS) || defined(TPF)
257 /* These systems don't do well with any lingering close code; I don't know
262 /* If APR has OTHER_CHILD logic, use reliable piped logs. */
263 #if APR_HAS_OTHER_CHILD
264 #define AP_HAVE_RELIABLE_PIPED_LOGS TRUE
267 /* Presume that the compiler supports C99-style designated
268 * initializers if using GCC (but not G++), or for any other compiler
269 * which claims C99 support. */
270 #if (defined(__GNUC__) && !defined(__cplusplus)) \
271 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
272 #define AP_HAVE_DESIGNATED_INITIALIZER
275 #endif /* AP_CONFIG_H */