|
@@ -179,6 +179,42 @@ REQUEST_EXPANDED ( CONFIG_SYMBOL );
|
179
|
179
|
/** Select file identifier for errno.h (if used) */
|
180
|
180
|
#define ERRFILE PREFIX_OBJECT ( ERRFILE_ )
|
181
|
181
|
|
|
182
|
+/**
|
|
183
|
+ * @defgroup weakmacros Macros to manage weak symbol definitions
|
|
184
|
+ *
|
|
185
|
+ * Weak symbols allow one to reference a function in another file
|
|
186
|
+ * without necessarily requiring that file to be linked in. In their
|
|
187
|
+ * native form, the function will be @c NULL if its file is not linked
|
|
188
|
+ * in; these macros provide an inline wrapper that returns an
|
|
189
|
+ * appropriate error indication or default value.
|
|
190
|
+ *
|
|
191
|
+ * @{
|
|
192
|
+ */
|
|
193
|
+#ifndef ASSEMBLY
|
|
194
|
+
|
|
195
|
+/** Mangle @a name into its weakly-referenced implementation */
|
|
196
|
+#define __weak_impl( name ) _w_ ## name
|
|
197
|
+
|
|
198
|
+/**
|
|
199
|
+ * Declare a weak function with inline safety wrapper
|
|
200
|
+ *
|
|
201
|
+ * @v ret Return type of weak function
|
|
202
|
+ * @v name Name of function to expose
|
|
203
|
+ * @v proto Parenthesized list of arguments with types
|
|
204
|
+ * @v args Parenthesized list of argument names
|
|
205
|
+ * @v dfl Value to return if weak function is not available
|
|
206
|
+ */
|
|
207
|
+#define __weak_decl( ret, name, proto, args, dfl ) \
|
|
208
|
+ ret __weak_impl( name ) proto __attribute__ (( weak )); \
|
|
209
|
+ static inline ret name proto { \
|
|
210
|
+ if ( __weak_impl( name ) ) \
|
|
211
|
+ return __weak_impl( name ) args; \
|
|
212
|
+ return dfl; \
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+#endif
|
|
216
|
+/** @} */
|
|
217
|
+
|
182
|
218
|
/** @defgroup dbg Debugging infrastructure
|
183
|
219
|
* @{
|
184
|
220
|
*/
|