Commit Graph

2904 Commits

Author SHA1 Message Date
Lioncash c4fb07f428 Common, DSP: Only compile in x86-64 emitter related utilities on x86 platforms
Previously these were required to be built into the executable so that
the JIT portion of the DSP code would build properly, as the
x86-64-specifics were tightly coupled to the DSP common code. As this is
no longer the case, this is no longer necessary.
2018-06-21 06:53:31 -04:00
Lioncash dddac76b8c Common/MemoryPatches: Silence variable shadowing warnings 2018-06-19 21:33:50 -04:00
Lioncash 6f473b96d0 PowerPC: Convert CPUCore enum into an enum class
Makes the enum values strongly-typed and prevents the identifiers from
polluting the PowerPC namespace. This also cleans up the parameters of
some functions where we were accepting an ambiguous int type and
expecting the correct values to be passed in.

Now those parameters accept a PowerPC::CPUCore type only, making it
immediately obvious which values should be passed in. It also turns out
we were storing these core types into other structures as plain ints,
which have also been corrected.

As this type is used directly with the configuration code, we need to
provide our own overloaded insertion (<<) and extraction (>>) operators
in order to make it compatible with it. These are fairly trivial to
implement, so there's no issue here.

A minor adjustment to TryParse() was required, as our generic function
was doing the following:

N tmp = 0;

which is problematic, as custom types may not be able to have that
assignment performed (e.g. strongly-typed enums), so we change this to:

N tmp;

which is sufficient, as the value is attempted to be initialized
immediately under that statement.
2018-06-15 10:27:59 -04:00
Léo Lam 58606702f7
Merge pull request #7107 from lioncash/mac
Common/Network: Get rid of out parameters for MAC address utilities
2018-06-14 19:44:09 +02:00
Lioncash 189d277cfc Common/Random: Add convenience template for simple arithmetic values
In cases where we just want a random value for a primitive arithmetic
type, we can wrap this in a template to allow convenient direct
assignment instead of keeping declaration and initialization separate
(making it more difficult to use values uninitialized). This also allows
the use of Common::Random with functions such as std::generate, making
it more flexible in how random values can be generated.
2018-06-14 10:31:13 -04:00
Lioncash ce69201f33 Common/Network: Get rid of out parameters for MAC address utilities
Given we have std::array and std::optional, we can use these in
conjunction with one another to avoid the need for out parameters.
2018-06-10 15:43:26 -04:00
Lioncash c825eecbc9 ChunkFile: Remove unnecessary includes
ChunkFile doesn't use any of the file utilities, so we can drop these
headers to avoid pulling in unnecessary dependencies. This also
uncovered a few indirect inclusions.
2018-06-09 16:49:59 -04:00
Lioncash 7b11ce3dd2 Compiler: Use [[maybe_unused]] in the Windows DOLPHIN_UNUSED macro
The required version of MSVC already supports [[maybe_unused]], so we
can utilize this here. When GCC 7 and clang 3.9 become hard
requirements, we can eliminate this macro entirely and replace it with
[[maybe_unused]].
2018-06-09 12:20:29 -04:00
Lioncash d8f6d60189 Compiler: Rename UNUSED macro to DOLPHIN_UNUSED
UNUSED is quite a generic macro name and has potential to clash with
other libraries, so rename it to DOLPHIN_UNUSED to prevent that, as well
as make its naming consistent with the force inline macro
2018-06-09 12:20:29 -04:00
Lioncash 3f210836ad Compiler: Rename __forceinline define to DOLPHIN_FORCE_INLINE
This is much better as prefixed double underscores are reserved for the
implementation when it comes to identifiers. Another reason its better,
is that, on Windows, where __forceinline is a compiler built-in, with
the previous define, header inclusion software that detects unnecessary
includes will erroneously flag usages of Compiler.h as unnecessary
(despite being necessary on other platforms). So we define a macro
that's used by Windows and other platforms to ensure this doesn't
happen.
2018-06-09 12:20:25 -04:00
Lioncash 03414e8e84 Common: Add header for compiler-specifics
Instead of globbing things under an ambiguous Common.h header, move
compiler-specifics over to Compiler.h. This gives us a dedicated home
for anything related to compilers that we want to make functional across
all compilers that we support.

