Browse Source

Renamed some internal functions to avoid name conflicts when some third-party code is #included.

Alex Szpakowski 10 years ago
parent
commit
99acec83c9

+ 3 - 3
src/common/int.h

@@ -45,12 +45,12 @@ typedef uint32_t uint32;
 typedef int64_t int64;
 typedef uint64_t uint64;
 
-static inline uint16 swap16(uint16 x)
+static inline uint16 swapuint16(uint16 x)
 {
 	return (x >> 8) | (x << 8);
 }
 
-static inline uint32 swap32(uint32 x)
+static inline uint32 swapuint32(uint32 x)
 {
 	return ((x & 0x000000FF) << 24) |
 	       ((x & 0x0000FF00) <<  8) |
@@ -58,7 +58,7 @@ static inline uint32 swap32(uint32 x)
 	       ((x & 0xFF000000) >> 24);
 }
 
-static inline uint64 swap64(uint64 x)
+static inline uint64 swapuint64(uint64 x)
 {
 	return ((x << 56) & 0xFF00000000000000ULL) | ((x << 40) & 0x00FF000000000000ULL) |
 	       ((x << 24) & 0x0000FF0000000000ULL) | ((x <<  8) & 0x000000FF00000000ULL) |

+ 3 - 3
src/modules/image/magpie/KTXHandler.cpp

@@ -170,7 +170,7 @@ uint8 *KTXHandler::parse(filesystem::FileData *filedata, std::vector<CompressedI
 	{
 		uint32 *headerArray = (uint32 *) &header.glType;
 		for (int i = 0; i < 12; i++)
-			headerArray[i] = swap32(headerArray[i]);
+			headerArray[i] = swapuint32(headerArray[i]);
 	}
 
 	header.numberOfMipmapLevels = std::max(header.numberOfMipmapLevels, 1u);
@@ -203,7 +203,7 @@ uint8 *KTXHandler::parse(filesystem::FileData *filedata, std::vector<CompressedI
 		uint32 mipsize = *(uint32 *) (filebytes + fileoffset);
 
 		if (header.endianness == KTX_ENDIAN_REF_REV)
-			mipsize = swap32(mipsize);
+			mipsize = swapuint32(mipsize);
 
 		fileoffset += sizeof(uint32);
 
@@ -235,7 +235,7 @@ uint8 *KTXHandler::parse(filesystem::FileData *filedata, std::vector<CompressedI
 		uint32 mipsize = *(uint32 *) (filebytes + fileoffset);
 
 		if (header.endianness == KTX_ENDIAN_REF_REV)
-			mipsize = swap32(mipsize);
+			mipsize = swapuint32(mipsize);
 
 		fileoffset += sizeof(uint32);
 

+ 1 - 1
src/modules/image/magpie/PKMHandler.cpp

@@ -38,7 +38,7 @@ inline uint16 swap16big(uint16 x)
 #ifdef LOVE_BIG_ENDIAN
 	return x;
 #else
-	return swap16(x);
+	return swapuint16(x);
 #endif
 }
 

+ 11 - 11
src/modules/image/magpie/PVRHandler.cpp

@@ -117,7 +117,7 @@ void ConvertPVRHeader(PVRTexHeaderV2 header2, PVRTexHeaderV3 *header3)
 		// All of the struct's members are uint32 values, so we can do this.
 		uint32 *headerArray = (uint32 *) &header2;
 		for (size_t i = 0; i < sizeof(PVRTexHeaderV2) / sizeof(uint32); i++)
-			headerArray[i] = swap32(headerArray[i]);
+			headerArray[i] = swapuint32(headerArray[i]);
 	}
 
 	memset(header3, 0, sizeof(PVRTexHeaderV3));
@@ -309,16 +309,16 @@ uint8 *PVRHandler::parse(filesystem::FileData *filedata, std::vector<CompressedI
 	if (header3.version == PVRTEX3_IDENT_REV)
 	{
 		header3.version = PVRTEX3_IDENT;
-		header3.flags = swap32(header3.flags);
-		header3.pixelFormat = swap64(header3.pixelFormat);
-		header3.colorSpace = swap32(header3.colorSpace);
-		header3.channelType = swap32(header3.channelType);
-		header3.height = swap32(header3.height);
-		header3.width = swap32(header3.width);
-		header3.depth = swap32(header3.depth);
-		header3.numFaces = swap32(header3.numFaces);
-		header3.numMipmaps = swap32(header3.numMipmaps);
-		header3.metaDataSize = swap32(header3.metaDataSize);
+		header3.flags = swapuint32(header3.flags);
+		header3.pixelFormat = swapuint64(header3.pixelFormat);
+		header3.colorSpace = swapuint32(header3.colorSpace);
+		header3.channelType = swapuint32(header3.channelType);
+		header3.height = swapuint32(header3.height);
+		header3.width = swapuint32(header3.width);
+		header3.depth = swapuint32(header3.depth);
+		header3.numFaces = swapuint32(header3.numFaces);
+		header3.numMipmaps = swapuint32(header3.numMipmaps);
+		header3.metaDataSize = swapuint32(header3.metaDataSize);
 	}
 
 	if (header3.depth > 1)

+ 2 - 2
src/modules/math/Compressor.cpp

@@ -63,7 +63,7 @@ public:
 		// Store the size of the uncompressed data as a header.
 #ifdef LOVE_BIG_ENDIAN
 		// Make sure it's little-endian for storage.
-		*(uint32 *) compressedbytes = swap32((uint32) dataSize);
+		*(uint32 *) compressedbytes = swapuint32((uint32) dataSize);
 #else
 		*(uint32 *) compressedbytes = (uint32) dataSize;
 #endif
@@ -110,7 +110,7 @@ public:
 		// Extract the original uncompressed size (stored in our custom header.)
 #ifdef LOVE_BIG_ENDIAN
 		// Convert from stored little-endian to big-endian.
-		uint32 rawsize = swap32(*(uint32 *) data);
+		uint32 rawsize = swapuint32(*(uint32 *) data);
 #else
 		uint32 rawsize = *(uint32 *) data;
 #endif