Fix OS X build errors

This was SVN commit r8684.
This commit is contained in:
Ykkrosh 2010-11-23 19:20:03 +00:00
parent 5672275298
commit 94dca529b1
2 changed files with 35 additions and 0 deletions

View File

@ -216,6 +216,12 @@ function package_set_build_flags()
if arch == "x86" then
tinsert(package.buildoptions, "-march=i686")
end
-- We don't want to require SSE2 everywhere yet, but OS X headers do
-- require it (and Intel Macs always have it) so enable it here
if OS == "macosx" then
tinsert(package.buildoptions, "-msse2")
end
end
tinsert(package.buildoptions, {

View File

@ -174,6 +174,35 @@ intptr_t cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment)
return _InterlockedExchangeAdd((P32)location, increment);
}
#elif OS_MACOSX
#include <libkern/OSAtomic.h>
#if ARCH_IA32
intptr_t cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment)
{
cassert(sizeof(intptr_t) == sizeof(int32_t));
return OSAtomicAdd32Barrier(increment, (volatile int32_t*)location);
}
#else
intptr_t cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment)
{
cassert(sizeof(intptr_t) == sizeof(int64_t));
return OSAtomicAdd64Barrier(increment, (volatile int64_t*)location);
}
#endif
bool cpu_CAS(volatile intptr_t* location, intptr_t expected, intptr_t newValue)
{
cassert(sizeof(intptr_t) == sizeof(void*));
return OSAtomicCompareAndSwapPtrBarrier((void*)expected, (void*)newValue, (void* volatile*)location);
}
bool cpu_CAS64(volatile i64* location, i64 expected, i64 newValue)
{
return OSAtomicCompareAndSwap64Barrier(expected, newValue, location);
}
#elif GCC_VERSION
intptr_t cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment)