Merge pull request #19 from lye/freebsd-platform-code

Add FreeBSD support to the codebase.
This commit is contained in:
Branimir Karadžić
2014-07-09 21:30:44 -07:00
7 changed files with 23 additions and 8 deletions

View File

@@ -12,7 +12,11 @@
#include <new>
#if BX_CONFIG_ALLOCATOR_CRT
# include <malloc.h>
# if BX_PLATFORM_FREEBSD
# include <stdlib.h>
# else
# include <malloc.h>
# endif
#endif // BX_CONFIG_ALLOCATOR_CRT
#if BX_CONFIG_ALLOCATOR_DEBUG

View File

@@ -162,6 +162,7 @@
|BX_PLATFORM_OSX \
|BX_PLATFORM_QNX \
|BX_PLATFORM_WINDOWS \
|BX_PLATFORM_FREEBSD \
)
#endif // BX_CONFIG_CRT_FILE_READER_WRITER

View File

@@ -15,10 +15,11 @@
|| BX_PLATFORM_LINUX \
|| BX_PLATFORM_OSX \
|| BX_PLATFORM_IOS \
|| BX_PLATFORM_EMSCRIPTEN
|| BX_PLATFORM_EMSCRIPTEN \
|| BX_PLATFORM_FREEBSD
# include <sched.h> // sched_yield
# if BX_PLATFORM_IOS || BX_PLATFORM_OSX || BX_PLATFORM_NACL
# if BX_PLATFORM_IOS || BX_PLATFORM_OSX || BX_PLATFORM_NACL || BX_PLATFORM_FREEBSD
# include <pthread.h> // mach_port_t
# endif // BX_PLATFORM_IOS || BX_PLATFORM_OSX || BX_PLATFORM_NACL
@@ -77,7 +78,7 @@ namespace bx
return (pid_t)::syscall(SYS_gettid);
#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
return (mach_port_t)::pthread_mach_thread_np(pthread_self() );
#elif BX_PLATFORM_NACL
#elif BX_PLATFORM_NACL || BX_PLATFORM_FREEBSD
// Casting __nc_basic_thread_data*... need better way to do this.
return *(uint32_t*)::pthread_self();
#else

View File

@@ -19,6 +19,7 @@
#define BX_PLATFORM_QNX 0
#define BX_PLATFORM_WINDOWS 0
#define BX_PLATFORM_XBOX360 0
#define BX_PLATFORM_FREEBSD 0
#define BX_CPU_ARM 0
#define BX_CPU_JIT 0
@@ -83,6 +84,9 @@
#elif defined(__QNX__)
# undef BX_PLATFORM_QNX
# define BX_PLATFORM_QNX 1
#elif defined(__FreeBSD__)
# undef BX_PLATFORM_FREEBSD
# define BX_PLATFORM_FREEBSD 1
#else
# error "BX_PLATFORM_* is not defined!"
#endif //
@@ -93,7 +97,8 @@
|| BX_PLATFORM_LINUX \
|| BX_PLATFORM_NACL \
|| BX_PLATFORM_OSX \
|| BX_PLATFORM_QNX)
|| BX_PLATFORM_QNX \
|| BX_PLATFORM_FREEBSD )
// http://sourceforge.net/apps/mediawiki/predef/index.php?title=Architectures
#if defined(__arm__)
@@ -160,6 +165,8 @@
# define BX_PLATFORM_NAME "OSX"
#elif BX_PLATFORM_QNX
# define BX_PLATFORM_NAME "QNX"
#elif BX_PLATFORM_FREEBSD
# define BX_PLATFORM_NAME "FreeBSD"
#elif BX_PLATFORM_WINDOWS
# define BX_PLATFORM_NAME "Windows"
#endif // BX_PLATFORM_

View File

@@ -15,7 +15,7 @@
#if BX_COMPILER_MSVC
# define fseeko64 _fseeki64
# define ftello64 _ftelli64
#elif BX_PLATFORM_ANDROID|BX_PLATFORM_IOS|BX_PLATFORM_OSX|BX_PLATFORM_QNX
#elif BX_PLATFORM_ANDROID|BX_PLATFORM_IOS|BX_PLATFORM_OSX|BX_PLATFORM_QNX|BX_PLATFORM_FREEBSD
# define fseeko64 fseeko
# define ftello64 ftello
#endif // BX_

View File

@@ -7,7 +7,9 @@
#define BX_PRINTF_H_HEADER_GUARD
#include "bx.h"
#include <alloca.h>
#if !BX_PLATFORM_FREEBSD
# include <alloca.h>
#endif
#include <ctype.h> // tolower
#include <stdarg.h> // va_list
#include <stdio.h> // vsnprintf, vsnwprintf

View File

@@ -12,7 +12,7 @@
# include <time.h> // clock, clock_gettime
#elif BX_PLATFORM_EMSCRIPTEN
# include <emscripten.h>
#elif BX_PLATFORM_NACL || BX_PLATFORM_LINUX || BX_PLATFORM_OSX || BX_PLATFORM_IOS || BX_PLATFORM_QNX
#elif BX_PLATFORM_NACL || BX_PLATFORM_LINUX || BX_PLATFORM_OSX || BX_PLATFORM_IOS || BX_PLATFORM_QNX || BX_PLATFORM_FREEBSD
# include <sys/time.h> // gettimeofday
#elif BX_PLATFORM_WINDOWS
# include <windows.h>