143 Commits

Author SHA1 Message Date
Miro Kropacek e09b9dfad6 PLUGINS: Provide __cxa_atexit & __cxa_finalize
Atari's mintelf platform has ELF support but its libc does not provide
__cxa_atexit / __cxa_finalize, so -fuse-cxa-atexit cannot be used out of
the box. Add a minimal shim (plus a __dso_handle definition for the main
executable) so plugins can register and finalize their function-local
static destructors per DSO on unload.

Note: earlier version ran __cxa_finalize from the host via
findSymbol("__dso_handle"). That works as long as exactly one
__dso_handle ends up in the plugin's symtab (the plugin's own).

When the main binary also defines __dso_handle (so the host's
function-local statics can link with -fuse-cxa-atexit), it breaks: the
plugin link uses --just-symbols=<main binary> and imports that as a
second __dso_handle, and findSymbol can then return the host-imported
one instead of the plugin's own. The two addresses differ, so
__cxa_finalize matches nothing.

The plugin-side helper avoids the ambiguity on every target by using
whichever __dso_handle the plugin's own code already resolved against --
the same one embedded in its __cxa_atexit calls. (PSP2's plugin runtime
has always called __cxa_finalize from inside the plugin for the same
reason; see backends/plugins/psp2/plugin.cpp.)
2026-04-27 02:05:36 +10:00
Filippos Karapetis 6ec64ff379 PLUGINS: Initialize the _currentPlugin var in PluginManagerUncached 2024-12-11 01:03:43 +02:00
Le Philousophe 5169a395a5 PLUGINS: Remove now useless functions
These functions heavily rely on the fact that detection plugin and
engine plugin can be loaded at the same time.
2024-06-30 18:39:06 +02:00
Le Philousophe a1193a02eb PLUGINS: Make findEnginePlugin publicly available
This will allow to remove getEngineFromDetectionPlugin which needs both
plugins loaded at the same time.
2024-06-30 18:39:06 +02:00
Le Philousophe 05a62249a9 PLUGINS: hide unloadAllPlugins from outside of PluginManager
This function will delete all plugins even those also stored in
_allEnginePlugins list which triggers a double free when cleaning up.
2024-06-30 18:39:06 +02:00
Le Philousophe 2575cdacff PLUGINS: Cleanup when destroying PluginManagerUncached
This removes memory leaks when destroying the manager.
2024-06-30 18:39:06 +02:00
Le Philousophe c93f53b491 PLUGINS: Rename getEngineFromMetaEngine to getEngineFromDetectionPlugin
Update comments and variable names accordingly.
This now matches what this function really do.
2024-06-30 18:39:06 +02:00
Cameron Cawley 5b1b14ad80 COMMON: Mark more symbols as const 2023-12-26 20:23:59 +01:00
Le Philousophe b3fbce7782 BACKENDS: Migrate plugins to Path API 2023-12-24 13:19:25 +01:00
Cameron Cawley f3b094e53f ENGINES: Change the MetaEngineDetection interface to match MetaEngine 2022-07-23 23:31:58 +02:00
Cameron Cawley a020300701 ENGINES: Remove use of getEngineId() in MetaEngine subclasses 2022-07-20 11:54:19 +02:00
D G Turner f8e18b81f5 BASE: Fix Redundant Declaration Warnings in Plugin Macros
These generated GCC Warnings when -Wredundant-decls is enabled.
2022-03-07 11:42:19 +00:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Orgad Shaneh b11c5ace90 BACKENDS: JANITORIAL: Remove 'virtual' when override is specified 2021-11-14 14:31:41 +02:00
Eugene Sandulenko 436e47292e BASE: Load engine plugins by name. Fixes bug #12342
This is a degradation from the split of detection plugins. All the
caching code which was present was left with detection plugins which
now make no sense: we always load all detection plugins as a whole.

This commit moves the caching logic over to the Engine plugins.

