diff options
| -rw-r--r-- | src/common/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/common/common_funcs.h | 11 | ||||
| -rw-r--r-- | src/common/error.cpp (renamed from src/common/misc.cpp) | 6 | ||||
| -rw-r--r-- | src/common/error.h | 21 | ||||
| -rw-r--r-- | src/common/thread.cpp | 6 | ||||
| -rw-r--r-- | src/core/network/network.cpp | 5 |
6 files changed, 34 insertions, 18 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 57922b51c..b18a2a2f5 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -53,6 +53,8 @@ add_library(common STATIC | |||
| 53 | div_ceil.h | 53 | div_ceil.h |
| 54 | dynamic_library.cpp | 54 | dynamic_library.cpp |
| 55 | dynamic_library.h | 55 | dynamic_library.h |
| 56 | error.cpp | ||
| 57 | error.h | ||
| 56 | fiber.cpp | 58 | fiber.cpp |
| 57 | fiber.h | 59 | fiber.h |
| 58 | fs/file.cpp | 60 | fs/file.cpp |
| @@ -88,7 +90,6 @@ add_library(common STATIC | |||
| 88 | microprofile.cpp | 90 | microprofile.cpp |
| 89 | microprofile.h | 91 | microprofile.h |
| 90 | microprofileui.h | 92 | microprofileui.h |
| 91 | misc.cpp | ||
| 92 | nvidia_flags.cpp | 93 | nvidia_flags.cpp |
| 93 | nvidia_flags.h | 94 | nvidia_flags.h |
| 94 | page_table.cpp | 95 | page_table.cpp |
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 53bd7da60..85f8bdd22 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include <algorithm> | 7 | #include <algorithm> |
| 8 | #include <array> | 8 | #include <array> |
| 9 | #include <string> | ||
| 10 | 9 | ||
| 11 | #if !defined(ARCHITECTURE_x86_64) | 10 | #if !defined(ARCHITECTURE_x86_64) |
| 12 | #include <cstdlib> // for exit | 11 | #include <cstdlib> // for exit |
| @@ -49,16 +48,6 @@ __declspec(dllimport) void __stdcall DebugBreak(void); | |||
| 49 | 48 | ||
| 50 | #endif // _MSC_VER ndef | 49 | #endif // _MSC_VER ndef |
| 51 | 50 | ||
| 52 | // Generic function to get last error message. | ||
| 53 | // Call directly after the command or use the error num. | ||
| 54 | // This function might change the error code. | ||
| 55 | // Defined in misc.cpp. | ||
| 56 | [[nodiscard]] std::string GetLastErrorMsg(); | ||
| 57 | |||
| 58 | // Like GetLastErrorMsg(), but passing an explicit error code. | ||
| 59 | // Defined in misc.cpp. | ||
| 60 | [[nodiscard]] std::string NativeErrorToString(int e); | ||
| 61 | |||
| 62 | #define DECLARE_ENUM_FLAG_OPERATORS(type) \ | 51 | #define DECLARE_ENUM_FLAG_OPERATORS(type) \ |
| 63 | [[nodiscard]] constexpr type operator|(type a, type b) noexcept { \ | 52 | [[nodiscard]] constexpr type operator|(type a, type b) noexcept { \ |
| 64 | using T = std::underlying_type_t<type>; \ | 53 | using T = std::underlying_type_t<type>; \ |
diff --git a/src/common/misc.cpp b/src/common/error.cpp index 495385b9e..d4455e310 100644 --- a/src/common/misc.cpp +++ b/src/common/error.cpp | |||
| @@ -10,7 +10,9 @@ | |||
| 10 | #include <cstring> | 10 | #include <cstring> |
| 11 | #endif | 11 | #endif |
| 12 | 12 | ||
| 13 | #include "common/common_funcs.h" | 13 | #include "common/error.h" |
| 14 | |||
| 15 | namespace Common { | ||
| 14 | 16 | ||
| 15 | std::string NativeErrorToString(int e) { | 17 | std::string NativeErrorToString(int e) { |
| 16 | #ifdef _WIN32 | 18 | #ifdef _WIN32 |
| @@ -50,3 +52,5 @@ std::string GetLastErrorMsg() { | |||
| 50 | return NativeErrorToString(errno); | 52 | return NativeErrorToString(errno); |
| 51 | #endif | 53 | #endif |
| 52 | } | 54 | } |
| 55 | |||
| 56 | } // namespace Common | ||
diff --git a/src/common/error.h b/src/common/error.h new file mode 100644 index 000000000..e084d4b0f --- /dev/null +++ b/src/common/error.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | |||
| 9 | namespace Common { | ||
| 10 | |||
| 11 | // Generic function to get last error message. | ||
| 12 | // Call directly after the command or use the error num. | ||
| 13 | // This function might change the error code. | ||
| 14 | // Defined in error.cpp. | ||
| 15 | [[nodiscard]] std::string GetLastErrorMsg(); | ||
| 16 | |||
| 17 | // Like GetLastErrorMsg(), but passing an explicit error code. | ||
| 18 | // Defined in error.cpp. | ||
| 19 | [[nodiscard]] std::string NativeErrorToString(int e); | ||
| 20 | |||
| 21 | } // namespace Common | ||
diff --git a/src/common/thread.cpp b/src/common/thread.cpp index d2c1ac60d..946a1114d 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp | |||
| @@ -2,7 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/common_funcs.h" | 5 | #include <string> |
| 6 | |||
| 7 | #include "common/error.h" | ||
| 6 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 7 | #include "common/thread.h" | 9 | #include "common/thread.h" |
| 8 | #ifdef __APPLE__ | 10 | #ifdef __APPLE__ |
| @@ -21,8 +23,6 @@ | |||
| 21 | #include <unistd.h> | 23 | #include <unistd.h> |
| 22 | #endif | 24 | #endif |
| 23 | 25 | ||
| 24 | #include <string> | ||
| 25 | |||
| 26 | #ifdef __FreeBSD__ | 26 | #ifdef __FreeBSD__ |
| 27 | #define cpu_set_t cpuset_t | 27 | #define cpu_set_t cpuset_t |
| 28 | #endif | 28 | #endif |
diff --git a/src/core/network/network.cpp b/src/core/network/network.cpp index 4732d4485..72eea52f0 100644 --- a/src/core/network/network.cpp +++ b/src/core/network/network.cpp | |||
| @@ -7,7 +7,8 @@ | |||
| 7 | #include <limits> | 7 | #include <limits> |
| 8 | #include <utility> | 8 | #include <utility> |
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | #include "common/common_funcs.h" | 10 | |
| 11 | #include "common/error.h" | ||
| 11 | 12 | ||
| 12 | #ifdef _WIN32 | 13 | #ifdef _WIN32 |
| 13 | #include <winsock2.h> | 14 | #include <winsock2.h> |
| @@ -223,7 +224,7 @@ Errno GetAndLogLastError() { | |||
| 223 | if (err == Errno::AGAIN) { | 224 | if (err == Errno::AGAIN) { |
| 224 | return err; | 225 | return err; |
| 225 | } | 226 | } |
| 226 | LOG_ERROR(Network, "Socket operation error: {}", NativeErrorToString(e)); | 227 | LOG_ERROR(Network, "Socket operation error: {}", Common::NativeErrorToString(e)); |
| 227 | return err; | 228 | return err; |
| 228 | } | 229 | } |
| 229 | 230 | ||