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 @@ #define fseeko _fseeki64 #define ftello _ftelli64 #define atoll _atoi64 -#define stat64 _stat64 -#define fstat64 _fstat64 +#define stat _stat64 +#define fstat _fstat64 #define fileno _fileno #else #ifdef __APPLE__ @@ -52,11 +52,6 @@ #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) #endif -#ifdef BSD4_4 -#define stat64 stat -#define fstat64 fstat -#endif - // This namespace has various generic functions related to files and paths. // The code still needs a ton of cleanup. // REMEMBER: strdup considered harmful! @@ -76,7 +71,7 @@ static void StripTailDirSlashes(std::string& fname) { // Returns true if file filename exists bool Exists(const std::string& filename) { - struct stat64 file_info; + struct stat file_info; std::string copy(filename); StripTailDirSlashes(copy); @@ -88,7 +83,7 @@ bool Exists(const std::string& filename) { int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); #else - int result = stat64(copy.c_str(), &file_info); + int result = stat(copy.c_str(), &file_info); #endif return (result == 0); @@ -96,7 +91,7 @@ bool Exists(const std::string& filename) { // Returns true if filename is a directory bool IsDirectory(const std::string& filename) { - struct stat64 file_info; + struct stat file_info; std::string copy(filename); StripTailDirSlashes(copy); @@ -108,7 +103,7 @@ bool IsDirectory(const std::string& filename) { int result = _wstat64(Common::UTF8ToUTF16W(copy).c_str(), &file_info); #else - int result = stat64(copy.c_str(), &file_info); + int result = stat(copy.c_str(), &file_info); #endif if (result < 0) { @@ -339,11 +334,11 @@ u64 GetSize(const std::string& filename) { return 0; } - struct stat64 buf; + struct stat buf; #ifdef _WIN32 if (_wstat64(Common::UTF8ToUTF16W(filename).c_str(), &buf) == 0) #else - if (stat64(filename.c_str(), &buf) == 0) + if (stat(filename.c_str(), &buf) == 0) #endif { LOG_TRACE(Common_Filesystem, "%s: %lld", filename.c_str(), (long long)buf.st_size); @@ -356,8 +351,8 @@ u64 GetSize(const std::string& filename) { // Overloaded GetSize, accepts file descriptor u64 GetSize(const int fd) { - struct stat64 buf; - if (fstat64(fd, &buf) != 0) { + struct stat buf; + if (fstat(fd, &buf) != 0) { LOG_ERROR(Common_Filesystem, "GetSize: stat failed %i: %s", fd, GetLastErrorMsg()); return 0; } 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) { return k; } -// This is the 128-bit variant of the MurmurHash3 hash function that is targetted for 64-bit +// This is the 128-bit variant of the MurmurHash3 hash function that is targeted for 64-bit // platforms (MurmurHash3_x64_128). It was taken from: // https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp 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 { SUB(Service, FS) \ SUB(Service, ERR) \ SUB(Service, APT) \ + SUB(Service, BOSS) \ SUB(Service, GSP) \ SUB(Service, AC) \ 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 { Service_FS, ///< The FS (Filesystem) service implementation Service_ERR, ///< The ERR (Error) port implementation Service_APT, ///< The APT (Applets) service + Service_BOSS, ///< The BOSS (SpotPass) service Service_GSP, ///< The GSP (GPU control) service Service_AC, ///< The AC (WiFi status) service 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; * * @param path The input file path as a null-terminated string * @param root The name of the root source directory as a null-terminated string. Path up to and - * including the last occurence of this name will be stripped + * including the last occurrence of this name will be stripped * @return A pointer to the same string passed as `path`, but starting at the trimmed portion */ 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 @@ #include <cstdlib> #elif defined(__linux__) #include <byteswap.h> -#elif defined(__FreeBSD__) +#elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) #include <sys/endian.h> #endif #include <cstring> @@ -101,7 +102,9 @@ inline __attribute__((always_inline)) u32 swap32(u32 _data) { inline __attribute__((always_inline)) u64 swap64(u64 _data) { return __builtin_bswap64(_data); } -#elif __FreeBSD__ +#elif defined(__Bitrig__) || defined(__OpenBSD__) +// swap16, swap32, swap64 are left as is +#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) inline u16 swap16(u16 _data) { return bswap16(_data); } 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 @@ #elif defined(_WIN32) #include <Windows.h> #else -#if defined(BSD4_4) || defined(__OpenBSD__) +#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) #include <pthread_np.h> #else #include <pthread.h> @@ -19,6 +19,10 @@ #include <unistd.h> #endif +#ifdef __FreeBSD__ +#define cpu_set_t cpuset_t +#endif + namespace Common { int CurrentThreadId() { @@ -86,7 +90,7 @@ void SetCurrentThreadName(const char* szThreadName) { void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) { #ifdef __APPLE__ thread_policy_set(pthread_mach_thread_np(thread), THREAD_AFFINITY_POLICY, (integer_t*)&mask, 1); -#elif (defined __linux__ || defined BSD4_4) && !(defined ANDROID) +#elif (defined __linux__ || defined __FreeBSD__) && !(defined ANDROID) cpu_set_t cpu_set; CPU_ZERO(&cpu_set); @@ -117,8 +121,10 @@ void SwitchCurrentThread() { void SetCurrentThreadName(const char* szThreadName) { #ifdef __APPLE__ pthread_setname_np(szThreadName); -#elif defined(__OpenBSD__) +#elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) pthread_set_name_np(pthread_self(), szThreadName); +#elif defined(__NetBSD__) + pthread_setname_np(pthread_self(), "%s", (void*)szThreadName); #else pthread_setname_np(pthread_self(), szThreadName); #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: } Vec2() = default; - Vec2(const T a[2]) : x(a[0]), y(a[1]) {} Vec2(const T& _x, const T& _y) : x(_x), y(_y) {} template <typename T2> @@ -199,7 +198,6 @@ public: } Vec3() = default; - Vec3(const T a[3]) : x(a[0]), y(a[1]), z(a[2]) {} Vec3(const T& _x, const T& _y, const T& _z) : x(_x), y(_y), z(_z) {} template <typename T2> @@ -405,7 +403,6 @@ public: } Vec4() = default; - Vec4(const T a[4]) : x(a[0]), y(a[1]), z(a[2]), w(a[3]) {} Vec4(const T& _x, const T& _y, const T& _z, const T& _w) : x(_x), y(_y), z(_z), w(_w) {} 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 { #ifndef _MSC_VER -#ifdef __FreeBSD__ -#include <machine/cpufunc.h> +#if defined(__DragonFly__) || defined(__FreeBSD__) +// clang-format off #include <sys/types.h> +#include <machine/cpufunc.h> +// clang-format on #endif static inline void __cpuidex(int info[4], int function_id, int subfunction_id) { -#ifdef __FreeBSD__ +#if defined(__DragonFly__) || defined(__FreeBSD__) // Despite the name, this is just do_cpuid() with ECX as second input. cpuid_count((u_int)function_id, (u_int)subfunction_id, (u_int*)info); #else |