From b6d67560e39ca3c7154d97355fec988210a460e5 Mon Sep 17 00:00:00 2001 From: Ganael Laplanche Date: Wed, 29 Nov 2023 20:38:56 +0100 Subject: [PATCH 1/3] Fix data directory handling on FreeBSD --- src/duckstation-nogui/nogui_host.cpp | 2 +- src/duckstation-qt/qthost.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/duckstation-nogui/nogui_host.cpp b/src/duckstation-nogui/nogui_host.cpp index 5543c2c99..8e2778ed1 100644 --- a/src/duckstation-nogui/nogui_host.cpp +++ b/src/duckstation-nogui/nogui_host.cpp @@ -185,7 +185,7 @@ void NoGUIHost::SetDataDirectory() EmuFolders::DataRoot = Path::Combine(StringUtil::WideStringToUTF8String(documents_directory), "DuckStation"); CoTaskMemFree(documents_directory); } -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) // Use $XDG_CONFIG_HOME/duckstation if it exists. const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); if (xdg_config_home && Path::IsAbsolute(xdg_config_home)) diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index a2039160d..b7977cb60 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -290,7 +290,7 @@ void QtHost::SetDataDirectory() EmuFolders::DataRoot = Path::Combine(StringUtil::WideStringToUTF8String(documents_directory), "DuckStation"); CoTaskMemFree(documents_directory); } -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) // Use $XDG_CONFIG_HOME/duckstation if it exists. const char* xdg_config_home = getenv("XDG_CONFIG_HOME"); if (xdg_config_home && Path::IsAbsolute(xdg_config_home)) From af046c8987ec3c580eff8a0c7c438762377fdbca Mon Sep 17 00:00:00 2001 From: Ganael Laplanche Date: Wed, 29 Nov 2023 20:54:12 +0100 Subject: [PATCH 2/3] Fix build on FreeBSD FreeBSD's alloca(3) only needs --- src/common/byte_stream.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/byte_stream.cpp b/src/common/byte_stream.cpp index bb26af0fd..186099960 100644 --- a/src/common/byte_stream.cpp +++ b/src/common/byte_stream.cpp @@ -28,8 +28,10 @@ #ifdef _MSC_VER #include #else +#if !defined(__FreeBSD__) #include #endif +#endif Log_SetChannel(ByteStream); From 5486a7a467dc0cd502bd8c4e7eb7a3c95a5a3c02 Mon Sep 17 00:00:00 2001 From: Ganael Laplanche Date: Wed, 29 Nov 2023 21:05:21 +0100 Subject: [PATCH 3/3] Fix get_thread_time() declaration on FreeBSD --- src/common/threading.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/threading.cpp b/src/common/threading.cpp index ac272ff1c..8dacce838 100644 --- a/src/common/threading.cpp +++ b/src/common/threading.cpp @@ -64,7 +64,7 @@ static u64 getthreadtime(thread_port_t thread) } #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__FreeBSD__) // Helper function to get either either the current cpu usage // in called thread or in id thread static u64 get_thread_time(void* id = 0) @@ -227,7 +227,7 @@ u64 Threading::ThreadHandle::GetCPUTime() const return user.u64time + kernel.u64time; #elif defined(__APPLE__) return getthreadtime(pthread_mach_thread_np((pthread_t)m_native_handle)); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) return get_thread_time(m_native_handle); #else return 0;