diff --git a/Source/Core/Common/MemoryUtil.cpp b/Source/Core/Common/MemoryUtil.cpp index aa284ab091..1941f8e35b 100644 --- a/Source/Core/Common/MemoryUtil.cpp +++ b/Source/Core/Common/MemoryUtil.cpp @@ -20,7 +20,7 @@ #include #include #include -#if defined __APPLE__ || defined __FreeBSD__ +#if defined __APPLE__ || defined __FreeBSD__ || defined __OpenBSD__ #include #else #include @@ -253,7 +253,7 @@ size_t MemPhysical() memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); return memInfo.ullTotalPhys; -#elif defined __APPLE__ || defined __FreeBSD__ +#elif defined __APPLE__ || defined __FreeBSD__ || defined __OpenBSD__ int mib[2]; size_t physical_memory; mib[0] = CTL_HW; @@ -261,6 +261,8 @@ size_t MemPhysical() mib[1] = HW_MEMSIZE; #elif defined __FreeBSD__ mib[1] = HW_REALMEM; +#elif defined __OpenBSD__ + mib[1] = HW_PHYSMEM; #endif size_t length = sizeof(size_t); sysctl(mib, 2, &physical_memory, &length, NULL, 0); diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index ff6c6074cf..5048446682 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -28,7 +28,7 @@ #include #endif -#if !defined(_WIN32) && !defined(ANDROID) +#if !defined(_WIN32) && !defined(ANDROID) && !defined(__OpenBSD__) static locale_t GetCLocale() { static locale_t c_locale = newlocale(LC_ALL_MASK, "C", nullptr); @@ -121,11 +121,11 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar c_locale = _create_locale(LC_ALL, "C"); writtenCount = _vsnprintf_l(out, outsize, format, c_locale, args); #else -#if !defined(ANDROID) +#if !defined(ANDROID) && !defined(__OpenBSD__) locale_t previousLocale = uselocale(GetCLocale()); #endif writtenCount = vsnprintf(out, outsize, format, args); -#if !defined(ANDROID) +#if !defined(ANDROID) && !defined(__OpenBSD__) uselocale(previousLocale); #endif #endif @@ -162,12 +162,12 @@ std::string StringFromFormatV(const char* format, va_list args) std::string temp = buf; delete[] buf; #else -#if !defined(ANDROID) +#if !defined(ANDROID) && !defined(__OpenBSD__) locale_t previousLocale = uselocale(GetCLocale()); #endif if (vasprintf(&buf, format, args) < 0) ERROR_LOG(COMMON, "Unable to allocate memory for string"); -#if !defined(ANDROID) +#if !defined(ANDROID) && !defined(__OpenBSD__) uselocale(previousLocale); #endif diff --git a/Source/Core/Common/Thread.cpp b/Source/Core/Common/Thread.cpp index 557cbfbef2..a03b9c2e57 100644 --- a/Source/Core/Common/Thread.cpp +++ b/Source/Core/Common/Thread.cpp @@ -12,7 +12,7 @@ #ifdef __APPLE__ #include -#elif defined BSD4_4 || defined __FreeBSD__ +#elif defined BSD4_4 || defined __FreeBSD__ || defined __OpenBSD__ #include #endif @@ -132,7 +132,7 @@ void SetCurrentThreadName(const char* szThreadName) { #ifdef __APPLE__ pthread_setname_np(szThreadName); -#elif defined __FreeBSD__ +#elif defined __FreeBSD__ || defined __OpenBSD__ pthread_set_name_np(pthread_self(), szThreadName); #else // linux doesn't allow to set more than 16 bytes, including \0. diff --git a/Source/Core/Core/HW/EXI_DeviceEthernet.h b/Source/Core/Core/HW/EXI_DeviceEthernet.h index 28b1aff389..26f0e8e28d 100644 --- a/Source/Core/Core/HW/EXI_DeviceEthernet.h +++ b/Source/Core/Core/HW/EXI_DeviceEthernet.h @@ -327,11 +327,12 @@ public: OVERLAPPED mWriteOverlapped; std::vector mWriteBuffer; bool mWritePending; -#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) int fd; #endif -#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) +#if defined(WIN32) || defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ + defined(__OpenBSD__) std::thread readThread; Common::Flag readEnabled; Common::Flag readThreadShutdown; diff --git a/Source/Core/VideoCommon/DriverDetails.cpp b/Source/Core/VideoCommon/DriverDetails.cpp index 46e264353f..f65f0afa3e 100644 --- a/Source/Core/VideoCommon/DriverDetails.cpp +++ b/Source/Core/VideoCommon/DriverDetails.cpp @@ -32,6 +32,8 @@ const u32 m_os = OS_ALL | OS_OSX; const u32 m_os = OS_ALL | OS_LINUX; #elif __FreeBSD__ const u32 m_os = OS_ALL | OS_FREEBSD; +#elif __OpenBSD__ +const u32 m_os = OS_ALL | OS_OPENBSD; #endif static Vendor m_vendor = VENDOR_UNKNOWN; diff --git a/Source/Core/VideoCommon/DriverDetails.h b/Source/Core/VideoCommon/DriverDetails.h index 3868eda77e..9c705694c6 100644 --- a/Source/Core/VideoCommon/DriverDetails.h +++ b/Source/Core/VideoCommon/DriverDetails.h @@ -17,6 +17,7 @@ enum OS OS_OSX = (1 << 3), OS_ANDROID = (1 << 4), OS_FREEBSD = (1 << 5), + OS_OPENBSD = (1 << 6), }; // Enum of known vendors // Tegra and Nvidia are separated out due to such substantial differences