From d526b8a1e9b09371a32c0ebb159de094143d7ba7 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 2 Mar 2017 13:33:04 -0500 Subject: [PATCH] Some patches to make SDL compile with armcc (ARM's C compiler). --- include/begin_code.h | 2 +- src/SDL.c | 4 ++-- src/SDL_internal.h | 2 +- src/audio/SDL_audiocvt.c | 5 ++++- src/video/SDL_shape.c | 8 +++++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/begin_code.h b/include/begin_code.h index d2d45f7e1f54f..444068fda49f5 100644 --- a/include/begin_code.h +++ b/include/begin_code.h @@ -111,7 +111,7 @@ #elif defined(_MSC_VER) || defined(__BORLANDC__) || \ defined(__DMC__) || defined(__SC__) || \ defined(__WATCOMC__) || defined(__LCC__) || \ - defined(__DECC) + defined(__DECC) || defined(__CC_ARM) #define SDL_INLINE __inline #ifndef __inline__ #define __inline__ __inline diff --git a/src/SDL.c b/src/SDL.c index bcfc8e00bf8fa..0ed49a261978a 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -78,7 +78,7 @@ SDL_PrivateShouldInitSubsystem(Uint32 subsystem) { int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255); - return (SDL_SubsystemRefCount[subsystem_index] == 0); + return (SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE; } /* Private helper to check if a system needs to be quit. */ @@ -92,7 +92,7 @@ SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) { /* If we're in SDL_Quit, we shut down every subsystem, even if refcount * isn't zero. */ - return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit; + return (SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE; } void diff --git a/src/SDL_internal.h b/src/SDL_internal.h index 0669275e496be..654895cbe2055 100644 --- a/src/SDL_internal.h +++ b/src/SDL_internal.h @@ -29,7 +29,7 @@ /* This is for a variable-length array at the end of a struct: struct x { int y; char z[SDL_VARIABLE_LENGTH_ARRAY]; }; Use this because GCC 2 needs different magic than other compilers. */ -#if (defined(__GNUC__) && (__GNUC__ <= 2)) +#if (defined(__GNUC__) && (__GNUC__ <= 2)) || defined(__CC_ARM) #define SDL_VARIABLE_LENGTH_ARRAY 1 #else #define SDL_VARIABLE_LENGTH_ARRAY diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 691fb39f9530a..41ad345812c62 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -439,7 +439,10 @@ SDL_ResampleCVT_si16_c2(SDL_AudioCVT *cvt, SDL_AudioFormat format) const int srclen = cvt->len_cvt; Sint16 *dst = (Sint16 *) cvt->buf; const int dstlen = (cvt->len * cvt->len_mult); - Sint16 state[2] = { src[0], src[1] }; + Sint16 state[2]; + + state[0] = src[0]; + state[1] = src[1]; SDL_assert(format == AUDIO_S16SYS); diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index d2c3af4dbc65b..799266bdfafc3 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -206,8 +206,14 @@ RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rec SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shape) { - SDL_Rect dimensions = {0,0,shape->w,shape->h}; + SDL_Rect dimensions; SDL_ShapeTree* result = NULL; + + dimensions.x = 0; + dimensions.y = 0; + dimensions.w = shape->w; + dimensions.h = shape->h; + if(SDL_MUSTLOCK(shape)) SDL_LockSurface(shape); result = RecursivelyCalculateShapeTree(mode,shape,dimensions);