Commit graph

112 commits

Author SHA1 Message Date
RipleyTom cd87a64621 Headers cleanup 2025-02-11 20:38:35 +01:00
Elad 6165c2d8b3 Thread.h: Fix a bug by adding thread_state::destroying_context 2025-01-05 10:01:35 +02:00
Elad 2614450e4b Fix IDM image serialization 2025-01-04 09:29:09 +02:00
Megamouse 33c3e3fb0f fix some warning 2024-12-28 18:10:06 +01:00
Elad 3bf735161f sys_config: Move cleanup to IDM abort 2024-12-24 21:31:57 +02:00
Megamouse 53817dcc90 Fix fs::file log formatting 2024-12-23 11:29:13 +01:00
Elad 575a245f8d
IDM: Implement lock-free smart pointers (#16403)
Replaces `std::shared_pointer` with `stx::atomic_ptr` and `stx::shared_ptr`.

Notes to programmers:

* This pr kills the use of `dynamic_cast`, `std::dynamic_pointer_cast` and `std::weak_ptr` on IDM objects, possible replacement is to save the object ID on the base object, then use idm::check/get_unlocked to the destination type via the saved ID which may be null. Null pointer check is how you can tell type mismatch (as dynamic cast) or object destruction (as weak_ptr locking).
* Double-inheritance on IDM objects should be used with care, `stx::shared_ptr` does not support constant-evaluated pointer offsetting to parent/child type.
* `idm::check/get_unlocked` can now be used anywhere.

Misc fixes:
* Fixes some segfaults with RPCN with interaction with IDM.
* Fix deadlocks in access violation handler due locking recursion.
* Fixes race condition in process exit-spawn on memory containers read.
* Fix bug that theoretically can prevent RPCS3 from booting - fix `id_manager::typeinfo` comparison to compare members instead of `memcmp` which can fail spuriously on padding bytes.
* Ensure all IDM inherited types of base, either has `id_base` or `id_type` defined locally, this allows to make getters such as `idm::get_unlocked<lv2_socket, lv2_socket_raw>()` which were broken before. (requires save-states invalidation)
* Removes broken operator[] overload of `stx::shared_ptr` and `stx::single_ptr` for non-array types.
2024-12-22 20:59:48 +02:00
oltolm 9e9a3262eb simplify template code like std::is_same<T>::value 2024-04-21 18:15:17 +03:00
Eladash 526aaf7302 Fix idm::allocate_id at fixed position 2023-12-29 11:11:53 +02:00
Eladash f696107c90 Add savestate data validity asserts 2023-12-29 11:11:53 +02:00
Eladash f60bdbaece Savestates: Compressed state files 2023-11-27 12:36:17 +02:00
Eladash d335d356ca IdManager.h: Savestate fix part 2 2023-10-05 05:07:46 +03:00
Eladash 96d31cf64e IdManager.h: Savestate fix 2023-10-02 15:38:58 +03:00
oltolm 0c94606fcf
Make compile with msvc, clang and gcc on Windows 2023-07-11 21:40:30 +03:00
Eladash 5f2f084091 Savestate/IDM: Do not save unsavable containers 2023-06-28 18:34:33 +03:00
Nekotekina b49a1f27eb Warning fixes 2022-09-17 16:35:02 +03:00
Eladash 5e2424da58 IdManager.cpp: Fix cellFs IDs 2022-09-07 17:05:51 +03:00
Eladash b55a052a22 IdManager.h: Do not lock IDM mutex if the preliminary ID check failed
Optimizes common ESRCH failures. (lambda variants only atm)
2022-08-07 20:23:54 +03:00
Eladash 72c14994f0 Savestates: Fix memory containers initialization (invalidates old savestates) 2022-07-05 08:25:36 +02:00
Elad Ashkenazi fcd297ffb2
Savestates Support For PS3 Emulation (#10478) 2022-07-04 16:02:17 +03:00
Eladash 71e07dc6c7 IdManager.h: Improvements
* Ensure ::PtrSame<T, Derived> is true.
* Allow id_base, id_step and id_count to be of enumeration type.
* Fix potential deadlock in kernel explorer.

idm::select:
* Allow to select multiple inherited object types for idm::select.
* Allow function reference types. (they don't allow access to operator() directly, use deducing std::function constructor instead)
* Ensure ::is_same_ptr<T, object_type> is true.
2022-06-22 17:24:47 +03:00
Eladash 76bf720adf Improve emulation stopping speed
Split phases of signalling threads and joining them.
2021-06-08 18:26:14 +03:00
Nekotekina 160b131de3 types.hpp: implement smin, smax, amin, amax
Rewritten the following global utility constants:
`umax` returns max number, restricted to unsigned.
`smax` returns max signed number, restricted to integrals.
`smin` returns min signed number, restricted to signed.
`amin` returns smin or zero, less restricted.
`amax` returns smax or umax, less restricted.

Fix operators == and <=> for synthesized rel-ops.
2021-05-22 12:10:57 +03:00
Nekotekina 7dae376646 Implement fill_array() utility 2021-04-19 12:33:32 +03:00
Eladash 4a9be0a8d2 core: Move IDM to FXO 2021-04-04 17:29:32 +03:00
Nekotekina d788b12a8e fixed_typemap.hpp: reduce indirection
Backported some changes from auto_typemap.hpp
Implemented methods init(), reset(), clear()
Disabled recreation support.
2021-03-02 16:08:14 +03:00
Nekotekina b59f142d4e Move types.h to util/types.hpp 2020-12-12 15:12:01 +03:00
RipleyTom af8c661a64 Remove BOM markers 2020-12-06 15:30:12 +03:00
Eladash f0d526411c IDM: Implement idm::clear<typename> 2020-06-12 22:12:36 +03:00
Eladash 3265772ae4 idm: Implement creation/destruction invalidation counter
* "Ensures" newely created IDs won't have the same ID as old destroyed objects for lv2_obj. (256 tries cycle)

Similar to how the kernel implements it.
2020-05-24 19:24:07 +03:00
Eladash 141d62fbf9 Implement ::as_rvalue 2020-04-11 21:58:36 +03:00
Eladash 93b8f3b5db idm: Minor update to use std::static_pointer_cast 2020-04-11 10:58:24 +03:00
Eladash efe6e1eb0a sys_ppu_thread: Make PPU id removal after exit atomic with descheduling
* Make PPU id removal after exit atomic with descheduling
* Make joining thread scheduling atomic with thread exit sleep.
* Update sys_ppu_thread_stop/restart.
* Add idm::remove_verify.
2020-03-14 18:30:14 +02:00
Eladash 1d4595a349 Idm: Minor assert fix 2020-02-15 10:41:15 +03:00
Nekotekina c0f80cfe7a Use attributes for LIKELY/UNLIKELY
Remove LIKELY/UNLIKELY macro.
2020-02-05 10:42:34 +03:00
Nekotekina 465b16e786 Finally remove fxm from IdManager 2019-09-26 23:26:36 +03:00
msuih 5ac631e03b Fix debug build
Seems to be a compiler bug
2019-09-25 23:20:52 +03:00
Nekotekina c900fb0d77 Delete g_idm
Needs to be reimplemented
2019-09-17 15:55:58 +03:00
Nekotekina dd79a5efb7 Remove fxm::make_always 2019-08-27 03:50:15 +03:00
Nekotekina fcbf91b7cb Deprecate fxm::get_always
And also its unused fxm::import_always counterpart
2019-08-27 03:50:15 +03:00
Nekotekina 8517ccfdfa Add new typemap for always existing objects
Not to be confused with singletons or global variables.
2019-08-22 02:13:39 +03:00
Eladash 96527eee5b idm: Fix bug in ID searching
* ID checking now checks if (id % step) == 0
* Extend possible ID range to allow UINT32_MAX (as long as base is non-zero)
2019-08-11 21:43:13 +03:00
gidan80 9aa08313e3 Qt: Add custom pad configs
Add a custom pad config for every game.
2019-05-16 20:37:41 +02:00
Nekotekina 1b37e775be Migration to named_thread<>
Add atomic_t<>::try_dec instead of fetch_dec_sat
Add atomic_t<>::try_inc
GDBDebugServer is broken (needs rewrite)
Removed old_thread class (former named_thread)
Removed storing/rethrowing exceptions from thread
Emu.Stop doesn't inject an exception anymore
task_stack helper class removed
thread_base simplified (no shared_from_this)
thread_ctrl::spawn simplified (creates detached thread)
Implemented overrideable thread detaching logic
Disabled cellAdec, cellDmux, cellFsAio
SPUThread renamed to spu_thread
RawSPUThread removed, spu_thread used instead
Disabled deriving from ppu_thread
Partial support for thread renaming
lv2_timer... simplified, screw it
idm/fxm: butchered support for on_stop/on_init
vm: improved allocation structure (added size)
2018-10-19 22:22:35 +03:00
Nekotekina 19a64e0e94 Add g_typemap and g_idm alias
Future idm/fxm replacement
2018-10-02 02:22:26 +03:00
Nekotekina ee96807305 Remove explicit_bool_t, ignore, multicast<>
Remove vm::ptr operator %
This was a bad idea but explicit_bool_t was created almost for it
Other removed types are unused and have little to no meaning
2018-09-08 00:32:04 +03:00
Nekotekina 99ffc3fca9 Use std::invoke_result_t
Also simplify idm code
2018-09-08 00:32:04 +03:00
Nekotekina ca5158a03e Cleanup semaphore<> (sema.h) and mutex.h (shared_mutex)
Remove semaphore_lock and writer_lock classes, replace with std::lock_guard
Change semaphore<> interface to Lockable (+ exotic try_unlock method)
2018-09-03 23:00:36 +03:00
Nekotekina 6cc7d1fb26 Use std::void_t 2018-08-24 16:44:19 +03:00
Nekotekina 4b6f8d2f62 fxm::check_unlocked added 2017-02-22 12:57:39 +03:00