@@ -416,7 +416,9 @@ static SDL_INLINE void BG_Blended_Color(const TTF_Image *image, Uint32 *destinat
416
416
while (height -- ) {
417
417
/* *INDENT-OFF* */
418
418
DUFFS_LOOP4 (
419
- tmp = * src ++ ;
419
+ /* prevent misaligned load: tmp = *src++; */
420
+ /* eventually, we can expect the compiler to replace the memcpy call with something optimized */
421
+ memcpy (& tmp , src ++ , sizeof (tmp )); /* This should NOT be SDL_memcpy */
420
422
alpha = tmp >> 24 ;
421
423
tmp &= ~0xFF000000 ;
422
424
alpha = fg_alpha * alpha ;
@@ -451,7 +453,8 @@ static SDL_INLINE void BG_Blended_LCD(const TTF_Image *image, Uint32 *destinatio
451
453
while (height -- ) {
452
454
/* *INDENT-OFF* */
453
455
DUFFS_LOOP4 (
454
- tmp = * src ++ ;
456
+ /* prevent misaligned load: tmp = *src++; */
457
+ memcpy (& tmp , src ++ , sizeof (tmp )); /* This should NOT be SDL_memcpy */
455
458
456
459
if (tmp ) {
457
460
bg = * dst ;
@@ -908,11 +911,14 @@ static SDL_INLINE void BG_64(const TTF_Image *image, Uint8 *destination, Sint32
908
911
Uint64 * dst = (Uint64 * )destination ;
909
912
Uint32 width = image -> width / 8 ;
910
913
Uint32 height = image -> rows ;
914
+ Uint64 tmp ;
911
915
912
916
while (height -- ) {
913
917
/* *INDENT-OFF* */
914
918
DUFFS_LOOP4 (
915
- * dst ++ |= * src ++ ;
919
+ /* prevent misaligned load: *dst++ |= *src++; */
920
+ memcpy (& tmp , src ++ , sizeof (tmp )); /* This should NOT be SDL_memcpy */
921
+ * dst ++ |= tmp ;
916
922
, width );
917
923
/* *INDENT-ON* */
918
924
src = (const Uint64 * )((const Uint8 * )src + srcskip );
@@ -926,11 +932,14 @@ static SDL_INLINE void BG_32(const TTF_Image *image, Uint8 *destination, Sint32
926
932
Uint32 * dst = (Uint32 * )destination ;
927
933
Uint32 width = image -> width / 4 ;
928
934
Uint32 height = image -> rows ;
935
+ Uint32 tmp ;
929
936
930
937
while (height -- ) {
931
938
/* *INDENT-OFF* */
932
939
DUFFS_LOOP4 (
933
- * dst ++ |= * src ++ ;
940
+ /* prevent misaligned load: *dst++ |= *src++; */
941
+ memcpy (& tmp , src ++ , sizeof (tmp )); /* This should NOT be SDL_memcpy */
942
+ * dst ++ |= tmp ;
934
943
, width );
935
944
/* *INDENT-ON* */
936
945
src = (const Uint32 * )((const Uint8 * )src + srcskip );
0 commit comments