This opens a question now whether we should move all to UNCACHED_PLUGINS
2021-08-16 20:32:53 +02:00
Eric Culp a3af191753 GRAPHICS/BASE: Adds definitions for scaler plugins
This includes a class for plugin implementations to inherit from and
code necessary for plugin managers to use scalers
2021-03-15 16:48:40 +02:00
Cameron Cawley 76ac4414ec BASE: Fix crash when building with uncached plugins and static detection 2021-02-08 03:09:58 +02:00
Bartosz Gentkowski 7192ec0bb5 DOXYGEN: Fix the build output and structure
This commit introduces a couple tweaks to the
doxygen build configuration to assure the
overall structure looks correct.
2020-12-02 22:55:41 +00:00
Eugene Sandulenko 7ea6781043 PLUGINS: PLUGIN_TYPE_METAENGINE -> PLUGIN_TYPE_ENGINE_DETECTION 2020-10-11 23:12:32 +02:00
aryanrawlani28 c48719404a BASE: PLUGINS: Rename plugin matching helpers
- give*From* -> get*From*
2020-10-03 14:56:36 +02:00
Eugene Sandulenko ceabaf3b0d BASE: Added override keywords 2020-10-03 14:56:36 +02:00
aryanrawlani28 8dfaf6cc0e BASE: PLUGINS: Add support for detection plugins to be loaded on demand.
- Mainly used for UncachedPluginManagers.
- CachedPluginManagers will not handle these, as metaengines will always be available in memory.
2020-10-03 14:56:36 +02:00
aryanrawlani28 b78534dcb0 BASE: PLUGINS: Seperate declaration/definition of StaticPlugins.
- Move declarations inside plugins.h to make it visible to detection/detection.cpp
2020-10-03 14:56:36 +02:00
aryanrawlani28 408158edc9 BASE: PLUGINS: Add a new type of plugin - DETECTION. 2020-10-03 14:56:36 +02:00
aryanrawlani28 39f5c93c5c BASE: PLUGINS: Bump PLUGIN_TYPE_ENGINE_VERSION to 2
- Because of the many changes happening to engine classes, it would be a good idea to update the version, something similiar was done with themes.
2020-10-03 14:56:36 +02:00
aryanrawlani28 50e9f0d875 BASE: PLUGINS: Add helper methods which match MetaEngine to Engine & vice-versa 2020-10-03 14:56:36 +02:00
aryanrawlani28 f2dd03e7d8 BASE: PLUGINS: Implement a getEngineId for PluginObjects, return nullptr by default.
- See comments.
2020-10-03 14:56:36 +02:00
aryanrawlani28 6689fa740a BASE: PLUGINS: Add a new type of plugin - MetaEngine
- MetaEngines will now always go to the executable.
- But, because they still live in engine projects and are connected via a macro, they will need to be differentiated from Engines.
- This macro, and it's use in future will help in that.
2020-10-03 14:56:36 +02:00
Bastien Bouclet bb813719b5 ENGINES: Change targets to have an 'engine ID'
The engine ID identifies which engine should be used to launch the target.
Also remove the 'single ID' system. Different games from engines that used
that system now have different game IDs.

Also-By: Matthew Hoops <clone2727@gmail.com>
2019-11-03 11:43:00 +01:00
Eric Culp 6d11f46b15 BASE: Only reload engine plugins after return to launcher
The other plugins do not need to be reloaded. Reloading
the scaler plugins breaks the graphics.
2019-03-10 03:49:29 +02:00
sluicebox e67b8501bf WIN32: Fix embedding disabled engine files
Fix Windows builds (msvc and mingw) including data files from disabled
engines as embedded resources in executable. Bug #10878
2019-03-02 10:01:37 +02:00
Adrian Frühwirth 3747d852ee JANITORIAL: Fix whitespace 2018-04-15 16:31:31 +02:00
Colin Snover d087c9605f BASE: Remove bad casts between incompatible Plugin types
Previously, a C-style cast was used to convert a
Common::Array<Plugin *>, populated with pointers to StaticPlugin
and DynamicPlugin instances, to a
Common::Array<PluginSubclass<T> *>, but PluginSubclass<T> is a
*sibling* class to StaticPlugin/DynamicPlugin, so this cast was
invalid and the results undefined. The methods for retrieving
subclasses of plugins can't be easily changed to just generate an
array of temporary wrapper objects that expose an identical API
which dereferences to the preferred PluginObject subclass because
pointers to these objects are retained by other parts of ScummVM,
so the wrappers would needed to be persisted or they would need to
just re-expose the underlying Plugin object again. This indicated
that a way to solve this problem is to have the callers receive
Plugin objects and get the PluginObject from the Plugin by
explicitly stating their desired type, in a similar manner to
std::get(std::variant), so that the pattern used by this patch to
solve the problem.

