Merge pull request #1110 from patrickbabb/master
Updates to target arm64-v8a Android devices
This commit is contained in:
@@ -29,11 +29,30 @@ public:
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
#if defined(__ARM_FEATURE_LSE)
|
||||||
|
// Use LSE atomic instructions if supported
|
||||||
|
#pragma message("LSE feature detected") // This will print a message in your build logs
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
"swp %0, %1, [%2]":
|
"ldaxr %0, [%1];" // Load-Exclusive instruction
|
||||||
"=&r"( r ): // outputs
|
"cbnz %0, 1f;" // If the value is non-zero, the lock is already acquired
|
||||||
"r"( 1 ), "r"( &v_ ): // inputs
|
"stlxr %w0, %2, [%1];" // Store-Exclusive instruction
|
||||||
"memory", "cc" );
|
"cbnz %w0, 1f;" // If the store failed, retry
|
||||||
|
"mov %0, #0;" // Success, zero indicates lock acquired
|
||||||
|
"1:"
|
||||||
|
: "=&r"(r)
|
||||||
|
: "r"(&v_), "r"(1)
|
||||||
|
: "memory", "cc"
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
// Fallback for systems that don't support LSE
|
||||||
|
#pragma message("LSE feature not detected") // This will print a message in your build logs if LSE is not detected
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"swp %0, %1, [%2];" // Swap instruction (used as a fallback)
|
||||||
|
: "=&r"(r) // output constraint
|
||||||
|
: "r"(1), "r"(&v_) // input constraints
|
||||||
|
: "memory", "cc" // clobbered registers
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
return r == 0;
|
return r == 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,11 @@
|
|||||||
claim that you wrote the original software. If you use this software
|
claim that you wrote the original software. If you use this software
|
||||||
in a product, an acknowledgment in the product documentation would be
|
in a product, an acknowledgment in the product documentation would be
|
||||||
appreciated but is not required.
|
appreciated but is not required.
|
||||||
2. Altered source versions must be plainly marked as such, and must not be
|
2. Altered source versions must be plainly marked as such, and must not
|
||||||
misrepresented as being the original software.
|
be misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
|
|
||||||
#include "SDL_atomic.h"
|
#include "SDL_atomic.h"
|
||||||
@@ -30,8 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function is where all the magic happens... */
|
/* This function is where all the magic happens... */
|
||||||
SDL_bool
|
SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
||||||
SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|
||||||
{
|
{
|
||||||
#if SDL_ATOMIC_DISABLED
|
#if SDL_ATOMIC_DISABLED
|
||||||
/* Terrible terrible damage */
|
/* Terrible terrible damage */
|
||||||
@@ -85,13 +85,27 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
return (result == 0);
|
return (result == 0);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Need CPU instructions for spinlock here! */
|
/* Fallback implementation using a standard mutex */
|
||||||
__need_spinlock_implementation__
|
/* You can use SDL_mutex as a fallback if no atomic instructions are available */
|
||||||
|
static SDL_mutex *mutex;
|
||||||
|
if (!mutex) {
|
||||||
|
mutex = SDL_CreateMutex();
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_mutexP(mutex);
|
||||||
|
if (*lock == 0) {
|
||||||
|
*lock = 1;
|
||||||
|
SDL_mutexV(mutex);
|
||||||
|
return SDL_TRUE;
|
||||||
|
} else {
|
||||||
|
SDL_mutexV(mutex);
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SDL_AtomicLock(SDL_SpinLock *lock)
|
||||||
SDL_AtomicLock(SDL_SpinLock *lock)
|
|
||||||
{
|
{
|
||||||
/* FIXME: Should we have an eventual timeout? */
|
/* FIXME: Should we have an eventual timeout? */
|
||||||
while (!SDL_AtomicTryLock(lock)) {
|
while (!SDL_AtomicTryLock(lock)) {
|
||||||
@@ -99,8 +113,7 @@ SDL_AtomicLock(SDL_SpinLock *lock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SDL_AtomicUnlock(SDL_SpinLock *lock)
|
||||||
SDL_AtomicUnlock(SDL_SpinLock *lock)
|
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
_ReadWriteBarrier();
|
_ReadWriteBarrier();
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
APP_PROJECT_PATH := $(call my-dir)/..
|
APP_PROJECT_PATH := $(call my-dir)/..
|
||||||
APP_CPPFLAGS += -frtti -fexceptions
|
APP_CPPFLAGS += -frtti -fexceptions
|
||||||
APP_ABI := armeabi-v7a
|
APP_ABI := arm64-v8a
|
||||||
|
APP_PLATFORM := android-21
|
||||||
|
APP_CFLAGS += -march=armv8.1-a
|
||||||
|
APP_CPPFLAGS += -D__ARM_FEATURE_LSE=1
|
||||||
#APP_ABI := x86 # mainly for emulators
|
#APP_ABI := x86 # mainly for emulators
|
||||||
APP_STL := c++_static
|
APP_STL := c++_static
|
||||||
APP_MODULES := libpng libjpeg main SDL
|
APP_MODULES := libpng libjpeg main SDL
|
||||||
|
|||||||
Reference in New Issue
Block a user