]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dlfcn-util: add two new macros for making it easier to create "sym_xyz" indirect...
authorLennart Poettering <lennart@poettering.net>
Thu, 2 Nov 2023 14:53:40 +0000 (15:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 3 Nov 2023 08:30:24 +0000 (09:30 +0100)
Let's use "typeof" to make it easier to generate "sym_xyz" wrappers of
functions exposed by libraries.

src/shared/dlfcn-util.h

index ca632f4e1f4b8442aa620b5379c283d5c6c6675a..7d8cb4c9abe21bfe3e1ae235de59dfb56191f8e2 100644 (file)
@@ -15,6 +15,11 @@ int dlopen_many_sym_or_warn_sentinel(void **dlp, const char *filename, int log_l
 #define dlopen_many_sym_or_warn(dlp, filename, log_level, ...) \
         dlopen_many_sym_or_warn_sentinel(dlp, filename, log_level, __VA_ARGS__, NULL)
 
+#define DLSYM_PROTOTYPE(symbol)                 \
+        extern typeof(symbol)* sym_##symbol
+#define DLSYM_FUNCTION(symbol)                  \
+        typeof(symbol)* sym_##symbol = NULL
+
 /* Macro useful for putting together variable/symbol name pairs when calling dlsym_many_or_warn(). Assumes
  * that each library symbol to resolve will be placed in a variable with the "sym_" prefix, i.e. a symbol
  * "foobar" is loaded into a variable "sym_foobar". */