-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARM64 implements SDL_Swap16/32 #3943
Comments
@devnexen: I have a bug report at de4me/SDL-1.2-xcode@d750278
|
Or, should we just remove the aarch64 asm now that we handle things using |
Well, I believe the safest way is removing the aarch64 asm. This one is for SDL2 - suggest for 2.0.18: diff --git a/include/SDL_endian.h b/include/SDL_endian.h
index 3306003..4ff7e03 100644
--- a/include/SDL_endian.h
+++ b/include/SDL_endian.h
@@ -135,13 +135,6 @@ SDL_Swap16(Uint16 x)
__asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x));
return (Uint16)result;
}
-#elif defined(__aarch64__)
-SDL_FORCE_INLINE Uint16
-SDL_Swap16(Uint16 x)
-{
- __asm__("rev16 %w1, %w0" : "=r"(x) : "r"(x));
- return x;
-}
#elif (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x)
@@ -193,13 +186,6 @@ SDL_Swap32(Uint32 x)
__asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x));
return result;
}
-#elif defined(__aarch64__)
-SDL_FORCE_INLINE Uint32
-SDL_Swap32(Uint32 x)
-{
- __asm__("rev %w1, %w0": "=r"(x):"r"(x));
- return x;
-}
#elif (defined(__m68k__) && !defined(__mcoldfire__))
SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) And this one is for SDL-1.2, and considering aarch64 is new enough all of diff --git a/include/SDL_endian.h b/include/SDL_endian.h
index 72f257b..9b11987 100644
--- a/include/SDL_endian.h
+++ b/include/SDL_endian.h
@@ -94,16 +94,10 @@ static __inline__ Uint16 SDL_Swap16(Uint16 x)
__asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x));
return (Uint16)result;
}
-#elif defined(__APPLE__) && defined(__aarch64__)
-static __inline__ Uint16 SDL_Swap16(Uint16 x)
-{
- return __builtin_bswap16(x);
-}
#elif defined(__GNUC__) && defined(__aarch64__)
static __inline__ Uint16 SDL_Swap16(Uint16 x)
{
- __asm__("rev16 %w1, %w0" : "=r"(x) : "r"(x));
- return x;
+ return __builtin_bswap16(x);
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
static __inline__ Uint16 SDL_Swap16(Uint16 x)
@@ -146,16 +140,10 @@ static __inline__ Uint32 SDL_Swap32(Uint32 x)
__asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x));
return result;
}
-#elif defined(__APPLE__) && defined(__aarch64__)
-static __inline__ Uint32 SDL_Swap32(Uint32 x)
-{
- return __builtin_bswap32(x);
-}
#elif defined(__GNUC__) && defined(__aarch64__)
static __inline__ Uint32 SDL_Swap32(Uint32 x)
{
- __asm__("rev %w1, %w0": "=r"(x):"r"(x));
- return x;
+ return __builtin_bswap32(x);
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
static __inline__ Uint32 SDL_Swap32(Uint32 x)
@@ -175,7 +163,7 @@ static __inline__ Uint32 SDL_Swap32(Uint32 x) {
}
#endif
-#ifdef SDL_HAS_64BIT_TYPE
+#ifdef SDL_HAS_64BIT_TYPE /**/
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
static __inline__ Uint64 SDL_Swap64(Uint64 x)
@@ -190,7 +178,7 @@ static __inline__ Uint64 SDL_Swap64(Uint64 x)
: "0" (v.s.a), "1" (v.s.b));
return v.u;
}
-#elif defined(__APPLE__) && defined(__aarch64__)
+#elif defined(__GNUC__) && defined(__aarch64__)
static __inline__ Uint64 SDL_Swap64(Uint64 x)
{
return __builtin_bswap64(x); OK to apply? |
It is better if toolchains's builtin are supported indeed, even tough I know better now the m1 specifics vs the common arm64 are still a bit of mistery :) |
Patches applied to SDL-12 and sdl12-compat. Waiting for approval to apply to SDL2. |
Apply this to SDL2, please. |
Done: eb39e20 |
This bug report was migrated from our old Bugzilla tracker.
These attachments are available in the static archive:
diff (patch, text/plain, 2020-12-26 19:33:25 +0000, 1024 bytes)Reported in version: HG 2.1
Reported for operating system, platform: Other, ARM
Comments on the original bug report:
On 2020-12-26 19:33:25 +0000, David Carlier wrote:
On 2020-12-28 04:21:17 +0000, Ozkan Sezer wrote:
On 2020-12-28 04:35:42 +0000, Ozkan Sezer wrote:
On 2020-12-28 05:04:02 +0000, Ozkan Sezer wrote:
On 2020-12-28 06:09:40 +0000, David Carlier wrote:
On 2020-12-28 06:10:01 +0000, David Carlier wrote:
On 2020-12-28 08:55:40 +0000, Ozkan Sezer wrote:
The text was updated successfully, but these errors were encountered: