Commit graph

73 commits

Author SHA1 Message Date
Lioncash
cb111c0038 common_funcs: Move R_ macros to result.h
These macros all interact with the result code type, so they should
ideally be within this file as well, so all the common_funcs machinery
doesn't need to be pulled in just to use them.
2021-05-31 16:41:00 -04:00
bunnei
5b894b28d6 common: Rename NON_COPYABLE/NON_MOVABLE with YUZU_ prefix. 2021-05-05 16:40:53 -07:00
bunnei
b477e9e11b common: common_funcs: Add Size helper function. 2021-05-05 16:40:49 -07:00
bunnei
092b91aeb7 common: common_funcs: Add helper macros for non-copyable and non-moveable.
- Useful for scenarios where we do not want to inherit from NonCopyable.
2021-05-05 16:40:49 -07:00
comex
4258b4985a [network] Error handling reform
`network.cpp` has several error paths which either:
- report "Unhandled host socket error=n" and return `SUCCESS`, or
- switch on a few possible errors, log them, and translate them to
  Errno; the same switch statement is copied and pasted in multiple
  places in the code

Convert these paths to use a helper function `GetAndLogLastError`, which
is roughly the equivalent of one of the switch statements, but:
- handling more cases (both ones that were already in `Errno`, and a few
  more I added), and
- using OS functions to convert the error to a string when logging, so
  it'll describe the error even if it's not one of the ones in the
  switch statement.
  - To handle this, refactor the logic in `GetLastErrorMsg` to expose a
    new function `NativeErrorToString` which takes the error number
    explicitly as an argument.  And improve the Windows version a bit.

