diff options
author | Ariadne Conill <ariadne@dereferenced.org> | 2021-12-10 14:33:52 -0600 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2021-12-14 21:10:26 +0200 |
commit | 0fd415faf57bdf6e3e459b8315c3d9c8d69b0136 (patch) | |
tree | bff68e521ba540effc90868e99c40a972e2eaf05 /src/apk_applet.h | |
parent | eab6645cb8c03282fbe6b8484c3fd390cfd91a9c (diff) | |
download | apk-tools-0fd415faf57bdf6e3e459b8315c3d9c8d69b0136.tar.gz apk-tools-0fd415faf57bdf6e3e459b8315c3d9c8d69b0136.tar.bz2 apk-tools-0fd415faf57bdf6e3e459b8315c3d9c8d69b0136.tar.xz apk-tools-0fd415faf57bdf6e3e459b8315c3d9c8d69b0136.zip |
applet: rework APK_DEFINE_APPLET to use constructor attribute
this allows the applet registration to work in a portable way, without having to
weird things with the linker.
ref #10794
[TT: rebased for 2.12]
Diffstat (limited to 'src/apk_applet.h')
-rw-r--r-- | src/apk_applet.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/apk_applet.h b/src/apk_applet.h index 3bc2eb9..0ae33b4 100644 --- a/src/apk_applet.h +++ b/src/apk_applet.h @@ -63,12 +63,11 @@ struct apk_applet { extern const struct apk_option_group optgroup_global, optgroup_commit; -void apk_help(struct apk_applet *applet); void apk_applet_register(struct apk_applet *); -typedef void (*apk_init_func_t)(void); +struct apk_applet *apk_applet_find(const char *name); +void apk_applet_help(struct apk_applet *applet); #define APK_DEFINE_APPLET(x) \ -static void __register_##x(void) { apk_applet_register(&x); } \ -static apk_init_func_t __regfunc_##x __attribute__((__section__("initapplets"))) __attribute((used)) = __register_##x; +__attribute__((constructor)) static void __register_##x(void) { apk_applet_register(&x); } #endif |