diff --git a/source/lib/bits.h b/source/lib/bits.h index 92a5afb27e..dd1ac9b54c 100644 --- a/source/lib/bits.h +++ b/source/lib/bits.h @@ -51,7 +51,7 @@ T bit_mask(size_t numBits) // note: the perhaps more intuitive (1 << numBits)-1 cannot // handle numBits == bitsInT, but this implementation does. const T bitsInT = sizeof(T)*CHAR_BIT; - T mask = ~T(0); + T mask = T(~0); mask >>= T(bitsInT-numBits); return mask; } @@ -111,7 +111,8 @@ bool is_pow2(T n) * ceil(log2(x)) * * @param x (unsigned integer) - * @return ceiling of the base-2 logarithm (i.e. rounded up). + * @return ceiling of the base-2 logarithm (i.e. rounded up) or + * zero if the input is zero. **/ template size_t ceil_log2(T x) diff --git a/source/lib/sysdep/cpu.h b/source/lib/sysdep/cpu.h index 30e8d9a5ae..6dffc2a831 100644 --- a/source/lib/sysdep/cpu.h +++ b/source/lib/sysdep/cpu.h @@ -64,11 +64,6 @@ LIB_API void cpu_AtomicAdd(volatile intptr_t* location, intptr_t increment); **/ LIB_API void cpu_Serialize(); -/** - * enforce strong memory ordering. - **/ -LIB_API void cpu_MemoryFence(); - //----------------------------------------------------------------------------- // misc diff --git a/source/lib/sysdep/win/wdbg_heap.cpp b/source/lib/sysdep/win/wdbg_heap.cpp index 9c27fe8eec..7bd640d646 100644 --- a/source/lib/sysdep/win/wdbg_heap.cpp +++ b/source/lib/sysdep/win/wdbg_heap.cpp @@ -823,7 +823,7 @@ static void PrintCallStack(const uintptr_t* callers, size_t numCallers) } } - +#ifndef NDEBUG static int __cdecl ReportHook(int reportType, char* message, int* out) { UNUSED2(reportType); @@ -886,6 +886,7 @@ static int __cdecl ReportHook(int reportType, char* message, int* out) wdbg_assert(0); // unreachable return 0; } +#endif //----------------------------------------------------------------------------- diff --git a/source/lib/sysdep/x86_x64/x86_x64.cpp b/source/lib/sysdep/x86_x64/x86_x64.cpp index c307b1b2bf..aa16ffdb9a 100644 --- a/source/lib/sysdep/x86_x64/x86_x64.cpp +++ b/source/lib/sysdep/x86_x64/x86_x64.cpp @@ -509,14 +509,6 @@ void x86_x64_DebugBreak() } -// enforce strong memory ordering. -void cpu_MemoryFence() -{ - if(x86_x64_cap(X86_X64_CAP_SSE2)) - _mm_mfence(); -} - - void cpu_Serialize() { x86_x64_CpuidRegs regs; diff --git a/source/lib/tests/test_bits.h b/source/lib/tests/test_bits.h index 27e65d2d0a..332a8c63de 100644 --- a/source/lib/tests/test_bits.h +++ b/source/lib/tests/test_bits.h @@ -33,9 +33,9 @@ public: void test_round_up_to_pow2() { TS_ASSERT_EQUALS(round_up_to_pow2(0u), 1u); - TS_ASSERT_EQUALS(round_up_to_pow2(1u), 2u); + TS_ASSERT_EQUALS(round_up_to_pow2(1u), 1u); TS_ASSERT_EQUALS(round_up_to_pow2(127u), 128u); - TS_ASSERT_EQUALS(round_up_to_pow2(128u), 256u); + TS_ASSERT_EQUALS(round_up_to_pow2(128u), 128u); TS_ASSERT_EQUALS(round_up_to_pow2(129u), 256u); } diff --git a/source/renderer/TerrainOverlay.h b/source/renderer/TerrainOverlay.h index 2d0d3c507f..87707bfbb2 100644 --- a/source/renderer/TerrainOverlay.h +++ b/source/renderer/TerrainOverlay.h @@ -10,12 +10,12 @@ #ifndef INCLUDED_TERRAINOVERLAY #define INCLUDED_TERRAINOVERLAY -class CColor; +struct CColor; class CTerrain; /** * Base class for (relatively) simple drawing of - * data onto terrain tiles, ssize_tended for debugging purposes and for the Atlas + * data onto terrain tiles, intended for debugging purposes and for the Atlas * editor (hence not trying to be very efficient). *

* To start drawing a terrain overlay, first create a subclass of TerrainOverlay.