From f66cddb11fec416258882b91a933d9de6b6db437 Mon Sep 17 00:00:00 2001 From: planetmaker Date: Fri, 3 Jan 2014 18:43:10 +0000 Subject: [PATCH] Silence uninitialised variable warnings in SSE blitters (openttd r26223) -Codechange: Silence some compile warnings about unititialized variables in the SSE blitters (MJP) (openttd r26248) -Fix (r26223): missed compiler warning (MJP) --- src/blitter/32bpp_anim_sse4.cpp | 9 ++------- src/blitter/32bpp_sse2.cpp | 4 ++++ src/blitter/32bpp_sse4.cpp | 11 ++++------- src/blitter/32bpp_sse4.hpp | 10 ++-------- src/blitter/32bpp_ssse3.cpp | 12 ++++-------- src/stdafx.h | 17 +++++++++++++++++ 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/blitter/32bpp_anim_sse4.cpp b/src/blitter/32bpp_anim_sse4.cpp index 483a6e0ba..5bc63bbb0 100644 --- a/src/blitter/32bpp_anim_sse4.cpp +++ b/src/blitter/32bpp_anim_sse4.cpp @@ -19,10 +19,6 @@ /** Instantiation of the SSE4 32bpp blitter factory. */ static FBlitter_32bppSSE4_Anim iFBlitter_32bppSSE4_Anim; -#if defined(__GNUC__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-variable" -#endif /** * Draws a sprite to a (screen) buffer. It is templated to allow faster operation. * @@ -30,6 +26,7 @@ static FBlitter_32bppSSE4_Anim iFBlitter_32bppSSE4_Anim; * @param bp further blitting parameters * @param zoom zoom level at which we are drawing */ +IGNORE_UNINITIALIZED_WARNING_START template inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) { @@ -332,9 +329,7 @@ bmcr_alpha_blend_single: anim_line += this->anim_buf_width; } } -#if defined(__GNUC__) - #pragma GCC diagnostic pop -#endif +IGNORE_UNINITIALIZED_WARNING_STOP /** * Draws a sprite to a (screen) buffer. Calls adequate templated function. diff --git a/src/blitter/32bpp_sse2.cpp b/src/blitter/32bpp_sse2.cpp index 141721442..be3871eef 100644 --- a/src/blitter/32bpp_sse2.cpp +++ b/src/blitter/32bpp_sse2.cpp @@ -26,6 +26,7 @@ static FBlitter_32bppSSE2 iFBlitter_32bppSSE2; * @param bp further blitting parameters * @param zoom zoom level at which we are drawing */ +IGNORE_UNINITIALIZED_WARNING_START template inline void Blitter_32bppSSE2::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) { @@ -184,6 +185,7 @@ bmcr_alpha_blend_single: dst_line += bp->pitch; } } +IGNORE_UNINITIALIZED_WARNING_STOP /** * Draws a sprite to a (screen) buffer. Calls adequate templated function. @@ -336,6 +338,7 @@ inline Colour Blitter_32bppSSE2::AdjustBrightness(Colour colour, uint8 brightnes return Blitter_32bppSSE2::ReallyAdjustBrightness(colour, brightness); } +IGNORE_UNINITIALIZED_WARNING_START /* static */ Colour Blitter_32bppSSE2::ReallyAdjustBrightness(Colour colour, uint8 brightness) { uint64 c16 = colour.b | (uint64) colour.g << 16 | (uint64) colour.r << 32; @@ -375,5 +378,6 @@ inline Colour Blitter_32bppSSE2::AdjustBrightness(Colour colour, uint8 brightnes ret = _mm_packus_epi16(ret, ret); /* PACKUSWB, saturate and pack. */ return alpha32 | _mm_cvtsi128_si32(ret); } +IGNORE_UNINITIALIZED_WARNING_STOP #endif /* WITH_SSE */ diff --git a/src/blitter/32bpp_sse4.cpp b/src/blitter/32bpp_sse4.cpp index 07ae7858e..316bda2fc 100644 --- a/src/blitter/32bpp_sse4.cpp +++ b/src/blitter/32bpp_sse4.cpp @@ -19,10 +19,6 @@ /** Instantiation of the SSE4 32bpp blitter factory. */ static FBlitter_32bppSSE4 iFBlitter_32bppSSE4; -#if defined(__GNUC__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-variable" -#endif /** * Draws a sprite to a (screen) buffer. It is templated to allow faster operation. * @@ -30,6 +26,7 @@ static FBlitter_32bppSSE4 iFBlitter_32bppSSE4; * @param bp further blitting parameters * @param zoom zoom level at which we are drawing */ +IGNORE_UNINITIALIZED_WARNING_START template inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) { @@ -231,9 +228,7 @@ bmcr_alpha_blend_single: dst_line += bp->pitch; } } -#if defined(__GNUC__) - #pragma GCC diagnostic pop -#endif +IGNORE_UNINITIALIZED_WARNING_STOP /** * Draws a sprite to a (screen) buffer. Calls adequate templated function. @@ -282,6 +277,7 @@ inline Colour Blitter_32bppSSE4::AdjustBrightness(Colour colour, uint8 brightnes return Blitter_32bppSSE4::ReallyAdjustBrightness(colour, brightness); } +IGNORE_UNINITIALIZED_WARNING_START /* static */ Colour Blitter_32bppSSE4::ReallyAdjustBrightness(Colour colour, uint8 brightness) { uint64 c16 = colour.b | (uint64) colour.g << 16 | (uint64) colour.r << 32; @@ -313,5 +309,6 @@ inline Colour Blitter_32bppSSE4::AdjustBrightness(Colour colour, uint8 brightnes ret = _mm_packus_epi16(ret, ret); /* PACKUSWB, saturate and pack. */ return alpha32 | _mm_cvtsi128_si32(ret); } +IGNORE_UNINITIALIZED_WARNING_STOP #endif /* WITH_SSE */ diff --git a/src/blitter/32bpp_sse4.hpp b/src/blitter/32bpp_sse4.hpp index 6545c1692..f3a24fa1e 100644 --- a/src/blitter/32bpp_sse4.hpp +++ b/src/blitter/32bpp_sse4.hpp @@ -22,11 +22,7 @@ #undef INSR32 #define INSR32(val, into, rank) (*(um128i*) &into).m128i = _mm_insert_epi32((*(um128i*) &into).m128i, val, rank) -#if defined(__GNUC__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wuninitialized" - #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif +IGNORE_UNINITIALIZED_WARNING_START #ifdef _SQ64 #undef INSR64 #define INSR64(val, into, rank) (*(um128i*) &into).m128i = _mm_insert_epi64((*(um128i*) &into).m128i, val, rank) @@ -40,9 +36,7 @@ (*(um128i*) &into).m128i = _mm_insert_epi32((*(um128i*) &into).m128i, v.u32.high, (rank)*2 + 1); \ } #endif -#if defined(__GNUC__) - #pragma GCC diagnostic pop -#endif +IGNORE_UNINITIALIZED_WARNING_STOP /** The SSE4 32 bpp blitter (without palette animation). */ class Blitter_32bppSSE4 : public Blitter_32bppSSSE3 { diff --git a/src/blitter/32bpp_ssse3.cpp b/src/blitter/32bpp_ssse3.cpp index ebfc3ce6d..dcd460b3c 100644 --- a/src/blitter/32bpp_ssse3.cpp +++ b/src/blitter/32bpp_ssse3.cpp @@ -19,10 +19,6 @@ /** Instantiation of the SSSE3 32bpp blitter factory. */ static FBlitter_32bppSSSE3 iFBlitter_32bppSSSE3; -#if defined(__GNUC__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-variable" -#endif /** * Draws a sprite to a (screen) buffer. It is templated to allow faster operation. * @@ -30,6 +26,7 @@ static FBlitter_32bppSSSE3 iFBlitter_32bppSSSE3; * @param bp further blitting parameters * @param zoom zoom level at which we are drawing */ +IGNORE_UNINITIALIZED_WARNING_START template inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) { @@ -37,7 +34,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left; int effective_width = bp->width; - /* Find where to start reading in the source sprite */ + /* Find where to start reading in the source sprite. */ const SpriteData * const sd = (const SpriteData *) bp->sprite; const SpriteInfo * const si = &sd->infos[zoom]; const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width; @@ -100,6 +97,7 @@ inline void Blitter_32bppSSSE3::Draw(const Blitter::BlitterParams *bp, ZoomLevel } break; } + case BM_COLOUR_REMAP: { switch (read_mode) { case RM_WITH_MARGIN: { @@ -229,9 +227,7 @@ bmcr_alpha_blend_single: dst_line += bp->pitch; } } -#if defined(__GNUC__) - #pragma GCC diagnostic pop -#endif +IGNORE_UNINITIALIZED_WARNING_STOP /** * Draws a sprite to a (screen) buffer. Calls adequate templated function. diff --git a/src/stdafx.h b/src/stdafx.h index 80f63e38a..067a48760 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -503,4 +503,21 @@ static inline void free(const void *ptr) */ #define MAX_UVALUE(type) ((type)~(type)0) +#if defined(_MSC_VER) && !defined(_DEBUG) + #define IGNORE_UNINITIALIZED_WARNING_START __pragma(warning(push)) __pragma(warning(disable:4700)) + #define IGNORE_UNINITIALIZED_WARNING_STOP __pragma(warning(pop)) +#elif defined(__GNUC__) && !defined(_DEBUG) + #define HELPER0(x) #x + #define HELPER1(x) HELPER0(GCC diagnostic ignored x) + #define HELPER2(y) HELPER1(#y) + #define IGNORE_UNINITIALIZED_WARNING_START \ + _Pragma("GCC diagnostic push") \ + _Pragma(HELPER2(-Wuninitialized)) \ + _Pragma(HELPER2(-Wmaybe-uninitialized)) + #define IGNORE_UNINITIALIZED_WARNING_STOP _Pragma("GCC diagnostic pop") +#else + #define IGNORE_UNINITIALIZED_WARNING_START + #define IGNORE_UNINITIALIZED_WARNING_STOP +#endif + #endif /* STDAFX_H */ -- 2.11.4.GIT