We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1122

Summary: does not support ldrex
Product: SDL Reporter: Andrey <afletdinov>
Component: atomicAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: ARM   
OS: All   

Description Andrey 2011-02-14 20:46:34 UTC
I build with the mingw32ce, -march=armv4t and got an error:
Error: selected processor does not support `ldrex r2,[r0]'

Here on the page reads:
http://www.keil.com/support/man/docs/armasm/armasm_cihbghef.htm
> ARM LDREX and STREX are available in ARMv6 and above.
Comment 1 Sam Lantinga 2011-02-14 22:37:34 UTC
What's the output of this, replacing gcc with your compiler and architecture flags?
 echo | gcc -E -dM -
Comment 2 Andrey 2011-02-14 22:50:04 UTC
#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define _WIN32 1
#define __CHAR_BIT__ 8
#define __MINGW32CE__ 1
#define __WCHAR_MAX__ 65535U
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __FLT_EVAL_METHOD__ 0
#define UNICODE 1
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __ARMEL__ 1
#define __GNUC_PATCHLEVEL__ 0
#define __ARM_ARCH_4__ 1
#define _stdcall __attribute__((__cdecl__))
#define __DEC64_MAX_EXP__ 385
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
#define __UINTMAX_TYPE__ long long unsigned int
#define __DEC32_EPSILON__ 1E-6DF
#define __LDBL_MAX_EXP__ 1024
#define __SCHAR_MAX__ 127
#define __DBL_DIG__ 15
#define _M_ARM 4
#define _UNICODE 1
#define __SIZEOF_INT__ 4
#define __SIZEOF_POINTER__ 4
#define __USER_LABEL_PREFIX__
#define __STDC_HOSTED__ 1
#define __WIN32 1
#define __LDBL_HAS_INFINITY__ 1
#define __FLT_EPSILON__ 1.19209290e-7F
#define __APCS_32__ 1
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define __DEC32_MAX__ 9.999999E96DF
#define __MINGW32__ 1
#define __SIZEOF_LONG__ 4
#define __DECIMAL_DIG__ 17
#define __LDBL_HAS_QUIET_NAN__ 1
#define __GNUC__ 4
#define _cdecl __attribute__((__cdecl__))
#define __FLT_HAS_DENORM__ 1
#define __SIZEOF_LONG_DOUBLE__ 8
#define __BIGGEST_ALIGNMENT__ 8
#define __UNICODE__ 1
#define __DBL_MAX__ 1.7976931348623157e+308
#define __WINNT 1
#define __DBL_HAS_INFINITY__ 1
#define __WINNT__ 1
#define __DEC32_MIN_EXP__ (-94)
#define _fastcall __attribute__((__cdecl__))
#define __LDBL_HAS_DENORM__ 1
#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
#define __USING_SJLJ_EXCEPTIONS__ 1
#define __DEC32_MIN__ 1E-95DF
#define __DBL_MAX_EXP__ 1024
#define __DEC128_EPSILON__ 1E-33DL
#define __WIN32__ 1
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WINT_T__ 2
#define __GXX_ABI_VERSION 1002
#define __SOFTFP__ 1
#define __FLT_MIN_EXP__ (-125)
#define __DBL_MIN__ 2.2250738585072014e-308
#define __UNDER_CE__ 1
#define __DEC128_MIN__ 1E-6143DL
#define __REGISTER_PREFIX__
#define __DBL_HAS_DENORM__ 1
#define __cdecl __attribute__((__cdecl__))
#define __NO_INLINE__ 1
#define __FLT_MANT_DIG__ 24
#define __VERSION__ "4.4.0"
#define __CEGCC_VERSION__ 1
#define __DEC64_EPSILON__ 1E-15DD
#define __DEC128_MIN_EXP__ (-6142)
#define __SIZE_TYPE__ unsigned int
#define __FLT_RADIX__ 2
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __VFP_FP__ 1
#define __SIZEOF_PTRDIFF_T__ 4
#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
#define UNDER_CE 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 2147483647L
#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
#define __FLT_HAS_INFINITY__ 1
#define __DEC64_MAX__ 9.999999999999999E384DD
#define __CHAR16_TYPE__ short unsigned int
#define __DEC64_MANT_DIG__ 16
#define __DEC32_MAX_EXP__ 97
#define __GXX_MERGED_TYPEINFO_NAMES 0
#define __stdcall __attribute__((__cdecl__))
#define ARM
#define __LDBL_MANT_DIG__ 53
#define __DBL_HAS_QUIET_NAN__ 1
#define __WCHAR_TYPE__ short unsigned int
#define __SIZEOF_FLOAT__ 4
#define __UNDER_CE 1
#define __DEC64_MIN_EXP__ (-382)
#define __FLT_DIG__ 6
#define __INT_MAX__ 2147483647
#define WIN32 1
#define __FLT_MAX_EXP__ 128
#define __DBL_MANT_DIG__ 53
#define __UNICODE 1
#define __DEC64_MIN__ 1E-383DD
#define __WINT_TYPE__ short unsigned int
#define __SIZEOF_SHORT__ 2
#define __LDBL_MIN_EXP__ (-1021)
#define __arm__ 1
#define __LDBL_MAX_10_EXP__ 308
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __SIZEOF_WCHAR_T__ 2
#define __fastcall __attribute__((__cdecl__))
#define __DEC_EVAL_METHOD__ 2
#define __INTMAX_MAX__ 9223372036854775807LL
#define WINNT 1
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __CHAR32_TYPE__ unsigned int
#define __FLT_MAX__ 3.40282347e+38F
#define __SIZEOF_DOUBLE__ 8
#define __FLT_MIN_10_EXP__ (-37)
#define __INTMAX_TYPE__ long long int
#define __COREDLL__ 1
#define __DEC128_MAX_EXP__ 6145
#define __GNUC_MINOR__ 4
#define __DEC32_MANT_DIG__ 7
#define __DBL_MAX_10_EXP__ 308
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __STDC__ 1
#define __PTRDIFF_TYPE__ int
#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
#define __DEC128_MANT_DIG__ 34
#define __LDBL_MIN_10_EXP__ (-307)
#define __SIZEOF_LONG_LONG__ 8
#define __LDBL_DIG__ 15
#define __GNUC_GNU_INLINE__ 1
#define __declspec(x) __attribute__((x))
Comment 3 Sam Lantinga 2011-02-14 23:11:35 UTC
If you edit src/atomic/SDL_spinlock.c and change the line with __ARM_ARCH to:
#elif defined(__GNUC__) && defined(__arm__) && (defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__))

Does that work?
Comment 4 Andrey 2011-02-14 23:23:39 UTC
yes, and got:
error: __need_spinlock_implementation__ undeclared

so... I added a line to  SDL_config.h:
#define SDL_ATOMIC_DISABLED 1

and buld comlete.
Comment 5 Sam Lantinga 2011-02-15 00:22:28 UTC
That's weird because I clearly see the following defined:
__GNUC__, __arm__, __ARM_ARCH_4__

The code with the "swp" assembly should have been compiled.
Comment 6 Sam Lantinga 2011-02-16 03:27:31 UTC
Can you see why the 'swp' assembly code-path isn't being compiled?
Comment 7 Andrey 2011-02-16 16:48:43 UTC
new environment with -march=armv4t

echo | arm-mingw32ce-gcc -march=armv4t -E -dM -
#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define _WIN32 1
#define __CHAR_BIT__ 8
#define __MINGW32CE__ 1
#define __WCHAR_MAX__ 65535U
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __FLT_EVAL_METHOD__ 0
#define UNICODE 1
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __ARMEL__ 1
#define __GNUC_PATCHLEVEL__ 0
#define _stdcall __attribute__((__cdecl__))
#define __DEC64_MAX_EXP__ 385
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
#define __UINTMAX_TYPE__ long long unsigned int
#define __DEC32_EPSILON__ 1E-6DF
#define __LDBL_MAX_EXP__ 1024
#define __SCHAR_MAX__ 127
#define __DBL_DIG__ 15
#define _M_ARM 4
#define _UNICODE 1
#define __SIZEOF_INT__ 4
#define __SIZEOF_POINTER__ 4
#define __USER_LABEL_PREFIX__
#define __STDC_HOSTED__ 1
#define __WIN32 1
#define __LDBL_HAS_INFINITY__ 1
#define __FLT_EPSILON__ 1.19209290e-7F
#define __APCS_32__ 1
#define _M_ARMT 4
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define __DEC32_MAX__ 9.999999E96DF
#define __MINGW32__ 1
#define __SIZEOF_LONG__ 4
#define __DECIMAL_DIG__ 17
#define __LDBL_HAS_QUIET_NAN__ 1
#define __GNUC__ 4
#define _cdecl __attribute__((__cdecl__))
#define __FLT_HAS_DENORM__ 1
#define __SIZEOF_LONG_DOUBLE__ 8
#define __BIGGEST_ALIGNMENT__ 8
#define __UNICODE__ 1
#define __DBL_MAX__ 1.7976931348623157e+308
#define __WINNT 1
#define __DBL_HAS_INFINITY__ 1
#define __WINNT__ 1
#define __DEC32_MIN_EXP__ (-94)
#define _fastcall __attribute__((__cdecl__))
#define __LDBL_HAS_DENORM__ 1
#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
#define __USING_SJLJ_EXCEPTIONS__ 1
#define __DEC32_MIN__ 1E-95DF
#define __DBL_MAX_EXP__ 1024
#define __DEC128_EPSILON__ 1E-33DL
#define __WIN32__ 1
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WINT_T__ 2
#define __GXX_ABI_VERSION 1002
#define __SOFTFP__ 1
#define __FLT_MIN_EXP__ (-125)
#define __DBL_MIN__ 2.2250738585072014e-308
#define __UNDER_CE__ 1
#define __DEC128_MIN__ 1E-6143DL
#define __REGISTER_PREFIX__
#define __DBL_HAS_DENORM__ 1
#define __cdecl __attribute__((__cdecl__))
#define __NO_INLINE__ 1
#define __FLT_MANT_DIG__ 24
#define __VERSION__ "4.4.0"
#define __CEGCC_VERSION__ 1
#define __DEC64_EPSILON__ 1E-15DD
#define __DEC128_MIN_EXP__ (-6142)
#define __SIZE_TYPE__ unsigned int
#define __FLT_RADIX__ 2
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __VFP_FP__ 1
#define __SIZEOF_PTRDIFF_T__ 4
#define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF
#define UNDER_CE 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 2147483647L
#define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL
#define __FLT_HAS_INFINITY__ 1
#define __DEC64_MAX__ 9.999999999999999E384DD
#define __CHAR16_TYPE__ short unsigned int
#define __DEC64_MANT_DIG__ 16
#define __DEC32_MAX_EXP__ 97
#define __GXX_MERGED_TYPEINFO_NAMES 0
#define __stdcall __attribute__((__cdecl__))
#define ARM
#define __LDBL_MANT_DIG__ 53
#define __DBL_HAS_QUIET_NAN__ 1
#define __WCHAR_TYPE__ short unsigned int
#define __SIZEOF_FLOAT__ 4
#define __UNDER_CE 1
#define __DEC64_MIN_EXP__ (-382)
#define __FLT_DIG__ 6
#define __INT_MAX__ 2147483647
#define WIN32 1
#define __FLT_MAX_EXP__ 128
#define __DBL_MANT_DIG__ 53
#define __UNICODE 1
#define __DEC64_MIN__ 1E-383DD
#define __WINT_TYPE__ short unsigned int
#define __SIZEOF_SHORT__ 2
#define __LDBL_MIN_EXP__ (-1021)
#define __arm__ 1
#define __LDBL_MAX_10_EXP__ 308
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __SIZEOF_WCHAR_T__ 2
#define __fastcall __attribute__((__cdecl__))
#define __DEC_EVAL_METHOD__ 2
#define __INTMAX_MAX__ 9223372036854775807LL
#define WINNT 1
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __CHAR32_TYPE__ unsigned int
#define __FLT_MAX__ 3.40282347e+38F
#define __SIZEOF_DOUBLE__ 8
#define __FLT_MIN_10_EXP__ (-37)
#define __INTMAX_TYPE__ long long int
#define __COREDLL__ 1
#define __DEC128_MAX_EXP__ 6145
#define __GNUC_MINOR__ 4
#define __DEC32_MANT_DIG__ 7
#define __DBL_MAX_10_EXP__ 308
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __STDC__ 1
#define __ARM_ARCH_4T__ 1
#define __PTRDIFF_TYPE__ int
#define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD
#define __DEC128_MANT_DIG__ 34
#define __LDBL_MIN_10_EXP__ (-307)
#define __SIZEOF_LONG_LONG__ 8
#define __LDBL_DIG__ 15
#define __GNUC_GNU_INLINE__ 1
#define __declspec(x) __attribute__((x))
Comment 8 Andrey 2011-02-16 16:52:10 UTC
(In reply to comment #6)
> Can you see why the 'swp' assembly code-path isn't being compiled?

'swp' assembly working, with __ARM_ARCH_4T__, thanks you!
Comment 9 Andrey 2011-02-16 17:05:56 UTC
(In reply to comment #8)
> (In reply to comment #6)
> > Can you see why the 'swp' assembly code-path isn't being compiled?
> 
> 'swp' assembly working, with __ARM_ARCH_4T__, thanks you!

'swp' assembly also working with -march=armv4 (__ARM_ARCH_4__)
Comment 10 Sam Lantinga 2011-02-16 17:18:07 UTC
Thanks!  This is fixed in the repository:
http://hg.libsdl.org/SDL/rev/f34a5f9ce9f6