This moves us a little closer to eliminating Common.h entirely.
2018-06-09 12:10:05 -04:00
Lioncash d1e278218e Common/CMakeLists: Link in libraries privately for traversal_server
Without this, CMake script errors can occur, as explicit linkage
specifiers and non-explicit specifier commands aren't compatible with
one another.
2018-06-08 17:40:44 -04:00
Pierre Bourdon de0fe0e210
Merge pull request #6928 from leoetlino/random
Common: Add Random utilities
2018-06-08 00:41:08 +09:00
Léo Lam c93210155f
Merge pull request #7075 from Ebola16/DumpObjects
Software Renderer "Dump Objects" needs dedicated folder and tooltip
2018-06-06 15:20:14 +02:00
Ryan Meredith 45b9b7d211 Give Dump Objects dedicated folder and tooltip 2018-06-06 08:42:41 -04:00
Léo Lam 6ce9c96d91
Merge pull request #7027 from leoetlino/cleanup
Use some C++17 features available since GCC 6
2018-06-04 20:50:50 +02:00
Léo Lam 83324fe77d StringUtil: Remove ValueToString(std::string)
Doesn't make a lot of sense to have a function that gives the string
representation for a string.
2018-06-03 15:11:59 +02:00
Léo Lam 7e79bf97ab IniFile: Use templates for Get()
Gets rid of duplicated code.
2018-06-03 14:53:56 +02:00
Léo Lam cba32b12e7 IniFile: Use templates for Set() 2018-06-03 14:53:56 +02:00
Léo Lam fc0193c4b1 Move Config ValueToString to StringUtil
An identical implementation is used by IniFile, so move those functions
to StringUtil. A future commit will modify IniFile to use them.
2018-06-03 14:10:52 +02:00
Léo Lam fff1db9730 Common: Add Random utilities
This makes it easier to generate random numbers or fill a buffer with
random data in a cryptographically secure way.

This also replaces existing usages of RNG functions in the codebase:

* <random> is pretty hard to use correctly, and std::random_device does
  not give enough guarantees about its results (it's
  implementation-defined, non cryptographically secure and could be
  deterministic on some platforms).
  Doing things correctly is error prone and verbose.

* rand() is terrible and should not be used especially in crypto code.
2018-05-31 17:54:43 +02:00
Lioncash 81e11b2406 x64Emitter: Amend parameter ordering for WriteModRM()'s prototype
The definition of the function uses the ordering {mod, reg, rm}, which
is correct. Match the prototype to this, so that the parameter list
isn't misleading.
2018-05-30 09:30:24 -04:00
Léo Lam 5b90aba624 ChunkFile: Replace macro with a variable template
Note that std::is_trivially_copyable_v cannot be used yet (C++17 only).
2018-05-30 11:39:30 +02:00
Léo Lam 8a00a9e149 Remove old GCC version checks 2018-05-30 10:59:15 +02:00
Markus Wick 4bebd52850
Merge pull request #7017 from lioncash/arm
Arm64Emitter: Use Common::BitCast where applicable
2018-05-30 09:50:59 +02:00
JosJuice 243f353688
Merge pull request #7016 from lioncash/mem
MemoryPatches: Minor changes
2018-05-30 07:45:34 +02:00
Lioncash 6fd7a79b93 Arm64Emitter: Use Common::BitCast where applicable
Gets rid of the need to set up memcpy boilerplate to reinterpret between
floating-point and integers.

While we're at it, also do a minor bit of tidying.
2018-05-29 18:19:01 -04:00
Lioncash 397b27e665 MemoryPatches: In-class initialize is_enabled state for MemoryPatch instances
Given this is what occurs in both constructors (as one just passes
through to another), we can just initialize the member directly.

While we're at it, amend the struct to follow the general ordering
convention of:

<new types>
<functions>
<variables>
2018-05-29 18:04:06 -04:00
Lioncash 4c33bb8dda MemoryPatches: std::move std::vector in the constructor
We can avoid copying the vector contents in this instance.
2018-05-29 18:01:16 -04:00
Lioncash 97c5a840db PcapFile: Namespace code under the Common namespace
Brings more common code under the Common namespace.
2018-05-29 17:56:15 -04:00
spycrab 44784cf363 Common/HttpRequest: Add option to set cookies 2018-05-29 03:56:28 +02:00
Lioncash 4288bfe0f9 Common: Move host communication enum to Host.h
Given this is actually a part of the Host interface, this should be
placed with it.

