Merge pull request #4018 from bentley/openbsd-ifdefs

Openbsd ifdefs
This commit is contained in:
Matthew Parlane 2016-07-18 16:12:06 +12:00 committed by GitHub
commit a51c992e61
6 changed files with 17 additions and 11 deletions

View file

@ -20,7 +20,7 @@
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#if defined __APPLE__ || defined __FreeBSD__
#if defined __APPLE__ || defined __FreeBSD__ || defined __OpenBSD__
#include <sys/sysctl.h>
#else
#include <sys/sysinfo.h>
@ -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);

View file

@ -28,7 +28,7 @@
#include <locale.h>
#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

View file

@ -12,7 +12,7 @@
#ifdef __APPLE__
#include <mach/mach.h>
#elif defined BSD4_4 || defined __FreeBSD__
#elif defined BSD4_4 || defined __FreeBSD__ || defined __OpenBSD__
#include <pthread_np.h>
#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.

View file

@ -327,11 +327,12 @@ public:
OVERLAPPED mWriteOverlapped;
std::vector<u8> 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;

View file

@ -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;

View file

@ -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