Wed Jan 8 2020 09:49:48
Asterisk developer's documentation
Go to the documentation of this file.
19 #ifndef __ASTERISK_OPTIONAL_API_H
20 #define __ASTERISK_OPTIONAL_API_H
92 #define __stringify_1(x) #x
93 #define __stringify(x) __stringify_1(x)
103 #define AST_OPTIONAL_API_UNAVAILABLE INT_MIN
106 #if defined(HAVE_ATTRIBUTE_weak_import) || defined(HAVE_ATTRIBUTE_weak)
127 #if defined(HAVE_ATTRIBUTE_weak_import)
128 #define __default_attribute weak_import
130 #define __default_attribute weak
133 #define AST_OPTIONAL_API_NAME(name) __##name
135 #if defined(AST_API_MODULE)
137 #define AST_OPTIONAL_API(result, name, proto, stub) \
138 result AST_OPTIONAL_API_NAME(name) proto; \
139 static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name);
141 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
142 result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \
143 static attribute_unused typeof(AST_OPTIONAL_API_NAME(name)) * const name = AST_OPTIONAL_API_NAME(name);
147 #define AST_OPTIONAL_API(result, name, proto, stub) \
148 static result __stub__##name proto stub; \
149 __attribute__((__default_attribute)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \
150 static attribute_unused typeof(__stub__##name) * name; \
151 static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; }
153 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
154 static __attribute__((attr)) result __stub__##name proto stub; \
155 __attribute__((attr, __default_attribute)) typeof(__stub__##name) AST_OPTIONAL_API_NAME(name); \
156 static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \
157 static void __attribute__((constructor)) __init__##name(void) { name = AST_OPTIONAL_API_NAME(name) ? : __stub__##name; }
163 #elif defined(HAVE_ATTRIBUTE_weakref)
183 #define AST_OPTIONAL_API_NAME(name) __##name
185 #if defined(AST_API_MODULE)
187 #define AST_OPTIONAL_API(result, name, proto, stub) \
188 result AST_OPTIONAL_API_NAME(name) proto; \
189 static __attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name;
191 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
192 result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto; \
193 static __attribute__((alias(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(AST_OPTIONAL_API_NAME(name)) name;
197 #define AST_OPTIONAL_API(result, name, proto, stub) \
198 static result __stub__##name proto stub; \
199 static __attribute__((weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \
200 static attribute_unused typeof(__stub__##name) * name; \
201 static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; }
203 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) \
204 static __attribute__((attr)) result __stub__##name proto stub; \
205 static __attribute__((attr, weakref(__stringify(AST_OPTIONAL_API_NAME(name))))) typeof(__stub__##name) __ref__##name; \
206 static attribute_unused __attribute__((attr)) typeof(__stub__##name) * name; \
207 static void __attribute__((constructor)) __init__##name(void) { name = __ref__##name ? : __stub__##name; }
217 #define AST_OPTIONAL_API_NAME(name) name
233 #define AST_OPTIONAL_API(result, name, proto, stub) result AST_OPTIONAL_API_NAME(name) proto
244 #define AST_OPTIONAL_API_ATTR(result, attr, name, proto, stub) result __attribute__((attr)) AST_OPTIONAL_API_NAME(name) proto
250 #undef AST_API_MODULE