--- lib/builtins/assembly.h.orig 2016-12-08 05:41:07.000000000 +1100 +++ lib/builtins/assembly.h 2020-05-26 10:20:05.499839000 +1000 @@ -44,7 +44,7 @@ #endif #define CONST_SECTION .section .rodata -#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__) +#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__) || defined(__BSDSUniX__) #define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits #else #define NO_EXEC_STACK_DIRECTIVE --- lib/builtins/atomic.c.orig 2016-10-27 12:46:24.000000000 +1100 +++ lib/builtins/atomic.c 2020-05-26 10:22:42.801511000 +1000 @@ -73,6 +73,29 @@ /// locks for atomic operations static Lock locks[SPINLOCK_COUNT] = { [0 ... SPINLOCK_COUNT-1] = {0,1,0} }; +#elif defined(__BSDSUniX__) +#include +#include +#include +#include +typedef struct _usem Lock; +__inline static void unlock(Lock *l) { + __c11_atomic_store((_Atomic(uint32_t)*)&l->_count, 1, __ATOMIC_RELEASE); + __c11_atomic_thread_fence(__ATOMIC_SEQ_CST); + if (l->_has_waiters) + _umtx_op(l, UMTX_OP_SEM_WAKE, 1, 0, 0); +} +__inline static void lock(Lock *l) { + uint32_t old = 1; + while (!__c11_atomic_compare_exchange_weak((_Atomic(uint32_t)*)&l->_count, &old, + 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) { + _umtx_op(l, UMTX_OP_SEM_WAIT, 0, 0, 0); + old = 1; + } +} +/// locks for atomic operations +static Lock locks[SPINLOCK_COUNT] = { [0 ... SPINLOCK_COUNT-1] = {0,1,0} }; + #elif defined(__APPLE__) #include typedef OSSpinLock Lock; --- lib/builtins/clear_cache.c.orig 2016-09-08 08:59:54.000000000 +1000 +++ lib/builtins/clear_cache.c 2020-05-26 10:24:43.217292000 +1000 @@ -23,7 +23,7 @@ uintptr_t GetCurrentProcess(void); #endif -#if (defined(__FreeBSD__) || defined(__Bitrig__)) && defined(__arm__) +#if (defined(__BSDSUniX__) || defined(__FreeBSD__) || defined(__Bitrig__)) && defined(__arm__) #include #include #endif @@ -100,7 +100,7 @@ * so there is nothing to do */ #elif defined(__arm__) && !defined(__APPLE__) - #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__Bitrig__) + #if defined(__BSDSUniX__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__Bitrig__) struct arm_sync_icache_args arg; arg.addr = (uintptr_t)start; --- lib/builtins/int_endianness.h.orig 2015-02-23 20:27:49.000000000 +1100 +++ lib/builtins/int_endianness.h 2020-05-26 10:28:16.976824000 +1000 @@ -48,7 +48,7 @@ /* .. */ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \ - defined(__minix) + defined(__minix) || defined(__BSDSUniX__) #include #if _BYTE_ORDER == _BIG_ENDIAN