1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Added Android support, and generalized target triple support

Added PICLevel, RelocKind
DarwinCommon/LinuxCommon/AndroidCommon merged into PosixCommon
Mangling changed to avoid '@'
This commit is contained in:
Brian Fiete 2019-10-23 07:12:36 -07:00
parent 7a27ab75bf
commit 3883a3674d
39 changed files with 3457 additions and 5636 deletions

View file

@ -0,0 +1,8 @@
#include <android/log.h>
#define BFP_PRINTF(...) __android_log_print(ANDROID_LOG_INFO, "Beef", __VA_ARGS__)
#define BFP_ERRPRINTF(...) __android_log_print(ANDROID_LOG_ERROR, "Beef", __VA_ARGS__)
#define BFP_HAS_PTHREAD_GETATTR_NP
#include "../posix/PosixCommon.cpp"

View file

@ -0,0 +1,159 @@
#pragma once
#ifdef __LP64__
#define BF64
#else
#define BF32
#endif
#define BOOST_DETAIL_NO_CONTAINER_FWD
#include <string>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
#include <assert.h>
#include <sys/time.h>
//#include <libkern/OSAtomic.h>
#include <cstdlib>
#include <unistd.h>
#include <wchar.h>
#include <math.h>
#include <stdarg.h>
#include <string.h>
#include <pthread.h>
#include <wctype.h>
#include <stddef.h>
//#define offsetof(type, member) __builtin_offsetof (type, member)
extern "C"
{
//#define FFI_BUILDING
//#include "third_party/libffi/x86_64-apple-darwin12.5.0/include/ffi.h"
}
#define BF_ENDIAN_LITTLE
#define _NOEXCEPT noexcept
#define NTAPI
//#define FFI_STDCALL FFI_DEFAULT_ABI
//#define FFI_THISCALL FFI_DEFAULT_ABI
//#define FFI_FASTCALL FFI_DEFAULT_ABI
#define INVALID_SOCKET -1
typedef uint64_t uint64;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
typedef int64_t int64;
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;
typedef unsigned int uint;
//#define BF_PLATFORM_SDL
#define NOP
//#define BF_NOTHROW throw ()
//#define BF_NOTHROW noexcept
#define BF_NOTHROW
#ifdef BF64
typedef int64 intptr;
typedef uint64 uintptr;
#else
typedef int32 intptr;
typedef uint32 uintptr;
#endif
typedef wchar_t* BSTR;
typedef int HRESULT;
typedef uint8 BYTE;
typedef uint16 WORD;
typedef uint32 DWORD;
typedef int32 LONG;
typedef pthread_key_t BFTlsKey;
typedef pthread_t BF_THREADID;
typedef pthread_t BF_THREADHANDLE;
#define BF_HAS_TLS_DECLSPEC
#define BF_TLS_DECLSPEC thread_local
//:int64 abs(int64 val);
#define _stricmp stricmp
#define strnicmp strncasecmp
struct IID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[ 8 ];
};
typedef void* HANDLE;
typedef void* HMODULE;
// We only need the stdcall attribute for x32?
//#define BFSTDCALL __attribute__((stdcall))
//#include "../notwin/NotWin.h"
#ifdef DEBUG
#define _DEBUG
#endif
#define NOT_IMPL throw "Unimplemented";
//ARM
#if defined(__x86_64__) || defined(__i386__)
#define BF_FULL_MEMORY_FENCE() __asm__ __volatile__("mfence": : :"memory")
#define BF_SPINWAIT_NOP() __asm__ volatile ("pause\n" : : : "memory" );
#else
#define BF_FULL_MEMORY_FENCE() __sync_synchronize()
#define BF_SPINWAIT_NOP() ((void) 0)
#endif
#define BF_COMPILER_FENCE() __asm__ __volatile__("": : :"memory")
#define BF_THREAD_YIELD() sched_yield()
#if defined _DEBUG || defined BF_DEBUG_ASSERTS
#define BF_ASSERT(_Expression) (void)( (!!(_Expression)) || (Beefy::BFFatalError(#_Expression, __FILE__, __LINE__), 0) )
#else
#define BF_ASSERT(_Expression) (void)(0)
#endif
#define BF_ASSERT_REL(_Expression) (void)( (!!(_Expression)) || (Beefy::BFFatalError(#_Expression, __FILE__, __LINE__), 0) )
#define BF_FATAL(msg) (void) ((Beefy::BFFatalError(msg, __FILE__, __LINE__), 0) )
#if defined _DEBUG || defined BF_DEBUG_ASSERTS
#define BF_DBG_FATAL(msg) (void) ((Beefy::BFFatalError(msg, __FILE__, __LINE__), 0) )
#else
#define BF_DBG_FATAL(msg)
#endif
#define BF_NOINLINE __attribute__ ((noinline))
#define BF_NAKED
#define stricmp strcasecmp
#define _alloca alloca
#define DIR_SEP_CHAR '/'
#define DIR_SEP_CHAR_ALT '\\'
static char* itoa(int value, char* str, int base)
{
if (base == 16)
sprintf(str, "%X", value);
else
sprintf(str, "%d", value);
return str;
}

