diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/file_util.cpp | 25 | ||||
| -rw-r--r-- | src/common/hash.cpp | 2 | ||||
| -rw-r--r-- | src/common/logging/backend.cpp | 1 | ||||
| -rw-r--r-- | src/common/logging/log.h | 1 | ||||
| -rw-r--r-- | src/common/logging/text_formatter.h | 2 | ||||
| -rw-r--r-- | src/common/swap.h | 7 | ||||
| -rw-r--r-- | src/common/thread.cpp | 12 | ||||
| -rw-r--r-- | src/common/vector_math.h | 3 | ||||
| -rw-r--r-- | src/common/x64/cpu_detect.cpp | 8 |
9 files changed, 33 insertions, 28 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 14cbcac6b..407ed047a 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -23,8 +23,8 @@ | |||
| 23 | #define fseeko _fseeki64 | 23 | #define fseeko _fseeki64 |
| 24 | #define ftello _ftelli64 | 24 | #define ftello _ftelli64 |
| 25 | #define atoll _atoi64 | 25 | #define atoll _atoi64 |
| 26 | #define stat64 _stat64 | 26 | #define stat _stat64 |
| 27 | #define fstat64 _fstat64 | 27 | #define fstat _fstat64 |
| 28 | #define fileno _fileno | 28 | #define fileno _fileno |
| 29 | #else | 29 | #else |
| 30 | #ifdef __APPLE__ | 30 | #ifdef __APPLE__ |
| @@ -52,11 +52,6 @@ | |||
| 52 | #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) | 52 | #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) |
| 53 | #endif | 53 | #endif |
| 54 | 54 | ||
| 55 | #ifdef BSD4_4 | ||
| 56 | #define stat64 stat | ||
| 57 | #define fstat64 fstat | ||
| 58 | #endif | ||
| 59 | |||
| 60 | // This namespace has various generic functions related to files and paths. | 55 | // This namespace has various generic functions related to files and paths. |
| 61 | // The code still needs a ton of cleanup. | 56 | // The code still needs a ton of cleanup. |
| 62 | // REMEMBER: strdup considered harmful! | 57 | // REMEMBER: strdup considered harmful! |
| @@ -76,7 +71,7 @@ static void StripTailDirSlashes(std::string& fname) { | |||
| 76 | 71 | ||
| 77 | // Returns true if file filename exists | 72 | // Returns true if file filename exists |
| 78 | bool Exists(const std::string& filename) { | 73 | bool Exists(const std::string& filename) { |
| 79 | struct stat64 file_info; | 74 | struct stat file_info; |
| 80 | 75 | ||
| 81 | std::string copy(filename); | 76 | std::string copy(filename); |
| 82 | StripTailDirSlashes(copy); | 77 | StripTailDirSlashes(copy); |
| @@ -88,7 +83,7 @@ bool Exists(const std::string& filename) { | |||
| 88 | 83 | ||
| 89 | int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); | 84 | int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); |
| 90 | #else | 85 | #else |
| 91 | int result = stat64(copy.c_str(), &file_info); | 86 | int result = stat(copy.c_str(), &file_info); |
| 92 | #endif | 87 | #endif |
| 93 | 88 | ||
| 94 | return (result == 0); | 89 | return (result == 0); |
| @@ -96,7 +91,7 @@ bool Exists(const std::string& filename) { | |||
| 96 | 91 | ||
| 97 | // Returns true if filename is a directory | 92 | // Returns true if filename is a directory |
| 98 | bool IsDirectory(const std::string& filename) { | 93 | bool IsDirectory(const std::string& filename) { |
| 99 | struct stat64 file_info; | 94 | struct stat file_info; |
| 100 | 95 | ||
| 101 | std::string copy(filename); | 96 | std::string copy(filename); |
| 102 | StripTailDirSlashes(copy); | 97 | StripTailDirSlashes(copy); |
| @@ -108,7 +103,7 @@ bool IsDirectory(const std::string& filename) { | |||
| 108 | 103 | ||
| 109 | int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); | 104 | int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); |
| 110 | #else | 105 | #else |
| 111 | int result = stat64(copy.c_str(), &file_info); | 106 | int result = stat(copy.c_str(), &file_info); |
| 112 | #endif | 107 | #endif |
| 113 | 108 | ||
| 114 | if (result < 0) { | 109 | if (result < 0) { |
| @@ -339,11 +334,11 @@ u64 GetSize(const std::string& filename) { | |||
| 339 | return 0; | 334 | return 0; |
| 340 | } | 335 | } |
| 341 | 336 | ||
| 342 | struct stat64 buf; | 337 | struct stat buf; |
| 343 | #ifdef _WIN32 | 338 | #ifdef _WIN32 |
| 344 | if (_wstat64(Common::UTF8ToUTF16W(filename).c_str(), &buf) == 0) | 339 | if (_wstat64(Common::UTF8ToUTF16W(filename).c_str(), &buf) == 0) |
| 345 | #else | 340 | #else |
| 346 | if (stat64(filename.c_str(), &buf) == 0) | 341 | if (stat(filename.c_str(), &buf) == 0) |
| 347 | #endif | 342 | #endif |
| 348 | { | 343 | { |
| 349 | LOG_TRACE(Common_Filesystem, "%s: %lld", filename.c_str(), (long long)buf.st_size); | 344 | LOG_TRACE(Common_Filesystem, "%s: %lld", filename.c_str(), (long long)buf.st_size); |
| @@ -356,8 +351,8 @@ u64 GetSize(const std::string& filename) { | |||
| 356 | 351 | ||
| 357 | // Overloaded GetSize, accepts file descriptor | 352 | // Overloaded GetSize, accepts file descriptor |
| 358 | u64 GetSize(const int fd) { | 353 | u64 GetSize(const int fd) { |
| 359 | struct stat64 buf; | 354 | struct stat buf; |
| 360 | if (fstat64(fd, &buf) != 0) { | 355 | if (fstat(fd, &buf) != 0) { |
| 361 | LOG_ERROR(Common_Filesystem, "GetSize: stat failed %i: %s", fd, GetLastErrorMsg()); | 356 | LOG_ERROR(Common_Filesystem, "GetSize: stat failed %i: %s", fd, GetLastErrorMsg()); |
| 362 | return 0; | 357 | return 0; |
| 363 | } | 358 | } |
diff --git a/src/common/hash.cpp b/src/common/hash.cpp index 5aa5118eb..2309320bb 100644 --- a/src/common/hash.cpp +++ b/src/common/hash.cpp | |||
| @@ -31,7 +31,7 @@ static FORCE_INLINE u64 fmix64(u64 k) { | |||
| 31 | return k; | 31 | return k; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | // This is the 128-bit variant of the MurmurHash3 hash function that is targetted for 64-bit | 34 | // This is the 128-bit variant of the MurmurHash3 hash function that is targeted for 64-bit |
| 35 | // platforms (MurmurHash3_x64_128). It was taken from: | 35 | // platforms (MurmurHash3_x64_128). It was taken from: |
| 36 | // https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp | 36 | // https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp |
| 37 | void MurmurHash3_128(const void* key, int len, u32 seed, void* out) { | 37 | void MurmurHash3_128(const void* key, int len, u32 seed, void* out) { |
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 9a13a9e90..88209081d 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -37,6 +37,7 @@ namespace Log { | |||
| 37 | SUB(Service, FS) \ | 37 | SUB(Service, FS) \ |
| 38 | SUB(Service, ERR) \ | 38 | SUB(Service, ERR) \ |
| 39 | SUB(Service, APT) \ | 39 | SUB(Service, APT) \ |
| 40 | SUB(Service, BOSS) \ | ||
| 40 | SUB(Service, GSP) \ | 41 | SUB(Service, GSP) \ |
| 41 | SUB(Service, AC) \ | 42 | SUB(Service, AC) \ |
| 42 | SUB(Service, AM) \ | 43 | SUB(Service, AM) \ |
diff --git a/src/common/logging/log.h b/src/common/logging/log.h index a4b4750de..8d3a2d03e 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h | |||
| @@ -54,6 +54,7 @@ enum class Class : ClassType { | |||
| 54 | Service_FS, ///< The FS (Filesystem) service implementation | 54 | Service_FS, ///< The FS (Filesystem) service implementation |
| 55 | Service_ERR, ///< The ERR (Error) port implementation | 55 | Service_ERR, ///< The ERR (Error) port implementation |
| 56 | Service_APT, ///< The APT (Applets) service | 56 | Service_APT, ///< The APT (Applets) service |
| 57 | Service_BOSS, ///< The BOSS (SpotPass) service | ||
| 57 | Service_GSP, ///< The GSP (GPU control) service | 58 | Service_GSP, ///< The GSP (GPU control) service |
| 58 | Service_AC, ///< The AC (WiFi status) service | 59 | Service_AC, ///< The AC (WiFi status) service |
| 59 | Service_AM, ///< The AM (Application manager) service | 60 | Service_AM, ///< The AM (Application manager) service |
diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h index 0da102bc6..749268310 100644 --- a/src/common/logging/text_formatter.h +++ b/src/common/logging/text_formatter.h | |||
| @@ -17,7 +17,7 @@ struct Entry; | |||
| 17 | * | 17 | * |
| 18 | * @param path The input file path as a null-terminated string | 18 | * @param path The input file path as a null-terminated string |
| 19 | * @param root The name of the root source directory as a null-terminated string. Path up to and | 19 | * @param root The name of the root source directory as a null-terminated string. Path up to and |
| 20 | * including the last occurence of this name will be stripped | 20 | * including the last occurrence of this name will be stripped |
| 21 | * @return A pointer to the same string passed as `path`, but starting at the trimmed portion | 21 | * @return A pointer to the same string passed as `path`, but starting at the trimmed portion |
| 22 | */ | 22 | */ |
| 23 | const char* TrimSourcePath(const char* path, const char* root = "src"); | 23 | const char* TrimSourcePath(const char* path, const char* root = "src"); |
diff --git a/src/common/swap.h b/src/common/swap.h index e241c9f73..d94cbe6b2 100644 --- a/src/common/swap.h +++ b/src/common/swap.h | |||
| @@ -21,7 +21,8 @@ | |||
| 21 | #include <cstdlib> | 21 | #include <cstdlib> |
| 22 | #elif defined(__linux__) | 22 | #elif defined(__linux__) |
| 23 | #include <byteswap.h> | 23 | #include <byteswap.h> |
| 24 | #elif defined(__FreeBSD__) | 24 | #elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ |
| 25 | defined(__NetBSD__) || defined(__OpenBSD__) | ||
| 25 | #include <sys/endian.h> | 26 | #include <sys/endian.h> |
| 26 | #endif | 27 | #endif |
| 27 | #include <cstring> | 28 | #include <cstring> |
| @@ -101,7 +102,9 @@ inline __attribute__((always_inline)) u32 swap32(u32 _data) { | |||
| 101 | inline __attribute__((always_inline)) u64 swap64(u64 _data) { | 102 | inline __attribute__((always_inline)) u64 swap64(u64 _data) { |
| 102 | return __builtin_bswap64(_data); | 103 | return __builtin_bswap64(_data); |
| 103 | } | 104 | } |
| 104 | #elif __FreeBSD__ | 105 | #elif defined(__Bitrig__) || defined(__OpenBSD__) |
| 106 | // swap16, swap32, swap64 are left as is | ||
| 107 | #elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) | ||
| 105 | inline u16 swap16(u16 _data) { | 108 | inline u16 swap16(u16 _data) { |
| 106 | return bswap16(_data); | 109 | return bswap16(_data); |
| 107 | } | 110 | } |
diff --git a/src/common/thread.cpp b/src/common/thread.cpp index 6e7b39b9a..9bb2f4e1d 100644 --- a/src/common/thread.cpp +++ b/src/common/thread.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #elif defined(_WIN32) | 8 | #elif defined(_WIN32) |
| 9 | #include <Windows.h> | 9 | #include <Windows.h> |
| 10 | #else | 10 | #else |
| 11 | #if defined(BSD4_4) || defined(__OpenBSD__) | 11 | #if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
| 12 | #include <pthread_np.h> | 12 | #include <pthread_np.h> |
| 13 | #else | 13 | #else |
| 14 | #include <pthread.h> | 14 | #include <pthread.h> |
| @@ -19,6 +19,10 @@ | |||
| 19 | #include <unistd.h> | 19 | #include <unistd.h> |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | #ifdef __FreeBSD__ | ||
| 23 | #define cpu_set_t cpuset_t | ||
| 24 | #endif | ||
| 25 | |||
| 22 | namespace Common { | 26 | namespace Common { |
| 23 | 27 | ||
| 24 | int CurrentThreadId() { | 28 | int CurrentThreadId() { |
| @@ -86,7 +90,7 @@ void SetCurrentThreadName(const char* szThreadName) { | |||
| 86 | void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { | 90 | void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { |
| 87 | #ifdef __APPLE__ | 91 | #ifdef __APPLE__ |
| 88 | thread_policy_set(pthread_mach_thread_np(thread), THREAD_AFFINITY_POLICY, (integer_t*)&mask, 1); | 92 | thread_policy_set(pthread_mach_thread_np(thread), THREAD_AFFINITY_POLICY, (integer_t*)&mask, 1); |
| 89 | #elif (defined __linux__ || defined BSD4_4) && !(defined ANDROID) | 93 | #elif (defined __linux__ || defined __FreeBSD__) && !(defined ANDROID) |
| 90 | cpu_set_t cpu_set; | 94 | cpu_set_t cpu_set; |
| 91 | CPU_ZERO(&cpu_set); | 95 | CPU_ZERO(&cpu_set); |
| 92 | 96 | ||
| @@ -117,8 +121,10 @@ void SwitchCurrentThread() { | |||
| 117 | void SetCurrentThreadName(const char* szThreadName) { | 121 | void SetCurrentThreadName(const char* szThreadName) { |
| 118 | #ifdef __APPLE__ | 122 | #ifdef __APPLE__ |
| 119 | pthread_setname_np(szThreadName); | 123 | pthread_setname_np(szThreadName); |
| 120 | #elif defined(__OpenBSD__) | 124 | #elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) |
| 121 | pthread_set_name_np(pthread_self(), szThreadName); | 125 | pthread_set_name_np(pthread_self(), szThreadName); |
| 126 | #elif defined(__NetBSD__) | ||
| 127 | pthread_setname_np(pthread_self(), "%s", (void*)szThreadName); | ||
| 122 | #else | 128 | #else |
| 123 | pthread_setname_np(pthread_self(), szThreadName); | 129 | pthread_setname_np(pthread_self(), szThreadName); |
| 124 | #endif | 130 | #endif |
diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 2d56f168c..a57d86d88 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h | |||
| @@ -60,7 +60,6 @@ public: | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | Vec2() = default; | 62 | Vec2() = default; |
| 63 | Vec2(const T a[2]) : x(a[0]), y(a[1]) {} | ||
| 64 | Vec2(const T& _x, const T& _y) : x(_x), y(_y) {} | 63 | Vec2(const T& _x, const T& _y) : x(_x), y(_y) {} |
| 65 | 64 | ||
| 66 | template <typename T2> | 65 | template <typename T2> |
| @@ -199,7 +198,6 @@ public: | |||
| 199 | } | 198 | } |
| 200 | 199 | ||
| 201 | Vec3() = default; | 200 | Vec3() = default; |
| 202 | Vec3(const T a[3]) : x(a[0]), y(a[1]), z(a[2]) {} | ||
| 203 | Vec3(const T& _x, const T& _y, const T& _z) : x(_x), y(_y), z(_z) {} | 201 | Vec3(const T& _x, const T& _y, const T& _z) : x(_x), y(_y), z(_z) {} |
| 204 | 202 | ||
| 205 | template <typename T2> | 203 | template <typename T2> |
| @@ -405,7 +403,6 @@ public: | |||
| 405 | } | 403 | } |
| 406 | 404 | ||
| 407 | Vec4() = default; | 405 | Vec4() = default; |
| 408 | Vec4(const T a[4]) : x(a[0]), y(a[1]), z(a[2]), w(a[3]) {} | ||
| 409 | Vec4(const T& _x, const T& _y, const T& _z, const T& _w) : x(_x), y(_y), z(_z), w(_w) {} | 406 | Vec4(const T& _x, const T& _y, const T& _z, const T& _w) : x(_x), y(_y), z(_z), w(_w) {} |
| 410 | 407 | ||
| 411 | template <typename T2> | 408 | template <typename T2> |
diff --git a/src/common/x64/cpu_detect.cpp b/src/common/x64/cpu_detect.cpp index 6ddf9b70c..370ae2c80 100644 --- a/src/common/x64/cpu_detect.cpp +++ b/src/common/x64/cpu_detect.cpp | |||
| @@ -12,13 +12,15 @@ namespace Common { | |||
| 12 | 12 | ||
| 13 | #ifndef _MSC_VER | 13 | #ifndef _MSC_VER |
| 14 | 14 | ||
| 15 | #ifdef __FreeBSD__ | 15 | #if defined(__DragonFly__) || defined(__FreeBSD__) |
| 16 | #include <machine/cpufunc.h> | 16 | // clang-format off |
| 17 | #include <sys/types.h> | 17 | #include <sys/types.h> |
| 18 | #include <machine/cpufunc.h> | ||
| 19 | // clang-format on | ||
| 18 | #endif | 20 | #endif |
| 19 | 21 | ||
| 20 | static inline void __cpuidex(int info[4], int function_id, int subfunction_id) { | 22 | static inline void __cpuidex(int info[4], int function_id, int subfunction_id) { |
| 21 | #ifdef __FreeBSD__ | 23 | #if defined(__DragonFly__) || defined(__FreeBSD__) |
| 22 | // Despite the name, this is just do_cpuid() with ECX as second input. | 24 | // Despite the name, this is just do_cpuid() with ECX as second input. |
| 23 | cpuid_count((u_int)function_id, (u_int)subfunction_id, (u_int*)info); | 25 | cpuid_count((u_int)function_id, (u_int)subfunction_id, (u_int*)info); |
| 24 | #else | 26 | #else |