Make sure the memory barrier functions are always available, and now they are implemented on Android __ARM_ARCH_5TE__
authorSam Lantinga <slouken@libsdl.org>
Fri, 10 Feb 2017 11:21:15 -0800
changeset 10879773cbb61ad27
parent 10878 7fa08228d9e3
child 10880 5a77f977ad95
Make sure the memory barrier functions are always available, and now they are implemented on Android __ARM_ARCH_5TE__
Android.mk
include/SDL_atomic.h
src/atomic/SDL_atomic.c
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
     1.1 --- a/Android.mk	Fri Feb 10 09:41:16 2017 -0800
     1.2 +++ b/Android.mk	Fri Feb 10 11:21:15 2017 -0800
     1.3 @@ -20,7 +20,7 @@
     1.4  	$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
     1.5  	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
     1.6  	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
     1.7 -	$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
     1.8 +	$(LOCAL_PATH)/src/atomic/SDL_atomic.c.arm \
     1.9  	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
    1.10  	$(wildcard $(LOCAL_PATH)/src/core/android/*.c) \
    1.11  	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
     2.1 --- a/include/SDL_atomic.h	Fri Feb 10 09:41:16 2017 -0800
     2.2 +++ b/include/SDL_atomic.h	Fri Feb 10 11:21:15 2017 -0800
     2.3 @@ -149,6 +149,9 @@
     2.4   * For more information on these semantics, take a look at the blog post:
     2.5   * http://preshing.com/20120913/acquire-and-release-semantics
     2.6   */
     2.7 +extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void);
     2.8 +extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
     2.9 +
    2.10  #if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
    2.11  #define SDL_MemoryBarrierRelease()   __asm__ __volatile__ ("lwsync" : : : "memory")
    2.12  #define SDL_MemoryBarrierAcquire()   __asm__ __volatile__ ("lwsync" : : : "memory")
    2.13 @@ -156,11 +159,11 @@
    2.14  #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
    2.15  #define SDL_MemoryBarrierRelease()   __asm__ __volatile__ ("dmb ish" : : : "memory")
    2.16  #define SDL_MemoryBarrierAcquire()   __asm__ __volatile__ ("dmb ish" : : : "memory")
    2.17 -#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
    2.18 +#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__)
    2.19  #ifdef __thumb__
    2.20  /* The mcr instruction isn't available in thumb mode, use real functions */
    2.21 -extern DECLSPEC void SDLCALL SDL_MemoryBarrierRelease(void);
    2.22 -extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquire(void);
    2.23 +#define SDL_MemoryBarrierRelease()   SDL_MemoryBarrierReleaseFunction()
    2.24 +#define SDL_MemoryBarrierAcquire()   SDL_MemoryBarrierAcquireFunction()
    2.25  #else
    2.26  #define SDL_MemoryBarrierRelease()   __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
    2.27  #define SDL_MemoryBarrierAcquire()   __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory")
     3.1 --- a/src/atomic/SDL_atomic.c	Fri Feb 10 09:41:16 2017 -0800
     3.2 +++ b/src/atomic/SDL_atomic.c	Fri Feb 10 11:21:15 2017 -0800
     3.3 @@ -228,19 +228,16 @@
     3.4      return value;
     3.5  }
     3.6  
     3.7 -#ifdef __thumb__
     3.8 -#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
     3.9 -__asm__(
    3.10 -"   .align 2\n"
    3.11 -"   .globl _SDL_MemoryBarrierRelease\n"
    3.12 -"   .globl _SDL_MemoryBarrierAcquire\n"
    3.13 -"_SDL_MemoryBarrierRelease:\n"
    3.14 -"_SDL_MemoryBarrierAcquire:\n"
    3.15 -"   mov r0, #0\n"
    3.16 -"   mcr p15, 0, r0, c7, c10, 5\n"
    3.17 -"   bx lr\n"
    3.18 -);
    3.19 -#endif
    3.20 -#endif
    3.21 +void
    3.22 +SDL_MemoryBarrierReleaseFunction(void)
    3.23 +{
    3.24 +    SDL_MemoryBarrierRelease();
    3.25 +}
    3.26 +
    3.27 +void
    3.28 +SDL_MemoryBarrierAcquireFunction(void)
    3.29 +{
    3.30 +    SDL_MemoryBarrierAcquire();
    3.31 +}
    3.32  
    3.33  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Fri Feb 10 09:41:16 2017 -0800
     4.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Fri Feb 10 11:21:15 2017 -0800
     4.3 @@ -27,12 +27,6 @@
     4.4  #error You should not be here.
     4.5  #endif
     4.6  
     4.7 -/* so annoying. */
     4.8 -#if defined(__thumb__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__))
     4.9 -#define SDL_MemoryBarrierRelease SDL_MemoryBarrierRelease_REAL
    4.10 -#define SDL_MemoryBarrierAcquire SDL_MemoryBarrierAcquire_REAL
    4.11 -#endif
    4.12 -
    4.13  #define SDL_SetError SDL_SetError_REAL
    4.14  #define SDL_Log SDL_Log_REAL
    4.15  #define SDL_LogVerbose SDL_LogVerbose_REAL
    4.16 @@ -627,3 +621,5 @@
    4.17  #define SDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState_REAL
    4.18  #define SDL_JoystickGetDeviceType SDL_JoystickGetDeviceType_REAL
    4.19  #define SDL_JoystickGetType SDL_JoystickGetType_REAL
    4.20 +#define SDL_MemoryBarrierReleaseFunction SDL_MemoryBarrierReleaseFunction_REAL
    4.21 +#define SDL_MemoryBarrierAcquireFunction SDL_MemoryBarrierAcquireFunction_REAL
     5.1 --- a/src/dynapi/SDL_dynapi_procs.h	Fri Feb 10 09:41:16 2017 -0800
     5.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Fri Feb 10 11:21:15 2017 -0800
     5.3 @@ -60,12 +60,6 @@
     5.4  SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(void *a, SDL_bool b),(a,b),return)
     5.5  #endif
     5.6  
     5.7 -/* so annoying. */
     5.8 -#if defined(__thumb__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__))
     5.9 -SDL_DYNAPI_PROC(void,SDL_MemoryBarrierRelease,(void),(),)
    5.10 -SDL_DYNAPI_PROC(void,SDL_MemoryBarrierAcquire,(void),(),)
    5.11 -#endif
    5.12 -
    5.13  #ifdef __WIN32__
    5.14  SDL_DYNAPI_PROC(int,SDL_RegisterApp,(char *a, Uint32 b, void *c),(a,b,c),return)
    5.15  SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),)
    5.16 @@ -659,3 +653,5 @@
    5.17  SDL_DYNAPI_PROC(SDL_bool,SDL_JoystickGetAxisInitialState,(SDL_Joystick *a, int b, Sint16 *c),(a,b,c),return)
    5.18  SDL_DYNAPI_PROC(SDL_JoystickType,SDL_JoystickGetDeviceType,(int a),(a),return)
    5.19  SDL_DYNAPI_PROC(SDL_JoystickType,SDL_JoystickGetType,(SDL_Joystick *a),(a),return)
    5.20 +SDL_DYNAPI_PROC(void,SDL_MemoryBarrierReleaseFunction,(void),(),)
    5.21 +SDL_DYNAPI_PROC(void,SDL_MemoryBarrierAcquireFunction,(void),(),)