View file

@ -0,0 +1,13 @@
#include "Common.h"
#include "BFPlatform.h"
//#include <CoreFoundation/CFByteOrder.h>
//#include <mach/mach_time.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include <wchar.h>
#include <fcntl.h>
//#include <mach/clock.h>
//#include <mach/mach.h>
#include <time.h>
#include <dirent.h>

View file

@ -0,0 +1,24 @@
#pragma once
#define BFSTDCALL
#include "AndroidCommon.h"
#define BF_PLATFORM_ANDROID
#define BF_PLATFORM_POSIX
#define BF_PLATFORM_NAME "BF_PLATFORM_ANDROID"
#define BF_IMPORT extern "C"
#ifdef BFSYSLIB_DYNAMIC
#define BF_EXPORT extern "C"
#define BF_CALLTYPE
#else
#define BF_EXPORT extern "C"
#define BF_CALLTYPE
#define BF_RESOURCES_REL_DIR "../Resources"
#endif
#define BF_DEBUG_BREAK()
#include "../PlatformInterface.h"

View file

@ -0,0 +1,9 @@
#pragma once
#include "../../HeadlessApp.h"
NS_BF_BEGIN;
typedef HeadlessApp PlatformBFApp;
NS_BF_END;

File diff suppressed because it is too large Load diff

View file

@ -10,6 +10,7 @@
#endif
#define BF_PLATFORM_IOS
#define BF_PLATFORM_POSIX
#define BF_PLATFORM_OPENGL_ES2
#define BF_PLATFORM_FULLSCREEN

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,8 @@
#include <string>
#define BF_PLATFORM_MACOS
#define BF_PLATFORM_POSIX
#define BF_PLATFORM_DARWIN
#define BF_PLATFORM_NAME "BF_PLATFORM_MACOS"
#define BF_IMPORT extern "C"

File diff suppressed because it is too large Load diff

View file

@ -21,16 +21,14 @@ typedef fd_set FD_SET;
#include <sys/socket.h>
#include <mach/error.h>
#include <mach/mach.h>
#include <cerrno>
//#define errno (*__error())
#endif
//#include <rpcdce.h>
#ifdef BF_PLATFORM_POSIX
#include <cerrno>
#endif
#pragma comment(lib,"wsock32.lib")
//#include "Hash.h"
#pragma warning(disable:4996)
USING_NS_BF;

View file

@ -1356,7 +1356,9 @@ static int gDbgVizIdx = 0;
HashContext::~HashContext()
{
#ifdef BF_PLATFORM_WINDOWS
delete mDbgVizStream;
#endif
}
void HashContext::Reset()
@ -1378,6 +1380,7 @@ void HashContext::Mixin(const void* data, int size)
{
int addBytes = std::min(size, 1024 - mBufSize);
#ifdef BF_PLATFORM_WINDOWS
if (mDbgViz)
{
int findIdx = 0x2cc159;
@ -1386,6 +1389,7 @@ void HashContext::Mixin(const void* data, int size)
NOP;
}
}
#endif
memcpy(&mBuf[mBufSize], data, addBytes);
mBufSize += addBytes;
@ -1417,6 +1421,7 @@ void HashContext::MixinStr(const StringImpl& str)
Val128 HashContext::Finish128()
{
#ifdef BF_PLATFORM_WINDOWS
if (mDbgViz)
{
// String dbg = "HashContext Dbg";
@ -1441,6 +1446,7 @@ Val128 HashContext::Finish128()
if ((mDbgVizStream != NULL) && (mDbgVizStream->IsOpen()))
mDbgVizStream->Write(mBuf, mBufSize);
}
#endif
if (mBufSize <= 16)
{
@ -1459,6 +1465,7 @@ Val128 HashContext::Finish128()
uint64 HashContext::Finish64()
{
#ifdef BF_PLATFORM_WINDOWS
if (mDbgViz)
{
// String dbg = "HashContext Dbg";
@ -1476,6 +1483,7 @@ uint64 HashContext::Finish64()
}
mDbgVizStream->Write(mBuf, mBufSize);
}
#endif
if (mBufSize <= 8)
{

View file

@ -109,16 +109,20 @@ public:
uint8 mBuf[1024];
int mBufSize;
int mBufOffset;
#ifdef BF_PLATFORM_WINDOWS
bool mDbgViz;
FileStream* mDbgVizStream;
#endif
public:
HashContext()
{
mBufOffset = 0;
mBufSize = 0;
#ifdef BF_PLATFORM_WINDOWS
mDbgViz = false;
mDbgVizStream = NULL;
#endif
}
~HashContext();