Also, add a test which exercises two random error paths.
2021-02-28 17:25:31 -05:00
bunnei
4bb6de297f common: common_funcs: Change R_UNLESS to LOG_ERROR. 2021-01-28 21:51:16 -08:00
bunnei
d685f12dbc common: common_funcs: Log error on R_UNLESS. 2021-01-28 21:42:26 -08:00
bunnei
7351708eea common: common_funcs: Add useful kernel macro R_SUCCEED_IF. 2021-01-28 21:42:26 -08:00
bunnei
39987beb17 common: common_funcs: Add a few more useful macros for kernel code. 2021-01-28 21:42:25 -08:00
ReinUsesLisp
92ca4929f5 common/common_funcs: Rename INSERT_UNION_PADDING_{BYTES,WORDS} to _NOINIT
INSERT_PADDING_BYTES_NOINIT is more descriptive of the underlying behavior.
2021-01-15 16:27:28 -03:00
bunnei
bf73b6ed86 common: common_funcs: Add R_UNLESS macro. 2021-01-11 14:23:16 -08:00
Lioncash
50c1158d21 common_funcs: Add missing XOR operators to DECLARE_ENUM_FLAG_OPERATORS
Ensures that the full set of bitwise operators are available for types
that make use of this macro.
2020-08-24 04:42:43 -04:00
Lioncash
2ef7815422 common: Make use of [[nodiscard]] where applicable
Now that clang-format makes [[nodiscard]] attributes format sensibly, we
can apply them to several functions within the common library to allow
the compiler to complain about any misuses of the functions.
2020-08-15 17:17:52 -04:00
bunnei
f9a8cc03c3 common: common_funcs: Add a macro for defining enum flag operators. 2020-04-17 00:59:27 -04:00
Lioncash
51d9e22b7e common_funcs: Remove semicolons from INSERT_PADDING_* macros
Makes code that uses the macros consistent by requiring the lines to be
terminated with a semicolon.
2019-11-14 17:05:27 -05:00
Lioncash
ae15e162be common_funcs: silence sign-conversion warnings in MakeMagic()
We can trivially resolve these by casting the characters to unsigned
values and then shifting the bits.
2019-11-13 06:53:19 -05:00
bunnei
fe02b9f968 common_func: Use std::array for INSERT_PADDING_* macros.
- Zero initialization here is useful for determinism.
2019-11-03 22:22:41 -05:00
bunnei
da2cf661f1 Revert "common_func: Use std::array for INSERT_PADDING_* macros." 2019-11-03 04:39:51 -05:00
bunnei
388a651346 common_func: Use std::array for INSERT_PADDING_* macros.
- Zero initialization here is useful for determinism.
2019-11-03 04:30:16 -05:00
Fernando Sahmkow
c3c7215820 texture_cache: Address Feedback 2019-07-05 09:46:53 -04:00
Fernando Sahmkow
20e97604f1 Reduce amount of size calculations. 2019-06-20 21:36:12 -03:00
Cameron Cawley
edf024592e Port #3732 from Citra: "common: Fix compilation on ARM" 2018-07-29 15:51:31 +02:00
bunnei
a8139e0c59 Merge pull request #710 from lioncash/unused
common/common_funcs: Remove unused rotation functions
2018-07-19 11:43:41 -07:00
Lioncash
3ec8aa2bb9 common/common_funcs: Remove unused rotation functions
These are unused and essentially don't provide much benefit either. If
we ever need rotation functions, these can be introduced in a way that
they don't sit in a common_* header and require a bunch of ifdefing to
simply be available
2018-07-19 09:21:23 -04:00
Lioncash
03d8c78199 common/misc: Deduplicate code in GetLastErrorMsg()
Android and macOS have supported thread_local for quite a while, but
most importantly is that we don't even really need it. Instead of using
a thread-local buffer, we can just return a non-static buffer as a
std::string, avoiding the need for that quality entirely.
2018-07-19 09:15:38 -04:00
fearlessTobi
365753a98c Port #3579 from Citra 2018-07-07 13:59:18 +02:00
bunnei
d7a69c96e4 Merge pull request #362 from lioncash/snprintf
common_funcs: Remove check for VS versions that we don't even support
2018-04-20 09:43:30 -04:00
Lioncash
c9f5ae4fcc common_funcs: Remove ARRAY_SIZE macro
C++17 has non-member size() which we can just call where necessary.
2018-04-19 22:36:52 -04:00
Lioncash
4b0e4421f4 common_funcs: Remove check for VS versions that we don't even support
We don't support any VS versions that don't already have snprintf in the
standard library implementation.
2018-04-19 22:28:56 -04:00
bunnei
5e11c12766 core: Refactor MakeMagic usage and remove dead code. 2017-10-15 00:11:38 -04:00
Yuri Kunde Schlesner
8b55ffb74a Common: Fix some out-of-style includes 2017-05-27 16:14:10 -07:00
Emmanuel Gil Peyrot
1138ec0d49 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
Yuri Kunde Schlesner
1e4a5da9f4 Manually tweak source formatting and then re-run clang-format 2016-09-18 21:14:25 -07:00
Emmanuel Gil Peyrot
628ed4376a Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
MerryMage
b7b02d0177 common_funcs: Provide rotr and rotl for MSVC 2016-05-27 10:42:06 +01:00
Emmanuel Gil Peyrot
c39a267974 VideoCore: Run include-what-you-use and fix most includes. 2016-04-30 17:02:41 +01:00
Lioncash
f932c2f4ac Common: Get rid of alignment macros
The gl rasterizer already uses alignas,
so we may as well move everything over.
2016-03-09 01:31:14 -05:00
darkf
8d212ff881 Fix building under MinGW 2015-08-17 22:21:14 -07:00
bunnei
4ffc095fa3 Rename ARCHITECTURE_X64 definition to ARCHITECTURE_x86_64. 2015-08-15 18:03:27 -04:00
bunnei
f9e3228caa x64: Refactor to remove fake interfaces and general cleanups. 2015-08-15 18:03:25 -04:00
bunnei
3d35d53b8d Common: Ported over boilerplate x86 JIT code from Dolphin/PPSSPP. 2015-08-15 17:33:45 -04:00
archshift
58e2d19f08 Stop defining GCC always_inline attributes as __forceinline
__forceinline is a MSVC extension, which may confuse some people working on the codebase.
Furthermore, the C++ standard dictates that all names which contain adjacent underscores are reserved.
2015-08-11 19:45:15 -07:00
Apology11
af18572491 don´t define snprintf on Visual Studio 2015
Visual Studio 2015 defines this in stdio now
2015-07-12 13:12:14 +02:00
Emmanuel Gil Peyrot
1775adc34c Common: Remove unused ROUND_UP_POW2 macro. 2015-06-28 00:36:54 +01:00
Emmanuel Gil Peyrot
2d044a67c9 Common: Cleanup memory and misc includes. 2015-06-28 00:36:54 +01:00
Yuri Kunde Schlesner
b700b55696 Common: Remove the BIT macro
When the macro was introduced in 326ec51261
it wasn't noticed that it conflicted in name with a heavily used macro
inside of dyncom. This causes some compiler warnings. Since it's only
lightly used, it was opted to simply remove the new macro.
2015-05-09 18:16:46 -03:00
Yuri Kunde Schlesner
326ec51261 Common: Add BIT macro 2015-05-08 22:11:04 -03:00
Yuri Kunde Schlesner
fae5933ad6 Common: Add proper macros to test for architecture pointer size
The old system of just defining macros available in some other platform
was susceptible to silently using the wrong code if you forgot to
include a particular header. This fixes a crash on non-Windows platforms
introduced by e1fbac3ca1.
2015-05-07 18:22:36 -03:00
Yuri Kunde Schlesner
1bd1a13a02 Common: Move alignment macros to common_funcs.h 2015-05-07 15:45:21 -03:00
Yuri Kunde Schlesner
a594fdb66e Common: Remove more unused compatibility defines 2015-05-07 15:45:20 -03:00