From 1ff067147d698f4c3f9fe45bf772a1e072e0cd82 Mon Sep 17 00:00:00 2001 From: "boudreault.alan@gmail.com" Date: Thu, 17 Jan 2013 18:34:45 +0000 Subject: [PATCH] Fix compilation issues on linux 64 machines --- crnlib/crn_math.h | 11 ++++++++++- crnlib/crnlib.cpp | 3 ++- inc/crn_decomp.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crnlib/crn_math.h b/crnlib/crn_math.h index 5b48f8a..8fb045c 100644 --- a/crnlib/crn_math.h +++ b/crnlib/crn_math.h @@ -56,7 +56,12 @@ namespace crnlib template inline T square(T value) { return value * value; } +#ifdef __GNUC__ + #if CRNLIB_64BIT_POINTERS==0 inline bool is_power_of_2(uint32 x) { return x && ((x & (x - 1U)) == 0U); } + #endif +#endif + inline bool is_power_of_2(uint64 x) { return x && ((x & (x - 1U)) == 0U); } template inline T align_up_value(T x, uint alignment) @@ -79,7 +84,9 @@ namespace crnlib { return align_up_value(x, alignment) - x; } - + +#ifdef __GNUC__ + #if CRNLIB_64BIT_POINTERS==0 // From "Hackers Delight" inline uint32 next_pow2(uint32 val) { @@ -91,6 +98,8 @@ namespace crnlib val |= val >> 1; return val + 1; } + #endif +#endif inline uint64 next_pow2(uint64 val) { diff --git a/crnlib/crnlib.cpp b/crnlib/crnlib.cpp index ac485d0..36ba4fb 100644 --- a/crnlib/crnlib.cpp +++ b/crnlib/crnlib.cpp @@ -52,6 +52,7 @@ namespace crnlib } // namespace crnlib using namespace crnlib; +using crnlib::uint; const char* crn_get_format_string(crn_format fmt) { @@ -456,4 +457,4 @@ bool crn_decompress_block(const void *pSrc_block, crn_uint32 *pDst_pixels_u32, c } return true; -} \ No newline at end of file +} diff --git a/inc/crn_decomp.h b/inc/crn_decomp.h index c1abeb4..073c3ec 100644 --- a/inc/crn_decomp.h +++ b/inc/crn_decomp.h @@ -374,7 +374,7 @@ namespace crnd const uint32 cIntBits = 32U; -#ifdef _WIN64 +#if CRNLIB_64BIT_POINTERS typedef uint64 ptr_bits; #else typedef uint32 ptr_bits;