From: Lennart Poettering Date: Thu, 2 Nov 2023 14:53:40 +0000 (+0100) Subject: dlfcn-util: add two new macros for making it easier to create "sym_xyz" indirect... X-Git-Tag: v255-rc1~34^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9519b947960d4783624afee68b11946ee70f8252;p=thirdparty%2Fsystemd.git dlfcn-util: add two new macros for making it easier to create "sym_xyz" indirect function call variables Let's use "typeof" to make it easier to generate "sym_xyz" wrappers of functions exposed by libraries. --- diff --git a/src/shared/dlfcn-util.h b/src/shared/dlfcn-util.h index ca632f4e1f4..7d8cb4c9abe 100644 --- a/src/shared/dlfcn-util.h +++ b/src/shared/dlfcn-util.h @@ -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". */