From: <man...@us...> - 2013-04-18 13:42:28
|
Revision: 1905 http://sourceforge.net/p/modplug/code/1905 Author: manxorist Date: 2013-04-18 13:42:21 +0000 (Thu, 18 Apr 2013) Log Message: ----------- [Ref] Use <cstdint> for VS2010 and up. [Ref] Do not assume int8* and char* are implicitely convertible to each other. Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/SampleIO.cpp Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-04-18 01:32:41 UTC (rev 1904) +++ trunk/OpenMPT/common/typedefs.h 2013-04-18 13:42:21 UTC (rev 1905) @@ -86,11 +86,13 @@ #define DEPRECATED #endif + +#if defined(_MSC_VER) && (_MSC_VER <= MSVC_VER_2008) + typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; typedef __int64 int64; - typedef unsigned __int8 uint8; typedef unsigned __int16 uint16; typedef unsigned __int32 uint32; @@ -111,6 +113,37 @@ const uint32 uint32_max = 4294967295; const uint64 uint64_max = 18446744073709551615; +#else + +#include <cstdint> + +typedef std::int8_t int8; +typedef std::int16_t int16; +typedef std::int32_t int32; +typedef std::int64_t int64; +typedef std::uint8_t uint8; +typedef std::uint16_t uint16; +typedef std::uint32_t uint32; +typedef std::uint64_t uint64; + +const int8 int8_min = INT8_MIN; +const int16 int16_min = INT16_MIN; +const int32 int32_min = INT32_MIN; +const int64 int64_min = INT64_MIN; + +const int8 int8_max = INT8_MAX; +const int16 int16_max = INT16_MAX; +const int32 int32_max = INT32_MAX; +const int64 int64_max = INT64_MAX; + +const uint8 uint8_max = UINT8_MAX; +const uint16 uint16_max = UINT16_MAX; +const uint32 uint32_max = UINT32_MAX; +const uint64 uint64_max = UINT64_MAX; + +#endif + + typedef float float32; union FloatInt32 Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-18 01:32:41 UTC (rev 1904) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2013-04-18 13:42:21 UTC (rev 1905) @@ -982,7 +982,7 @@ ///////////////////////////////////////////////////////////////////// // AMS Sample unpacking -void AMSUnpack(const char * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter) +void AMSUnpack(const int8 * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter) //------------------------------------------------------------------------------------------------------------------------ { int8 *tempBuf = new (std::nothrow) int8[destSize]; Modified: trunk/OpenMPT/soundlib/SampleIO.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-04-18 01:32:41 UTC (rev 1904) +++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-04-18 13:42:21 UTC (rev 1905) @@ -18,7 +18,7 @@ // External decompressors -extern void AMSUnpack(const char * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter); +extern void AMSUnpack(const int8 * const source, size_t sourceSize, void * const dest, const size_t destSize, char packCharacter); extern uint16 MDLReadBits(uint32 &bitbuf, uint32 &bitnum, const uint8 *(&ibuf), int8 n); extern int DMFUnpack(LPBYTE psample, const uint8 *ibuf, const uint8 *ibufmax, uint32 maxlen); @@ -299,7 +299,7 @@ LimitMax(sourceSize, file.BytesLeft()); bytesRead = 9 + sourceSize; - AMSUnpack(reinterpret_cast<const char *>(sourceBuf) + 9, sourceSize, sample.pSample, sample.GetSampleSizeInBytes(), packCharacter); + AMSUnpack(reinterpret_cast<const int8 *>(sourceBuf) + 9, sourceSize, sample.pSample, sample.GetSampleSizeInBytes(), packCharacter); } } else if(GetEncoding() == PTM8Dto16 && GetChannelFormat() == mono && GetBitDepth() == 16) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |