Commit graph

26 commits

Author SHA1 Message Date
Morph
290afc00d3 common: Move error handling to error.cpp/h
This allows us to avoid implicitly including <string> every time common_funcs.h is included.
2021-09-11 17:19:14 -04:00
comex
d37f0b29e2 Fix thread naming on Linux, which limits names to 15 bytes.
- In `SetCurrentThreadName`, when on Linux, truncate to 15 bytes, as (at
  least on glibc) `pthread_set_name_np` will otherwise return `ERANGE` and
  do nothing.
- Also, add logging in case `pthread_set_name_np` returns an error
  anyway.  This is Linux-specific, as the Apple and BSD versions of
  `pthread_set_name_np return `void`.
- Change the name for CPU threads in multi-core mode from
  "yuzu:CoreCPUThread_N" (19 bytes) to "yuzu:CPUCore_N" (14 bytes) so it
  fits into the Linux limit.  Some other thread names are also cut off,
  but I didn't bother addressing them as you can guess them from the
  truncated versions.  For a CPU thread, truncation means you can't see
  which core it is!
2020-08-05 20:34:49 -07:00
Fernando Sahmkow
467d43570e Clang Format. 2020-06-27 11:36:14 -04:00
Fernando Sahmkow
528b19a842 General: Tune the priority of main emulation threads so they have higher priority than less important helper threads. 2020-06-27 11:36:09 -04:00
Fernando Sahmkow
e31425df38 General: Recover Prometheus project from harddrive failure
This commit: Implements CPU Interrupts, Replaces Cycle Timing for Host 
Timing, Reworks the Kernel's Scheduler, Introduce Idle State and 
Suspended State, Recreates the bootmanager, Initializes Multicore 
system.
2020-06-27 11:35:06 -04:00
Vitor K
bd0c56c6e7 common: Port some changes from dolphin (#5127)
* IOFile: Make the move constructor and move assignment operator noexcept

Certain parts of the standard library try to determine whether or not a
transfer operation should either be a copy or a move. The prevalent notion
of move constructors/assignment operators is that they should not throw,
they simply move an already existing resource somewhere else.

This is typically done with 'std::move_if_noexcept'. Like the name says,
if a type's move constructor is noexcept, then the functions retrieves an
r-value reference (for move semantics), or an l-value (for copy semantics)
if it is not noexcept.

As IOFile deletes the copy constructor and copy assignment operators,
using IOFile with certain parts of the standard library can fail in
unexcepted ways (especially when used with various container
implementations). This prevents that.

* fix various instances of -1 being assigned to unsigned types

* do not assign in conditional statements

* File/IOFile: Check _tfopen_s properly

* common/file_util.cpp: address review comments

Co-authored-by: Lioncash <mathew1800@gmail.com>
Co-authored-by: Shawn Hoffman <godisgovernment@gmail.com>
Co-authored-by: Sepalani <sepalani@hotmail.fr>
2020-04-01 02:58:42 +02:00
Lioncash
394095438a common/thread: Remove unused functions
Many of these functions are carried over from Dolphin (where they aren't
used anymore). Given these have no use (and we really shouldn't be
screwing around with OS-specific thread scheduler handling from the
emulator, these can be removed.

The function for setting the thread name is left, however, since it can
have debugging utility usages.
2019-03-29 13:26:21 -04:00
Lioncash
1bf5a337a5 common/thread: Drop Hungarian notation on SetCurrentThreadName's parameter
This is inconsistent with our coding style.
2018-11-22 00:40:26 -05:00
Lioncash
d6583d68f6 common/thread: Remove SleepCurrentThread()
This is also unused and superceded by standard functionality. The
standard library provides std::this_thread::sleep_for(), which provides
a much more flexible interface, as different time units can be used with
it.
2018-11-21 21:40:11 -05:00
Lioncash
1d555fdd25 common/thread: Remove unused CurrentThreadId()
This is an old function that's no longer necessary. C++11 introduced
proper threading support to the language and a thread ID can be
retrieved via std::this_thread::get_id() if it's ever needed.
2018-11-21 21:37:11 -05:00
Jannik Vogel
45d941d62e Support mingw cross-compile 2016-12-05 19:09:16 +01:00
Jan Beich
8ce1ec7ffa common: only FreeBSD has thread affinity compatible with Linux
src/common/thread.cpp:90:5: error: unknown type name 'cpu_set_t'; did you mean 'cpuset_t'?
    cpu_set_t cpu_set;
    ^~~~~~~~~
    cpuset_t
/usr/include/sys/_cpuset.h:48:24: note: 'cpuset_t' declared here
typedef struct _cpuset cpuset_t;
                       ^
1 error generated.
2016-10-27 23:28:29 +00:00
Jan Beich
1410bd3bd0 common: define routines to set thread name on more BSDs
src/common/thread.cpp:123:5: error: use of undeclared identifier 'pthread_setname_np'
    pthread_setname_np(pthread_self(), szThreadName);
    ^
1 error generated.
2016-10-27 23:28:29 +00:00
Emmanuel Gil Peyrot
ebdae19fd2 Remove empty newlines in #include blocks.
This makes clang-format useful on those.

Also add a bunch of forgotten transitive includes, which otherwise
prevented compilation.
2016-09-21 11:15:47 +09:00
Emmanuel Gil Peyrot
dc8479928c Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
Emmanuel Gil Peyrot
2a36edfd86 Common: Cleanup thread includes. 2015-06-28 00:36:53 +01:00
darkf
5d10b212ec Fix MSVC-related #defines and add CMakeLists comment 2014-12-29 20:12:03 -08:00
darkf
8ba9ac0f74 Fix merge conflicts 2014-12-29 19:47:41 -08:00
purpasmart96
ebfd831ccb License change 2014-12-20 21:20:24 -08:00
darkf
459502e48c Fix MinGW build 2014-11-28 21:38:20 -08:00
Emmanuel Gil Peyrot
f5d38649c7 Remove trailing spaces in every file but the ones imported from SkyEye, AOSP or generated 2014-11-19 09:03:07 +00:00
archshift
9d7cc2bedc common: Prune all redundant includes 2014-09-08 17:25:43 -07:00
archshift
498d1a37f1 Removed common/std_xyz, instead using the std header 2014-09-07 14:31:07 -07:00
Anthony J. Bentley
dad3655a6d Use pthread_set_name_np() on OpenBSD. 2014-08-07 22:56:58 -06:00
bunnei
de0a034a84 fixed project includes to use new directory structure 2014-04-08 20:15:08 -04:00
bunnei
63e46abdb8 got rid of 'src' folders in each sub-project 2014-04-08 19:25:03 -04:00
Renamed from src/common/src/thread.cpp (Browse further)