Merge pull request #1093 from stevenc99/kfreebsd

GNU/kFreeBSD support
This commit is contained in:
R. Belmont 2016-07-16 06:09:32 -04:00 committed by GitHub
commit 13c8e76cf7
6 changed files with 63 additions and 35 deletions

View File

@ -6,12 +6,37 @@
#ifndef BX_PLATFORM_H_HEADER_GUARD
#define BX_PLATFORM_H_HEADER_GUARD
// Architecture
#define BX_ARCH_32BIT 0
#define BX_ARCH_64BIT 0
// Compiler
#define BX_COMPILER_CLANG 0
#define BX_COMPILER_CLANG_ANALYZER 0
#define BX_COMPILER_GCC 0
#define BX_COMPILER_MSVC 0
#define BX_COMPILER_MSVC_COMPATIBLE 0
#define BX_COMPILER_MSVC_COMPATIBLE (BX_CRT_MSVC)
// Endianess
#define BX_CPU_ENDIAN_BIG 0
#define BX_CPU_ENDIAN_LITTLE 0
// CPU
#define BX_CPU_ARM 0
#define BX_CPU_JIT 0
#define BX_CPU_MIPS 0
#define BX_CPU_PPC 0
#define BX_CPU_RISCV 0
#define BX_CPU_X86 0
// C Runtime
#define BX_CRT_MSVC 0
#define BX_CRT_GLIBC 0
#define BX_CRT_NEWLIB 0
#define BX_CRT_MINGW 0
#define BX_CRT_MUSL 0
// Platform
#define BX_PLATFORM_ANDROID 0
#define BX_PLATFORM_EMSCRIPTEN 0
#define BX_PLATFORM_BSD 0
@ -28,19 +53,6 @@
#define BX_PLATFORM_XBOX360 0
#define BX_PLATFORM_XBOXONE 0
#define BX_CPU_ARM 0
#define BX_CPU_JIT 0
#define BX_CPU_MIPS 0
#define BX_CPU_PPC 0
#define BX_CPU_RISCV 0
#define BX_CPU_X86 0
#define BX_ARCH_32BIT 0
#define BX_ARCH_64BIT 0
#define BX_CPU_ENDIAN_BIG 0
#define BX_CPU_ENDIAN_LITTLE 0
// http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
#if defined(__clang__)
// clang defines __GNUC__ or _MSC_VER
@ -51,17 +63,27 @@
# define BX_COMPILER_CLANG_ANALYZER 1
# endif // defined(__clang_analyzer__)
# if defined(_MSC_VER)
# undef BX_COMPILER_MSVC_COMPATIBLE
# define BX_COMPILER_MSVC_COMPATIBLE _MSC_VER
# endif // defined(_MSC_VER)
# undef BX_CRT_MSVC
# define BX_CRT_MSVC 1
# elif defined(__GLIBC__)
# undef BX_CRT_GLIBC
# define BX_CRT_GLIBC (__GLIBC__ * 10000 + __GLIBC_MINOR__ * 100)
# endif // defined(__GLIBC__)
#elif defined(_MSC_VER)
# undef BX_COMPILER_MSVC
# define BX_COMPILER_MSVC _MSC_VER
# undef BX_COMPILER_MSVC_COMPATIBLE
# define BX_COMPILER_MSVC_COMPATIBLE _MSC_VER
# undef BX_CRT_MSVC
# define BX_CRT_MSVC 1
#elif defined(__GNUC__)
# undef BX_COMPILER_GCC
# define BX_COMPILER_GCC (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
# if defined(__GLIBC__)
# undef BX_CRT_GLIBC
# define BX_CRT_GLIBC (__GLIBC__ * 10000 + __GLIBC_MINOR__ * 100)
# elif defined(__MINGW32__) || defined(__MINGW64__)
# undef BX_CRT_MINGW
# define BX_CRT_MINGW 1
# endif //
#else
# error "BX_COMPILER_* is not defined!"
#endif //

View File

@ -8,17 +8,17 @@
#if BX_PLATFORM_POSIX
# include <pthread.h>
# if BX_PLATFORM_BSD
# if defined(__FreeBSD__)
# include <pthread_np.h>
# endif
# if defined(__GLIBC__) && !( (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) ) )
# if BX_PLATFORM_LINUX && (BX_CRT_GLIBC < 21200)
# include <sys/prctl.h>
# endif // defined(__GLIBC__) ...
# endif // BX_PLATFORM_
#elif BX_PLATFORM_WINRT
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::System::Threading;
#endif
#endif // BX_PLATFORM_
#include "sem.h"
@ -157,18 +157,16 @@ namespace bx
{
#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
pthread_setname_np(_name);
#elif BX_PLATFORM_LINUX
# if defined(__GLIBC__) && (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 12) )
#elif (BX_CRT_GLIBC >= 21200)
pthread_setname_np(m_handle, _name);
# else
#elif BX_PLATFORM_LINUX
prctl(PR_SET_NAME,_name, 0, 0, 0);
# endif // defined(__GLIBC__) ...
#elif BX_PLATFORM_BSD
#ifdef __NetBSD__
pthread_setname_np(m_handle, "%s", (void *)_name);
#else
# ifdef __NetBSD__
pthread_setname_np(m_handle, "%s", (void*)_name);
# else
pthread_set_name_np(m_handle, _name);
#endif
# endif // __NetBSD__
#elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
# pragma pack(push, 8)
struct ThreadName

View File

@ -1 +1,5 @@
#include <stdlib.h>
#if defined(__GLIBC__)
# include_next <alloca.h>
#else
# include <stdlib.h>
#endif

View File

@ -1 +1,5 @@
#include <sys/signal.h>
#if defined(__GLIBC__)
# include_next <signal.h>
#else
# include <sys/signal.h>
#endif

View File

@ -340,7 +340,7 @@ project ("qtdbg_" .. _OPTIONS["osd"])
MAME_DIR .. "src/osd/modules/render",
MAME_DIR .. "3rdparty",
}
configuration { "linux-*" }
configuration { "linux-* or freebsd" }
buildoptions {
"-fPIC",
}

View File

@ -19,7 +19,7 @@
#include <unistd.h>
#include <stdlib.h>
#if defined(__FreeBSD__) || defined(__DragonFly__)
#if defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#include <termios.h>
#include <libutil.h>
#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__ANDROID__)