mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
updated bx (nw)
This commit is contained in:
parent
b900f66730
commit
a74a7a37ef
195
3rdparty/bx/include/bx/cpu.h
vendored
195
3rdparty/bx/include/bx/cpu.h
vendored
@ -25,8 +25,7 @@ extern "C" void _ReadWriteBarrier();
|
||||
# pragma intrinsic(_ReadBarrier)
|
||||
# pragma intrinsic(_WriteBarrier)
|
||||
# pragma intrinsic(_ReadWriteBarrier)
|
||||
# pragma intrinsic(_InterlockedIncrement)
|
||||
# pragma intrinsic(_InterlockedDecrement)
|
||||
# pragma intrinsic(_InterlockedExchangeAdd)
|
||||
# pragma intrinsic(_InterlockedCompareExchange)
|
||||
#endif // BX_COMPILER_MSVC
|
||||
|
||||
@ -77,27 +76,184 @@ namespace bx
|
||||
#endif // BX_COMPILER
|
||||
}
|
||||
|
||||
/// Returns the resulting incremented value.
|
||||
inline int32_t atomicInc(volatile void* _ptr)
|
||||
template<typename Ty>
|
||||
inline Ty atomicFetchAndAdd(volatile Ty* _ptr, Ty _value);
|
||||
|
||||
template<typename Ty>
|
||||
inline Ty atomicAddAndFetch(volatile Ty* _ptr, Ty _value);
|
||||
|
||||
template<typename Ty>
|
||||
inline Ty atomicFetchAndSub(volatile Ty* _ptr, Ty _value);
|
||||
|
||||
template<typename Ty>
|
||||
inline Ty atomicSubAndFetch(volatile Ty* _ptr, Ty _value);
|
||||
|
||||
template<typename Ty>
|
||||
inline Ty atomicCompareAndSwap(volatile void* _ptr, Ty _old, Ty _new);
|
||||
|
||||
template<>
|
||||
inline int32_t atomicCompareAndSwap(volatile void* _ptr, int32_t _old, int32_t _new);
|
||||
|
||||
template<>
|
||||
inline int64_t atomicCompareAndSwap(volatile void* _ptr, int64_t _old, int64_t _new);
|
||||
|
||||
template<>
|
||||
inline int32_t atomicFetchAndAdd<int32_t>(volatile int32_t* _ptr, int32_t _add)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return _InterlockedIncrement( (volatile LONG*)(_ptr) );
|
||||
return _InterlockedExchangeAdd( (volatile long*)_ptr, _add);
|
||||
#else
|
||||
return __sync_add_and_fetch( (volatile int32_t*)_ptr, 1);
|
||||
#endif // BX_COMPILER
|
||||
return __sync_fetch_and_add(_ptr, _add);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int64_t atomicFetchAndAdd<int64_t>(volatile int64_t* _ptr, int64_t _add)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
# if _WIN32_WINNT >= 0x600
|
||||
return _InterlockedExchangeAdd64( (volatile int64_t*)_ptr, _add);
|
||||
# else
|
||||
int64_t oldVal;
|
||||
int64_t newVal = *(int64_t volatile*)_ptr;
|
||||
do
|
||||
{
|
||||
oldVal = newVal;
|
||||
newVal = atomicCompareAndSwap(_ptr, oldVal, newVal + _add);
|
||||
|
||||
} while (oldVal != newVal);
|
||||
|
||||
return oldVal;
|
||||
# endif
|
||||
#else
|
||||
return __sync_fetch_and_add(_ptr, _add);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint32_t atomicFetchAndAdd<uint32_t>(volatile uint32_t* _ptr, uint32_t _add)
|
||||
{
|
||||
return uint32_t(atomicFetchAndAdd<int32_t>( (volatile int32_t*)_ptr, int32_t(_add) ) );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint64_t atomicFetchAndAdd<uint64_t>(volatile uint64_t* _ptr, uint64_t _add)
|
||||
{
|
||||
return uint64_t(atomicFetchAndAdd<int64_t>( (volatile int64_t*)_ptr, int64_t(_add) ) );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int32_t atomicAddAndFetch<int32_t>(volatile int32_t* _ptr, int32_t _add)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return atomicFetchAndAdd(_ptr, _add) + _add;
|
||||
#else
|
||||
return __sync_add_and_fetch(_ptr, _add);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int64_t atomicAddAndFetch<int64_t>(volatile int64_t* _ptr, int64_t _add)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return atomicFetchAndAdd(_ptr, _add) + _add;
|
||||
#else
|
||||
return __sync_add_and_fetch(_ptr, _add);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint32_t atomicAddAndFetch<uint32_t>(volatile uint32_t* _ptr, uint32_t _add)
|
||||
{
|
||||
return uint32_t(atomicAddAndFetch<int32_t>( (volatile int32_t*)_ptr, int32_t(_add) ) );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint64_t atomicAddAndFetch<uint64_t>(volatile uint64_t* _ptr, uint64_t _add)
|
||||
{
|
||||
return uint64_t(atomicAddAndFetch<int64_t>( (volatile int64_t*)_ptr, int64_t(_add) ) );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int32_t atomicFetchAndSub<int32_t>(volatile int32_t* _ptr, int32_t _sub)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return atomicFetchAndAdd(_ptr, -_sub);
|
||||
#else
|
||||
return __sync_fetch_and_sub(_ptr, _sub);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int64_t atomicFetchAndSub<int64_t>(volatile int64_t* _ptr, int64_t _sub)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return atomicFetchAndAdd(_ptr, -_sub);
|
||||
#else
|
||||
return __sync_fetch_and_sub(_ptr, _sub);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint32_t atomicFetchAndSub<uint32_t>(volatile uint32_t* _ptr, uint32_t _add)
|
||||
{
|
||||
return uint32_t(atomicFetchAndSub<int32_t>( (volatile int32_t*)_ptr, int32_t(_add) ) );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint64_t atomicFetchAndSub<uint64_t>(volatile uint64_t* _ptr, uint64_t _add)
|
||||
{
|
||||
return uint64_t(atomicFetchAndSub<int64_t>( (volatile int64_t*)_ptr, int64_t(_add) ) );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int32_t atomicSubAndFetch<int32_t>(volatile int32_t* _ptr, int32_t _sub)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return atomicFetchAndAdd(_ptr, -_sub) - _sub;
|
||||
#else
|
||||
return __sync_sub_and_fetch(_ptr, _sub);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int64_t atomicSubAndFetch<int64_t>(volatile int64_t* _ptr, int64_t _sub)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return atomicFetchAndAdd(_ptr, -_sub) - _sub;
|
||||
#else
|
||||
return __sync_sub_and_fetch(_ptr, _sub);
|
||||
#endif // BX_COMPILER_
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint32_t atomicSubAndFetch<uint32_t>(volatile uint32_t* _ptr, uint32_t _add)
|
||||
{
|
||||
return uint32_t(atomicSubAndFetch<int32_t>( (volatile int32_t*)_ptr, int32_t(_add) ) );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline uint64_t atomicSubAndFetch<uint64_t>(volatile uint64_t* _ptr, uint64_t _add)
|
||||
{
|
||||
return uint64_t(atomicSubAndFetch<int64_t>( (volatile int64_t*)_ptr, int64_t(_add) ) );
|
||||
}
|
||||
|
||||
/// Returns the resulting incremented value.
|
||||
template<typename Ty>
|
||||
inline Ty atomicInc(volatile Ty* _ptr)
|
||||
{
|
||||
return atomicAddAndFetch(_ptr, Ty(1) );
|
||||
}
|
||||
|
||||
/// Returns the resulting decremented value.
|
||||
inline int32_t atomicDec(volatile void* _ptr)
|
||||
template<typename Ty>
|
||||
inline Ty atomicDec(volatile Ty* _ptr)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return _InterlockedDecrement( (volatile LONG*)(_ptr) );
|
||||
#else
|
||||
return __sync_sub_and_fetch( (volatile int32_t*)_ptr, 1);
|
||||
#endif // BX_COMPILER
|
||||
return atomicSubAndFetch(_ptr, Ty(1) );
|
||||
}
|
||||
|
||||
///
|
||||
template<>
|
||||
inline int32_t atomicCompareAndSwap(volatile void* _ptr, int32_t _old, int32_t _new)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
@ -107,11 +263,22 @@ namespace bx
|
||||
#endif // BX_COMPILER
|
||||
}
|
||||
|
||||
///
|
||||
template<>
|
||||
inline int64_t atomicCompareAndSwap(volatile void* _ptr, int64_t _old, int64_t _new)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return _InterlockedCompareExchange64( (volatile LONG64*)(_ptr), _new, _old);
|
||||
#else
|
||||
return __sync_val_compare_and_swap( (volatile int64_t*)_ptr, _old, _new);
|
||||
#endif // BX_COMPILER
|
||||
}
|
||||
|
||||
///
|
||||
inline void* atomicExchangePtr(void** _ptr, void* _new)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return InterlockedExchangePointer(_ptr, _new); /* VS2012 no intrinsics */
|
||||
return InterlockedExchangePointer(_ptr, _new);
|
||||
#else
|
||||
return __sync_lock_test_and_set(_ptr, _new);
|
||||
#endif // BX_COMPILER
|
||||
|
5
3rdparty/bx/include/bx/debug.h
vendored
5
3rdparty/bx/include/bx/debug.h
vendored
@ -51,7 +51,10 @@ namespace bx
|
||||
inline void debugOutput(const char* _out)
|
||||
{
|
||||
#if BX_PLATFORM_ANDROID
|
||||
__android_log_write(ANDROID_LOG_DEBUG, "", _out);
|
||||
# ifndef BX_ANDROID_LOG_TAG
|
||||
# define BX_ANDROID_LOG_TAG ""
|
||||
# endif // BX_ANDROID_LOG_TAG
|
||||
__android_log_write(ANDROID_LOG_DEBUG, BX_ANDROID_LOG_TAG, _out);
|
||||
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360
|
||||
OutputDebugStringA(_out);
|
||||
#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
|
||||
|
29
3rdparty/bx/include/bx/macros.h
vendored
29
3rdparty/bx/include/bx/macros.h
vendored
@ -48,6 +48,18 @@
|
||||
|
||||
#define BX_ALIGNOF(_type) __alignof(_type)
|
||||
|
||||
#if defined(__has_feature)
|
||||
# define BX_CLANG_HAS_FEATURE(_x) __has_feature(_x)
|
||||
#else
|
||||
# define BX_CLANG_HAS_FEATURE(_x) 0
|
||||
#endif // defined(__has_feature)
|
||||
|
||||
#if defined(__has_extension)
|
||||
# define BX_CLANG_HAS_EXTENSION(_x) __has_extension(_x)
|
||||
#else
|
||||
# define BX_CLANG_HAS_EXTENSION(_x) 0
|
||||
#endif // defined(__has_extension)
|
||||
|
||||
#if BX_COMPILER_GCC || BX_COMPILER_CLANG
|
||||
# define BX_ALIGN_DECL(_align, _decl) _decl __attribute__( (aligned(_align) ) )
|
||||
# define BX_ALLOW_UNUSED __attribute__( (unused) )
|
||||
@ -60,11 +72,12 @@
|
||||
# define BX_NO_VTABLE
|
||||
# define BX_OVERRIDE
|
||||
# define BX_PRINTF_ARGS(_format, _args) __attribute__ ( (format(__printf__, _format, _args) ) )
|
||||
# if BX_COMPILER_CLANG && (BX_PLATFORM_OSX || BX_PLATFORM_IOS)
|
||||
# define BX_THREAD /* not supported right now */
|
||||
# else
|
||||
# define BX_THREAD __thread
|
||||
# if BX_CLANG_HAS_FEATURE(cxx_thread_local)
|
||||
# define BX_THREAD_LOCAL __thread
|
||||
# endif // BX_COMPILER_CLANG
|
||||
# if BX_COMPILER_GCC >= 40200
|
||||
# define BX_THREAD_LOCAL __thread
|
||||
# endif // BX_COMPILER_GCC
|
||||
# define BX_ATTRIBUTE(_x) __attribute__( (_x) )
|
||||
# if BX_COMPILER_MSVC_COMPATIBLE
|
||||
# define __stdcall
|
||||
@ -81,18 +94,12 @@
|
||||
# define BX_NO_VTABLE __declspec(novtable)
|
||||
# define BX_OVERRIDE override
|
||||
# define BX_PRINTF_ARGS(_format, _args)
|
||||
# define BX_THREAD __declspec(thread)
|
||||
# define BX_THREAD_LOCAL __declspec(thread)
|
||||
# define BX_ATTRIBUTE(_x)
|
||||
#else
|
||||
# error "Unknown BX_COMPILER_?"
|
||||
#endif
|
||||
|
||||
#if defined(__has_extension)
|
||||
# define BX_CLANG_HAS_EXTENSION(_x) __has_extension(_x)
|
||||
#else
|
||||
# define BX_CLANG_HAS_EXTENSION(_x) 0
|
||||
#endif // defined(__has_extension)
|
||||
|
||||
// #define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, "" __VA_ARGS__)
|
||||
#define BX_STATIC_ASSERT(_condition, ...) typedef char BX_CONCATENATE(BX_STATIC_ASSERT_, __LINE__)[1][(_condition)] BX_ATTRIBUTE(unused)
|
||||
|
||||
|
37
3rdparty/bx/include/bx/mpscqueue.h
vendored
37
3rdparty/bx/include/bx/mpscqueue.h
vendored
@ -29,9 +29,8 @@ namespace bx
|
||||
|
||||
void push(Ty* _ptr) // producer only
|
||||
{
|
||||
m_write.lock();
|
||||
LwMutexScope $(m_write);
|
||||
m_queue.push(_ptr);
|
||||
m_write.unlock();
|
||||
}
|
||||
|
||||
Ty* peek() // consumer only
|
||||
@ -49,6 +48,40 @@ namespace bx
|
||||
SpScUnboundedQueue<Ty> m_queue;
|
||||
};
|
||||
|
||||
template <typename Ty>
|
||||
class MpScUnboundedBlockingQueue
|
||||
{
|
||||
BX_CLASS(MpScUnboundedBlockingQueue
|
||||
, NO_COPY
|
||||
, NO_ASSIGNMENT
|
||||
);
|
||||
|
||||
public:
|
||||
MpScUnboundedBlockingQueue()
|
||||
{
|
||||
}
|
||||
|
||||
~MpScUnboundedBlockingQueue()
|
||||
{
|
||||
}
|
||||
|
||||
void push(Ty* _ptr) // producer only
|
||||
{
|
||||
m_queue.push(_ptr);
|
||||
m_sem.post();
|
||||
}
|
||||
|
||||
Ty* pop() // consumer only
|
||||
{
|
||||
m_sem.wait();
|
||||
return m_queue.pop();
|
||||
}
|
||||
|
||||
private:
|
||||
MpScUnboundedQueue<Ty> m_queue;
|
||||
Semaphore m_sem;
|
||||
};
|
||||
|
||||
} // namespace bx
|
||||
|
||||
#endif // BX_MPSCQUEUE_H_HEADER_GUARD
|
||||
|
8
3rdparty/bx/include/bx/mutex.h
vendored
8
3rdparty/bx/include/bx/mutex.h
vendored
@ -69,7 +69,13 @@ namespace bx
|
||||
public:
|
||||
Mutex()
|
||||
{
|
||||
pthread_mutex_init(&m_handle, NULL);
|
||||
pthread_mutexattr_t attr;
|
||||
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
|
||||
#else
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
#endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT
|
||||
pthread_mutex_init(&m_handle, &attr);
|
||||
}
|
||||
|
||||
~Mutex()
|
||||
|
6
3rdparty/bx/include/bx/os.h
vendored
6
3rdparty/bx/include/bx/os.h
vendored
@ -15,21 +15,17 @@
|
||||
#elif BX_PLATFORM_ANDROID \
|
||||
|| BX_PLATFORM_EMSCRIPTEN \
|
||||
|| BX_PLATFORM_FREEBSD \
|
||||
|| BX_PLATFORM_NETBSD \
|
||||
|| BX_PLATFORM_IOS \
|
||||
|| BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_NACL \
|
||||
|| BX_PLATFORM_NETBSD \
|
||||
|| BX_PLATFORM_OSX \
|
||||
|| BX_PLATFORM_PS4 \
|
||||
|| BX_PLATFORM_RPI
|
||||
|
||||
# include <sched.h> // sched_yield
|
||||
# if BX_PLATFORM_FREEBSD \
|
||||
|| BX_PLATFORM_NETBSD \
|
||||
|| BX_PLATFORM_IOS \
|
||||
|| BX_PLATFORM_NACL \
|
||||
|| BX_PLATFORM_NETBSD \
|
||||
|| BX_PLATFORM_OSX \
|
||||
|| BX_PLATFORM_PS4
|
||||
# include <pthread.h> // mach_port_t
|
||||
@ -107,7 +103,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_FREEBSD || BX_PLATFORM_NACL || BX_PLATFORM_NETBSD
|
||||
#elif BX_PLATFORM_FREEBSD || BX_PLATFORM_NACL
|
||||
// Casting __nc_basic_thread_data*... need better way to do this.
|
||||
return *(uint32_t*)::pthread_self();
|
||||
#else
|
||||
|
13
3rdparty/bx/include/bx/platform.h
vendored
13
3rdparty/bx/include/bx/platform.h
vendored
@ -15,11 +15,9 @@
|
||||
#define BX_PLATFORM_ANDROID 0
|
||||
#define BX_PLATFORM_EMSCRIPTEN 0
|
||||
#define BX_PLATFORM_FREEBSD 0
|
||||
#define BX_PLATFORM_NETBSD 0
|
||||
#define BX_PLATFORM_IOS 0
|
||||
#define BX_PLATFORM_LINUX 0
|
||||
#define BX_PLATFORM_NACL 0
|
||||
#define BX_PLATFORM_NETBSD 0
|
||||
#define BX_PLATFORM_OSX 0
|
||||
#define BX_PLATFORM_PS4 0
|
||||
#define BX_PLATFORM_QNX 0
|
||||
@ -171,7 +169,7 @@
|
||||
#elif defined(__linux__)
|
||||
# undef BX_PLATFORM_LINUX
|
||||
# define BX_PLATFORM_LINUX 1
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
|
||||
#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
|
||||
# undef BX_PLATFORM_IOS
|
||||
# define BX_PLATFORM_IOS 1
|
||||
#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
|
||||
@ -189,9 +187,6 @@
|
||||
#elif defined(__FreeBSD__)
|
||||
# undef BX_PLATFORM_FREEBSD
|
||||
# define BX_PLATFORM_FREEBSD 1
|
||||
#elif defined(__NetBSD__)
|
||||
# undef BX_PLATFORM_NETBSD
|
||||
# define BX_PLATFORM_NETBSD 1
|
||||
#else
|
||||
# error "BX_PLATFORM_* is not defined!"
|
||||
#endif //
|
||||
@ -200,11 +195,9 @@
|
||||
|| BX_PLATFORM_ANDROID \
|
||||
|| BX_PLATFORM_EMSCRIPTEN \
|
||||
|| BX_PLATFORM_FREEBSD \
|
||||
|| BX_PLATFORM_NETBSD \
|
||||
|| BX_PLATFORM_IOS \
|
||||
|| BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_NACL \
|
||||
|| BX_PLATFORM_NETBSD \
|
||||
|| BX_PLATFORM_OSX \
|
||||
|| BX_PLATFORM_QNX \
|
||||
|| BX_PLATFORM_PS4 \
|
||||
@ -251,8 +244,6 @@
|
||||
BX_STRINGIZE(__EMSCRIPTEN_tiny__)
|
||||
#elif BX_PLATFORM_FREEBSD
|
||||
# define BX_PLATFORM_NAME "FreeBSD"
|
||||
#elif BX_PLATFORM_NETBSD
|
||||
# define BX_PLATFORM_NAME "NetBSD"
|
||||
#elif BX_PLATFORM_IOS
|
||||
# define BX_PLATFORM_NAME "iOS"
|
||||
#elif BX_PLATFORM_LINUX
|
||||
@ -260,8 +251,6 @@
|
||||
#elif BX_PLATFORM_NACL
|
||||
# define BX_PLATFORM_NAME "NaCl " \
|
||||
BX_STRINGIZE(BX_PLATFORM_NACL)
|
||||
#elif BX_PLATFORM_NETBSD
|
||||
# define BX_PLATFORM_NAME "NetBSD"
|
||||
#elif BX_PLATFORM_OSX
|
||||
# define BX_PLATFORM_NAME "OSX"
|
||||
#elif BX_PLATFORM_PS4
|
||||
|
4
3rdparty/bx/include/bx/thread.h
vendored
4
3rdparty/bx/include/bx/thread.h
vendored
@ -260,7 +260,7 @@ namespace bx
|
||||
uint32_t m_id;
|
||||
};
|
||||
|
||||
#elif !(BX_PLATFORM_WINRT)
|
||||
#elif !BX_PLATFORM_WINRT
|
||||
|
||||
class TlsData
|
||||
{
|
||||
@ -291,7 +291,7 @@ namespace bx
|
||||
private:
|
||||
pthread_key_t m_id;
|
||||
};
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
#endif // BX_PLATFORM_*
|
||||
|
||||
} // namespace bx
|
||||
|
||||
|
195
3rdparty/bx/scripts/toolchain.lua
vendored
195
3rdparty/bx/scripts/toolchain.lua
vendored
@ -13,25 +13,29 @@ function toolchain(_buildDir, _libDir)
|
||||
value = "GCC",
|
||||
description = "Choose GCC flavor",
|
||||
allowed = {
|
||||
{ "android-arm", "Android - ARM" },
|
||||
{ "android-mips", "Android - MIPS" },
|
||||
{ "android-x86", "Android - x86" },
|
||||
{ "asmjs", "Emscripten/asm.js" },
|
||||
{ "freebsd", "FreeBSD" },
|
||||
{ "linux-gcc", "Linux (GCC compiler)" },
|
||||
{ "linux-gcc-5", "Linux (GCC-5 compiler)" },
|
||||
{ "linux-clang", "Linux (Clang compiler)" },
|
||||
{ "ios-arm", "iOS - ARM" },
|
||||
{ "ios-simulator", "iOS - Simulator" },
|
||||
{ "mingw-gcc", "MinGW" },
|
||||
{ "mingw-clang", "MinGW (clang compiler)" },
|
||||
{ "nacl", "Native Client" },
|
||||
{ "nacl-arm", "Native Client - ARM" },
|
||||
{ "osx", "OSX" },
|
||||
{ "pnacl", "Native Client - PNaCl" },
|
||||
{ "ps4", "PS4" },
|
||||
{ "qnx-arm", "QNX/Blackberry - ARM" },
|
||||
{ "rpi", "RaspberryPi" },
|
||||
{ "android-arm", "Android - ARM" },
|
||||
{ "android-mips", "Android - MIPS" },
|
||||
{ "android-x86", "Android - x86" },
|
||||
{ "asmjs", "Emscripten/asm.js" },
|
||||
{ "freebsd", "FreeBSD" },
|
||||
{ "linux-gcc", "Linux (GCC compiler)" },
|
||||
{ "linux-gcc-5", "Linux (GCC-5 compiler)" },
|
||||
{ "linux-clang", "Linux (Clang compiler)" },
|
||||
{ "linux-mips-gcc", "Linux (MIPS, GCC compiler)" },
|
||||
{ "linux-arm-gcc", "Linux (ARM, GCC compiler)" },
|
||||
{ "ios-arm", "iOS - ARM" },
|
||||
{ "ios-simulator", "iOS - Simulator" },
|
||||
{ "tvos-arm64", "tvOS - ARM64" },
|
||||
{ "tvos-simulator", "tvOS - Simulator" },
|
||||
{ "mingw-gcc", "MinGW" },
|
||||
{ "mingw-clang", "MinGW (clang compiler)" },
|
||||
{ "nacl", "Native Client" },
|
||||
{ "nacl-arm", "Native Client - ARM" },
|
||||
{ "osx", "OSX" },
|
||||
{ "pnacl", "Native Client - PNaCl" },
|
||||
{ "ps4", "PS4" },
|
||||
{ "qnx-arm", "QNX/Blackberry - ARM" },
|
||||
{ "rpi", "RaspberryPi" },
|
||||
},
|
||||
}
|
||||
|
||||
@ -60,6 +64,7 @@ function toolchain(_buildDir, _libDir)
|
||||
allowed = {
|
||||
{ "osx", "OSX" },
|
||||
{ "ios", "iOS" },
|
||||
{ "tvos", "tvOS" },
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +80,12 @@ function toolchain(_buildDir, _libDir)
|
||||
description = "Set iOS target version (default: 8.0).",
|
||||
}
|
||||
|
||||
newoption {
|
||||
trigger = "with-tvos",
|
||||
value = "#",
|
||||
description = "Set tvOS target version (default: 9.0).",
|
||||
}
|
||||
|
||||
-- Avoid error when invoking genie --help.
|
||||
if (_ACTION == nil) then return false end
|
||||
|
||||
@ -94,6 +105,11 @@ function toolchain(_buildDir, _libDir)
|
||||
iosPlatform = _OPTIONS["with-ios"]
|
||||
end
|
||||
|
||||
local tvosPlatform = ""
|
||||
if _OPTIONS["with-tvos"] then
|
||||
tvosPlatform = _OPTIONS["with-tvos"]
|
||||
end
|
||||
|
||||
if _ACTION == "gmake" then
|
||||
|
||||
if nil == _OPTIONS["gcc"] then
|
||||
@ -154,17 +170,29 @@ function toolchain(_buildDir, _libDir)
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
|
||||
|
||||
elseif "ios-arm" == _OPTIONS["gcc"] then
|
||||
premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
|
||||
premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
|
||||
premake.gcc.cc = "clang"
|
||||
premake.gcc.cxx = "clang++"
|
||||
premake.gcc.ar = "ar"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-ios-arm"))
|
||||
|
||||
elseif "ios-simulator" == _OPTIONS["gcc"] then
|
||||
premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
|
||||
premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
|
||||
premake.gcc.cc = "clang"
|
||||
premake.gcc.cxx = "clang++"
|
||||
premake.gcc.ar = "ar"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
|
||||
|
||||
elseif "tvos-arm64" == _OPTIONS["gcc"] then
|
||||
premake.gcc.cc = "clang"
|
||||
premake.gcc.cxx = "clang++"
|
||||
premake.gcc.ar = "ar"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-tvos-arm64"))
|
||||
|
||||
elseif "tvos-simulator" == _OPTIONS["gcc"] then
|
||||
premake.gcc.cc = "clang"
|
||||
premake.gcc.cxx = "clang++"
|
||||
premake.gcc.ar = "ar"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-tvos-simulator"))
|
||||
|
||||
elseif "linux-gcc" == _OPTIONS["gcc"] then
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
|
||||
|
||||
@ -180,6 +208,12 @@ function toolchain(_buildDir, _libDir)
|
||||
premake.gcc.ar = "ar"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
|
||||
|
||||
elseif "linux-mips-gcc" == _OPTIONS["gcc"] then
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-linux-mips-gcc"))
|
||||
|
||||
elseif "linux-arm-gcc" == _OPTIONS["gcc"] then
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-linux-arm-gcc"))
|
||||
|
||||
elseif "mingw-gcc" == _OPTIONS["gcc"] then
|
||||
premake.gcc.cc = "$(MINGW)/bin/x86_64-w64-mingw32-gcc"
|
||||
premake.gcc.cxx = "$(MINGW)/bin/x86_64-w64-mingw32-g++"
|
||||
@ -335,6 +369,10 @@ function toolchain(_buildDir, _libDir)
|
||||
elseif "ios" == _OPTIONS["xcode"] then
|
||||
premake.xcode.toolset = "iphoneos"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-ios"))
|
||||
|
||||
elseif "tvos" == _OPTIONS["xcode"] then
|
||||
premake.xcode.toolset = "appletvos"
|
||||
location (path.join(_buildDir, "projects", _ACTION .. "-tvos"))
|
||||
end
|
||||
end
|
||||
|
||||
@ -397,7 +435,6 @@ function toolchain(_buildDir, _libDir)
|
||||
objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
|
||||
libdirs {
|
||||
path.join(_libDir, "lib/win32_" .. _ACTION),
|
||||
"$(DXSDK_DIR)/lib/x86",
|
||||
}
|
||||
|
||||
configuration { "x64", "vs*" }
|
||||
@ -406,7 +443,6 @@ function toolchain(_buildDir, _libDir)
|
||||
objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
|
||||
libdirs {
|
||||
path.join(_libDir, "lib/win64_" .. _ACTION),
|
||||
"$(DXSDK_DIR)/lib/x64",
|
||||
}
|
||||
|
||||
configuration { "ARM", "vs*" }
|
||||
@ -462,7 +498,6 @@ function toolchain(_buildDir, _libDir)
|
||||
objdir (path.join(_buildDir, "win32_mingw-gcc/obj"))
|
||||
libdirs {
|
||||
path.join(_libDir, "lib/win32_mingw-gcc"),
|
||||
"$(DXSDK_DIR)/lib/x86",
|
||||
}
|
||||
buildoptions { "-m32" }
|
||||
|
||||
@ -471,8 +506,6 @@ function toolchain(_buildDir, _libDir)
|
||||
objdir (path.join(_buildDir, "win64_mingw-gcc/obj"))
|
||||
libdirs {
|
||||
path.join(_libDir, "lib/win64_mingw-gcc"),
|
||||
"$(DXSDK_DIR)/lib/x64",
|
||||
"$(GLES_X64_DIR)",
|
||||
}
|
||||
buildoptions { "-m64" }
|
||||
|
||||
@ -492,7 +525,6 @@ function toolchain(_buildDir, _libDir)
|
||||
objdir (path.join(_buildDir, "win32_mingw-clang/obj"))
|
||||
libdirs {
|
||||
path.join(_libDir, "lib/win32_mingw-clang"),
|
||||
"$(DXSDK_DIR)/lib/x86",
|
||||
}
|
||||
buildoptions { "-m32" }
|
||||
|
||||
@ -501,8 +533,6 @@ function toolchain(_buildDir, _libDir)
|
||||
objdir (path.join(_buildDir, "win64_mingw-clang/obj"))
|
||||
libdirs {
|
||||
path.join(_libDir, "lib/win64_mingw-clang"),
|
||||
"$(DXSDK_DIR)/lib/x64",
|
||||
"$(GLES_X64_DIR)",
|
||||
}
|
||||
buildoptions { "-m64" }
|
||||
|
||||
@ -521,12 +551,12 @@ function toolchain(_buildDir, _libDir)
|
||||
-- "ubsan",
|
||||
}
|
||||
|
||||
configuration { "linux-g*" }
|
||||
configuration { "linux-gcc" }
|
||||
buildoptions {
|
||||
"-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
|
||||
"-mfpmath=sse",
|
||||
}
|
||||
|
||||
configuration { "linux-*" }
|
||||
configuration { "linux-gcc or linux-clang" }
|
||||
buildoptions {
|
||||
"-msse2",
|
||||
"-Wunused-value",
|
||||
@ -543,7 +573,7 @@ function toolchain(_buildDir, _libDir)
|
||||
"-Wl,--gc-sections",
|
||||
}
|
||||
|
||||
configuration { "linux-g*", "x32" }
|
||||
configuration { "linux-gcc*", "x32" }
|
||||
targetdir (path.join(_buildDir, "linux32_gcc/bin"))
|
||||
objdir (path.join(_buildDir, "linux32_gcc/obj"))
|
||||
libdirs { path.join(_libDir, "lib/linux32_gcc") }
|
||||
@ -551,7 +581,7 @@ function toolchain(_buildDir, _libDir)
|
||||
"-m32",
|
||||
}
|
||||
|
||||
configuration { "linux-g*", "x64" }
|
||||
configuration { "linux-gcc*", "x64" }
|
||||
targetdir (path.join(_buildDir, "linux64_gcc/bin"))
|
||||
objdir (path.join(_buildDir, "linux64_gcc/obj"))
|
||||
libdirs { path.join(_libDir, "lib/linux64_gcc") }
|
||||
@ -575,6 +605,44 @@ function toolchain(_buildDir, _libDir)
|
||||
"-m64",
|
||||
}
|
||||
|
||||
configuration { "linux-mips-gcc" }
|
||||
targetdir (path.join(_buildDir, "linux32_mips_gcc/bin"))
|
||||
objdir (path.join(_buildDir, "linux32_mips_gcc/obj"))
|
||||
libdirs { path.join(_libDir, "lib/linux32_mips_gcc") }
|
||||
buildoptions {
|
||||
"-Wunused-value",
|
||||
"-Wundef",
|
||||
}
|
||||
buildoptions_cpp {
|
||||
"-std=c++0x",
|
||||
}
|
||||
links {
|
||||
"rt",
|
||||
"dl",
|
||||
}
|
||||
linkoptions {
|
||||
"-Wl,--gc-sections",
|
||||
}
|
||||
|
||||
configuration { "linux-arm-gcc" }
|
||||
targetdir (path.join(_buildDir, "linux32_arm_gcc/bin"))
|
||||
objdir (path.join(_buildDir, "linux32_arm_gcc/obj"))
|
||||
libdirs { path.join(_libDir, "lib/linux32_arm_gcc") }
|
||||
buildoptions {
|
||||
"-Wunused-value",
|
||||
"-Wundef",
|
||||
}
|
||||
buildoptions_cpp {
|
||||
"-std=c++0x",
|
||||
}
|
||||
links {
|
||||
"rt",
|
||||
"dl",
|
||||
}
|
||||
linkoptions {
|
||||
"-Wl,--gc-sections",
|
||||
}
|
||||
|
||||
configuration { "android-*" }
|
||||
flags {
|
||||
"NoImportLib",
|
||||
@ -837,6 +905,10 @@ function toolchain(_buildDir, _libDir)
|
||||
}
|
||||
includedirs { path.join(bxDir, "include/compat/ios") }
|
||||
|
||||
configuration { "xcode4", "ios*" }
|
||||
targetdir (path.join(_buildDir, "ios-arm/bin"))
|
||||
objdir (path.join(_buildDir, "ios-arm/obj"))
|
||||
|
||||
configuration { "ios-arm" }
|
||||
targetdir (path.join(_buildDir, "ios-arm/bin"))
|
||||
objdir (path.join(_buildDir, "ios-arm/obj"))
|
||||
@ -873,6 +945,57 @@ function toolchain(_buildDir, _libDir)
|
||||
"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
|
||||
}
|
||||
|
||||
configuration { "tvos*" }
|
||||
linkoptions {
|
||||
"-lc++",
|
||||
}
|
||||
buildoptions {
|
||||
"-Wfatal-errors",
|
||||
"-Wunused-value",
|
||||
"-Wundef",
|
||||
}
|
||||
includedirs { path.join(bxDir, "include/compat/ios") }
|
||||
|
||||
configuration { "xcode4", "tvos*" }
|
||||
targetdir (path.join(_buildDir, "tvos-arm64/bin"))
|
||||
objdir (path.join(_buildDir, "tvos-arm64/obj"))
|
||||
|
||||
configuration { "tvos-arm64" }
|
||||
targetdir (path.join(_buildDir, "tvos-arm64/bin"))
|
||||
objdir (path.join(_buildDir, "tvos-arm64/obj"))
|
||||
libdirs { path.join(_libDir, "lib/tvos-arm64") }
|
||||
linkoptions {
|
||||
"-mtvos-version-min=9.0",
|
||||
"-arch arm64",
|
||||
"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
|
||||
"-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/usr/lib/system",
|
||||
"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
|
||||
"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
|
||||
}
|
||||
buildoptions {
|
||||
"-mtvos-version-min=9.0",
|
||||
"-arch arm64",
|
||||
"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
|
||||
}
|
||||
|
||||
configuration { "tvos-simulator" }
|
||||
targetdir (path.join(_buildDir, "tvos-simulator/bin"))
|
||||
objdir (path.join(_buildDir, "tvos-simulator/obj"))
|
||||
libdirs { path.join(_libDir, "lib/tvos-simulator") }
|
||||
linkoptions {
|
||||
"-mtvos-simulator-version-min=9.0",
|
||||
"-arch i386",
|
||||
"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
|
||||
"-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/usr/lib/system",
|
||||
"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
|
||||
"-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
|
||||
}
|
||||
buildoptions {
|
||||
"-mtvos-simulator-version-min=9.0",
|
||||
"-arch i386",
|
||||
"--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
|
||||
}
|
||||
|
||||
configuration { "ps4" }
|
||||
targetdir (path.join(_buildDir, "ps4/bin"))
|
||||
objdir (path.join(_buildDir, "ps4/obj"))
|
||||
|
BIN
3rdparty/bx/tools/bin/darwin/genie
vendored
BIN
3rdparty/bx/tools/bin/darwin/genie
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/linux/genie
vendored
BIN
3rdparty/bx/tools/bin/linux/genie
vendored
Binary file not shown.
BIN
3rdparty/bx/tools/bin/windows/genie.exe
vendored
BIN
3rdparty/bx/tools/bin/windows/genie.exe
vendored
Binary file not shown.
Loading…
Reference in New Issue
Block a user