While we're at it, turn it into an enum class so that we don't dump its
contained values into the surrounding scope. We can also make
Host_Message take the enum type itself directly instead of taking a
general int value.

After this, it'll be trivial to divide out the rest of Common.h and
remove the header from the repository entirely
2018-05-28 14:34:59 -04:00
Markus Wick 40d3163b12
Merge pull request #6998 from lioncash/log
Common: Remove unnecessary ~9 year old LOGGING preprocessor define
2018-05-28 09:33:21 +02:00
Lioncash ee434d4f01 Common: Remove unnecessary ~9 year old LOGGING preprocessor define
This was added in 4bdb4aa0d1 back in
2009-02-27. The only usage spot of this macro involves the same checks
that were used to define that preprocessor macro, so we can simply
remove the macro
2018-05-27 21:33:25 -04:00
Lioncash a745666a60 ColorUtil: Amend function name casing
Makes the function names conform to our coding style.
2018-05-27 21:04:48 -04:00
Lioncash ac474ff1da ColorUtil: Namespace code under the Common namespace
Given this is within Common, it should be in the Common namespace
itself.
2018-05-27 21:00:54 -04:00
Lioncash c056708dc8 CDUtils: Remove unused parameter in IsCDROM()
It was only ever passed nullptr, and even then, nothing was actually
done with the parameter.
2018-05-27 18:48:23 -04:00
Lioncash 470b09fe9d CDUtils: Amend function names
Amends the function names to follow our coding style.
2018-05-27 18:48:09 -04:00
Lioncash 1f75fa0aff CDUtils: Namespace code under the Common namespace 2018-05-27 18:30:58 -04:00
Lioncash f4ec419929 SymbolDB: Namespace code under the Common namespace
Moves more common code into the Common namespace where it belongs.
2018-05-27 18:01:40 -04:00
Lioncash 72e8058fb8 SymbolDB: Default constructor and destructor within the cpp file
Given this is a class with non-trivial data-members, it's preferable to
default the constructor and destructor in the cpp file.
2018-05-27 17:25:22 -04:00
Lioncash a1a81c7bc9 SymbolDB: Convert typedefs into using aliases 2018-05-27 17:23:55 -04:00
Lioncash e9b9797a86 SymbolDB: Normalize variable names
Normalizes variable naming so that it adheres to our coding style

While we're at it do minor cleanup relating to modified lines
2018-05-27 17:23:10 -04:00
Léo Lam bea1e38c67 Move ECCSignature to Common::ec and give it a less confusing name 2018-05-27 14:01:38 +02:00
Lioncash b60ad2425d Common: Namespace GekkoDisassembler.cpp/.h
Moves more common code into the Common namespace where it belongs
2018-05-25 16:55:09 -04:00
Léo Lam 93f49b1ca4 Config: Make Load() and Save() slightly faster
Only invoke config changed callbacks from Config::Save, not
Layer::Save. The latter results in callbacks being called
once per layer, up to 7 times per save.
2018-05-23 16:07:18 +02:00
Sepalani 8fa898fe9a DebugInterface: MemoryPatches methods added
CodeView: Restore instruction added
2018-05-22 10:31:31 +04:00
Léo Lam cec7fded60 IOSC: Implement VerifyPublicKeySign for ECC 2018-05-20 20:04:53 +02:00
Léo Lam 355b1b5d5b ec: Improve readability and clarity
- Move all of the ec functions into the Common::ec namespace.

- Give the public functions better names and some usage information.

- Move all of the "elt" related functions into an "elt" class including
  all of the arithmetic operations, so that the logic becomes clearer
  and feels less like assembly.

  This also makes it much more obvious what the parameters are, instead
  of only using unsigned char* (which doesn't tell anything about what
  the pointer is used for or the size).

- Similarly, add a new "Point" class and move point functions there.
  Overload the arithmetic operators to make calculations easier to read
2018-05-20 19:59:26 +02:00
Léo Lam e83591f188 ec: Avoid exposing internal function 2018-05-20 19:59:26 +02:00