]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
target: add startup and plugin hooks
authorStefan Reinauer <stefan.reinauer@coreboot.org>
Thu, 4 Jun 2026 14:57:12 +0000 (07:57 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Thu, 11 Jun 2026 21:08:30 +0000 (14:08 -0700)
Add narrow target hooks for early startup handling and plugin lookup.

Unix needs these integration points for Qt startup commands and local
plugin discovery without embedding Unix paths in common code.

dlopen.cpp
include/target_dlopen.h [new file with mode: 0644]
include/target_main.h [new file with mode: 0644]
main.cpp

index ed04fc3e7728feb5406013a2cccd2a4d92299bef..b83be9dc52eebf70b89a6416b7d00a93cc5ed1b0 100644 (file)
@@ -3,6 +3,7 @@
 #include "uae/api.h"
 #include "uae/dlopen.h"
 #include "uae/log.h"
+#include "target_dlopen.h"
 
 #ifdef _WIN32
 #include "windows.h"
@@ -76,13 +77,16 @@ UAE_DLHANDLE uae_dlopen_plugin(const TCHAR *name)
        _tcscat(path, LT_MODULE_EXT);
        UAE_DLHANDLE handle = WIN32_LoadLibrary(path);
 #else
-       TCHAR path[MAX_DPATH];
-       _tcscpy(path, name);
+       TCHAR path[MAX_DPATH] = { 0 };
+       UAE_DLHANDLE handle;
+       if (!target_dlopen_plugin(name, path, MAX_DPATH, &handle)) {
+               _tcscpy(path, name);
 #ifdef _WIN64
-       _tcscat(path, _T("_x64"));
+               _tcscat(path, _T("_x64"));
 #endif
-       _tcscat(path, LT_MODULE_EXT);
-       UAE_DLHANDLE handle = uae_dlopen(path);
+               _tcscat(path, LT_MODULE_EXT);
+               handle = uae_dlopen(path);
+       }
 #endif
        if (handle) {
                write_log(_T("DLOPEN: Loaded plugin %s\n"), path);
diff --git a/include/target_dlopen.h b/include/target_dlopen.h
new file mode 100644 (file)
index 0000000..23fffb3
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef UAE_TARGET_DLOPEN_H
+#define UAE_TARGET_DLOPEN_H
+
+static inline bool target_dlopen_plugin(const TCHAR *, TCHAR *, size_t,
+       UAE_DLHANDLE *)
+{
+       return false;
+}
+
+#endif /* UAE_TARGET_DLOPEN_H */
diff --git a/include/target_main.h b/include/target_main.h
new file mode 100644 (file)
index 0000000..2e2a1e7
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef UAE_TARGET_MAIN_H
+#define UAE_TARGET_MAIN_H
+
+static inline void target_main_set_args(int, TCHAR **)
+{
+}
+
+static inline int target_main_handle_early(int, TCHAR **)
+{
+       return -1;
+}
+
+#endif /* UAE_TARGET_MAIN_H */
index fc73b2d94c01de1aff4b1d312785c41fd6eec9ec..c207c593ed45ab4d6b4ae4f86573f229fe760e6c 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -28,6 +28,7 @@
 #include "inputdevice.h"
 #include "keybuf.h"
 #include "gui.h"
+#include "target_main.h"
 #include "zfile.h"
 #include "autoconf.h"
 #include "native2amiga.h"
@@ -1340,6 +1341,10 @@ void real_main (int argc, TCHAR **argv)
 #ifndef NO_MAIN_IN_MAIN_C
 int main (int argc, TCHAR **argv)
 {
+       target_main_set_args(argc, argv);
+       const int early_exit = target_main_handle_early(argc, argv);
+       if (early_exit >= 0)
+               return early_exit;
        real_main (argc, argv);
        return 0;
 }