19 #ifndef __ASTERISK_OPTIONAL_API_H 20 #define __ASTERISK_OPTIONAL_API_H 74 #define AST_OPTIONAL_API_UNAVAILABLE INT_MIN 108 #if defined(OPTIONAL_API) 159 ast_optional_fn stub,
const char *module);
175 #define AST_OPTIONAL_API_NAME(name) __##name 177 #define AST_OPTIONAL_API_INIT_IMPL(name) \ 178 static void __attribute__((constructor)) __init__##name##_impl(void) { \ 179 ast_optional_api_provide(#name, \ 180 (ast_optional_fn)AST_OPTIONAL_API_NAME(name)); \ 182 static void __attribute__((destructor)) __dtor__##name##_impl(void) { \ 183 ast_optional_api_unprovide(#name, \ 184 (ast_optional_fn)AST_OPTIONAL_API_NAME(name)); \ 187 #define AST_OPTIONAL_API_INIT_USER(name) \ 188 static void __attribute__((constructor)) __init__##name(void) { \ 189 ast_optional_api_use(#name, (ast_optional_fn *)&name, \ 190 (ast_optional_fn)__stub__##name, \ 193 static void __attribute__((destructor)) __dtor__##name(void) { \ 194 ast_optional_api_unuse(#name, (ast_optional_fn *)&name, \ 198 #define AST_OPTIONAL_API_IMPL(result, name, proto, stub) \ 199 result AST_OPTIONAL_API_NAME(name) proto; \ 200 static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const \ 201 name = AST_OPTIONAL_API_NAME(name); \ 202 AST_OPTIONAL_API_INIT_IMPL(name) 204 #define AST_OPTIONAL_API_USER(result, name, proto, stub) \ 205 static result __stub__##name proto stub; \ 206 static attribute_unused \ 207 typeof(__stub__##name) * name; \ 208 AST_OPTIONAL_API_INIT_USER(name) 212 #define AST_OPTIONAL_API_ATTR_IMPL(result, attr, name, proto, stub) \ 213 result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \ 214 static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const \ 215 name = AST_OPTIONAL_API_NAME(name); \ 216 AST_OPTIONAL_API_INIT_IMPL(name) 218 #define AST_OPTIONAL_API_ATTR_USER(result, attr, name, proto, stub) \ 219 static __attribute__((attr)) result __stub__##name proto stub; \ 220 static attribute_unused __attribute__((attr)) \ 221 typeof(__stub__##name) * name; \ 222 AST_OPTIONAL_API_INIT_USER(name) 228 #define AST_OPTIONAL_API_NAME(name) name 230 #define AST_OPTIONAL_API(result, name, proto, stub) \ 231 result AST_OPTIONAL_API_NAME(name) proto 233 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ 234 result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto 247 #if defined(OPTIONAL_API) 249 #undef AST_OPTIONAL_API 250 #undef AST_OPTIONAL_API_ATTR 252 #if defined(AST_API_MODULE) 254 #define AST_OPTIONAL_API(result, name, proto, stub) \ 255 AST_OPTIONAL_API_IMPL(result, name, proto, stub) 257 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ 258 AST_OPTIONAL_API_ATTR_IMPL(result, attr, name, proto, stub) 262 #define AST_OPTIONAL_API(result, name, proto, stub) \ 263 AST_OPTIONAL_API_USER(result, name, proto, stub) 265 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \ 266 AST_OPTIONAL_API_ATTR_USER(result, attr, name, proto, stub) 272 #undef AST_API_MODULE void ast_optional_api_provide(const char *symname, ast_optional_fn impl)
void ast_optional_api_unprovide(const char *symname, ast_optional_fn impl)
void ast_optional_api_use(const char *symname, ast_optional_fn *optional_ref, ast_optional_fn stub, const char *module)
void ast_optional_api_unuse(const char *symname, ast_optional_fn *optional_ref, const char *module)
#define attribute_may_alias