Closes gh-1051.
2017-12-03 20:26:38 -06:00
Ori Avtalion 4d120800fa ALL: Don't use 'defined' in macro definitions
This is undefined behavior and clang warns about it.
See <http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147239.html>.
2016-07-23 16:18:51 +03:00
Johannes Schickel f62153c795 BASE: Make GPL headers consistent in themselves. 2014-02-18 02:39:32 +01:00
D G Turner dd18159578 BASE: Fix uninitialized type field in plugin base class. CID 1002938. 2013-09-30 02:26:44 +01:00
Johannes Schickel b7c3ffd37c BASE: Add operator* to PluginSubclass. 2012-06-14 03:12:48 +02:00
Alyssa Milburn 31d1ae6530 Revert "BASE: Get rid of unecessary friend in PluginManagerUncached."
This reverts commit 1e0de79cf5.
The only available constructor for PluginManagerUncached is
protected, so this broke the builds using it.
2012-02-01 21:54:40 +01:00
Johannes Schickel 1e0de79cf5 BASE: Get rid of unecessary friend in PluginManagerUncached. 2012-02-01 19:38:27 +01:00
Max Horn 88913c0139 ALL: Remove trailing whitespaces
This tries to make our code a bit more compliant with our code formatting
conventions. For future use, this is the command I used:
  git ls-files "*.cpp" "*.h" | xargs sed -i -e 's/[ \t]*$//'
2011-06-20 00:59:48 +02:00
D G Turner 5a2e6e4f3f BUILD: Fix compilation when --enable-plugins is enabled. 2011-05-31 04:44:12 +01:00
strangerke 69b1485a22 GIT: Clean up: Suppress SVN tags, now useless 2011-05-12 01:16:22 +02:00
Ori Avtalion 9414d7a6e2 JANITORIAL: Reduce header dependencies in shared code
Some backends may break as I only compiled SDL
2011-04-28 15:08:58 +03:00
Ori Avtalion cd6ee0589d JANITORIAL: Format forward declarations to follow convention 2011-04-28 12:20:34 +03:00
Jordi Vilalta Prat a422763833 BUILD: Remove explicit references to SVN in revision variable names.
svn-id: r55898
2011-02-12 16:43:57 +00:00
Yotam Barnoy 8f36a5f887 PLUGINS: single plugin model now saves plugin filename to config file
After searching for the right plugin once, the filename will be saved to the config file under the domain 'plugin_files'. The key is the gameid and the value is the plugin file. The backup mechanism is searching plugin by plugin.

svn-id: r55061
2010-12-29 15:25:21 +00:00
Yotam Barnoy 10b96eb94d PLUGINS: PluginManager minor cleanups
svn-id: r55027
2010-12-23 14:37:03 +00:00
Yotam Barnoy ee2b1092ab PLUGINS: switched plugin manager to inheritance rather than #defines
The reason for this was that I found issues where the wrong functions were called in EngineManager for single plugin operation. Rather than inserting more messy #defines, I preferred to change the PluginManager to use virtual functions, which also makes EngineManager simpler.

svn-id: r55024
2010-12-23 13:38:37 +00:00
Yotam Barnoy a6bee87990 PLUGINS: improved one-at-a-time plugin code
I reduced memory fragmentation using 2 principles: Plugins should be loaded for as little time as possible, and long lasting memory allocations should be allocated before plugins are loaded. There might still be a little fragmentation left.
Note that command line settings that require plugins to be loaded don't work yet, but they didn't work (properly) before either.

svn-id: r54097
2010-11-05 13:24:57 +00:00
Andre Heider 2596143e2b PLUGINS: Additional plugin check for the ELF loader.
The ELF loader does not have access to the symbols of the main
executable, it just relocates symbols to it via fixed offsets. We need
to make sure that loaded plugins are from the same link process to
prevent crashes. An embedded build date is used for that.

svn-id: r52730
2010-09-15 07:44:08 +00:00