Fix build issues on ARM. Patch by Josh. Fixes #2049.

This was SVN commit r13634.
This commit is contained in:
alpha123 2013-08-07 05:00:46 +00:00
parent dc722d76f3
commit 93abbae435
2 changed files with 23 additions and 32 deletions

View File

@ -26,7 +26,7 @@ rootdir = "../.."
dofile("extern_libs4.lua")
-- detect CPU architecture (simplistic, currently only supports x86 and amd64)
-- detect CPU architecture (simplistic, currently only supports x86, amd64 and ARM)
arch = "x86"
if _OPTIONS["android"] then
arch = "arm"
@ -47,6 +47,8 @@ else
arch = "amd64"
elseif string.find(machine, "i.86") == 1 then
arch = "x86"
elseif string.find(machine, "arm") == 1 then
arch = "arm"
else
print("WARNING: Cannot determine architecture from GCC, assuming x86")
end
@ -262,9 +264,13 @@ function project_set_build_flags()
if arch == "arm" then
-- disable warnings about va_list ABI change
buildoptions { "-Wno-psabi" }
-- target Cortex-A9 CPUs with NEON
buildoptions { "-mthumb -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp" }
if _OPTIONS["android"] then
-- target generic arm CPUs with NEON
buildoptions { "-mtune=generic-arm -mfpu=neon -mfloat-abi=softfp" }
else
-- target Cortex-A15 CPUs with NEON
buildoptions { "-mtune=cortex-a15 -mfpu=neon-vfpv4 -mfloat-abi=hard" }
end
end
if _OPTIONS["coverage"] then

View File

@ -25,40 +25,25 @@
*/
#include "precompiled.h"
#include "lib/sysdep/cpu.h"
#include <android/log.h>
intptr_t cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment)
{
return __sync_fetch_and_add(location, increment);
#include "lib/sysdep/cpu.h"
intptr_t cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment)
{
return __sync_fetch_and_add(location, increment);
}
bool cpu_CAS(volatile intptr_t* location, intptr_t expected, intptr_t newValue)
{
return __sync_bool_compare_and_swap(location, expected, newValue);
}
bool cpu_CAS64(volatile i64* location, i64 expected, i64 newValue)
{
// Current versions of GCC don't implement this on ARM:
// return __sync_bool_compare_and_swap(location, expected, newValue);
// http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=40fb79c8a88625504857d44de1bc89dc0341e618
// adds support for
// return __kernel_cmpxchg64(&expected, &newValue, (long long*)location) == 0;
// but only for Linux kernel 3.1
// Maybe we can do it with user-space assembly assuming a modern-enough CPU?
// That sounds non-trivial so let's just cheat
#warning TODO: atomic cpu_CAS64 on ARM
if (*location != expected)
return false;
*location = newValue;
return true;
}
const char* cpu_IdentifierString()
bool cpu_CAS64(volatile i64* location, i64 expected, i64 newValue)
{
return __sync_bool_compare_and_swap(location, expected, newValue);
}
const char* cpu_IdentifierString()
{
return "unknown"; // TODO
}