From 18ce2262d6f93aa3715190aeb6e31b00e0eab2d4 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 6 Sep 2015 19:08:32 +0200 Subject: [PATCH] We don't need a third set of typed-integer typedefs --- audio/wav_read.cpp | 2 +- base/basictypes.h | 70 ++++++++++++-------------------------- base/stringutil.cpp | 2 +- base/stringutil.h | 2 +- file/chunk_file.cpp | 4 +-- file/chunk_file.h | 4 +-- gfx_es2/draw_buffer.cpp | 20 +++++------ gfx_es2/draw_buffer.h | 26 +++++++------- gfx_es2/vertex_format.cpp | 2 +- image/zim_load.cpp | 4 +-- math/expression_parser.cpp | 20 +++++------ math/expression_parser.h | 16 ++++----- util/bits/bits.cpp | 6 ++-- util/bits/bits.h | 10 +++--- util/bits/varint.cpp | 2 +- util/hash/hash.cpp | 10 +++--- util/hash/hash.h | 4 +-- util/random/rng.h | 6 ++-- 18 files changed, 92 insertions(+), 118 deletions(-) diff --git a/audio/wav_read.cpp b/audio/wav_read.cpp index 8b2dbeb76c..6a827ece36 100644 --- a/audio/wav_read.cpp +++ b/audio/wav_read.cpp @@ -47,7 +47,7 @@ short *wav_read(const char *filename, data = (short *)malloc(sizeof(short) * numSamples * *num_channels); *num_samples = numSamples; if (wBlockAlign == 2 && *num_channels == 1) { - cf.readData((uint8*)data,numBytes); + cf.readData((uint8_t *)data,numBytes); } else { ELOG("Error - bad blockalign or channels"); free(data); diff --git a/base/basictypes.h b/base/basictypes.h index 7f3dfea731..c7cb845a99 100644 --- a/base/basictypes.h +++ b/base/basictypes.h @@ -3,18 +3,6 @@ #include #include // for byte swapping -#ifdef _WIN32 -// We need this to compile without hundreds of std::bind errors in Visual Studio 2012 -// since by default VARIADIC_MAX is something low like 3, 4, or 5. -// It's a good idea to include this file wherever std::bind is being used with more than 3, 4 or 5 args. -// Visual Studio 2013 doesn't need this after all, so we can simply check for equality. -#if _MSC_VER == 1700 - #undef _VARIADIC_MAX - #define _VARIADIC_MAX 10 - #endif - -#endif - #ifdef _WIN32 #pragma warning(disable:4244) #pragma warning(disable:4996) @@ -26,20 +14,6 @@ private: \ t(const t &other); \ void operator =(const t &other); - -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef uint64_t uint64; -typedef int8_t sint8; -typedef int16_t sint16; -typedef int32_t sint32; -typedef int64_t sint64; -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; - #ifdef _WIN32 typedef intptr_t ssize_t; @@ -67,7 +41,7 @@ typedef intptr_t ssize_t; #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #endif -inline uint8 swap8(uint8 _data) {return _data;} +inline uint8_t swap8(uint8_t _data) {return _data;} // Just in case this has been defined by platform #undef swap16 @@ -75,37 +49,37 @@ inline uint8 swap8(uint8 _data) {return _data;} #undef swap64 #ifdef _WIN32 -inline uint16 swap16(uint16 _data) {return _byteswap_ushort(_data);} -inline uint32 swap32(uint32 _data) {return _byteswap_ulong (_data);} -inline uint64 swap64(uint64 _data) {return _byteswap_uint64(_data);} +inline uint16_t swap16(uint16_t _data) {return _byteswap_ushort(_data);} +inline uint32_t swap32(uint32_t _data) {return _byteswap_ulong (_data);} +inline uint64_t swap64(uint64_t _data) {return _byteswap_uint64(_data);} #elif defined(ARM) -inline uint16 swap16 (uint16 _data) { uint32 data = _data; __asm__ ("rev16 %0, %1\n" : "=l" (data) : "l" (data)); return (uint16)data;} -inline uint32 swap32 (uint32 _data) {__asm__ ("rev %0, %1\n" : "=l" (_data) : "l" (_data)); return _data;} -inline uint64 swap64(uint64 _data) {return ((uint64)swap32(_data) << 32) | swap32(_data >> 32);} +inline uint16_t swap16 (uint16_t _data) { uint32_t data = _data; __asm__ ("rev16 %0, %1\n" : "=l" (data) : "l" (data)); return (uint16_t)data;} +inline uint32_t swap32 (uint32_t _data) {__asm__ ("rev %0, %1\n" : "=l" (_data) : "l" (_data)); return _data;} +inline uint64_t swap64(uint64_t _data) {return ((uint64_t)swap32(_data) << 32) | swap32(_data >> 32);} #elif __linux__ && !defined(ANDROID) #include -inline uint16 swap16(uint16 _data) {return bswap_16(_data);} -inline uint32 swap32(uint32 _data) {return bswap_32(_data);} -inline uint64 swap64(uint64 _data) {return bswap_64(_data);} +inline uint16_t swap16(uint16_t _data) {return bswap_16(_data);} +inline uint32_t swap32(uint32_t _data) {return bswap_32(_data);} +inline uint64_t swap64(uint64_t _data) {return bswap_64(_data);} #elif defined(__DragonFly__) || defined(__FreeBSD__) #include -inline uint16 swap16(uint16 _data) {return bswap16(_data);} -inline uint32 swap32(uint32 _data) {return bswap32(_data);} -inline uint64 swap64(uint64 _data) {return bswap64(_data);} +inline uint16_t swap16(uint16_t _data) {return bswap16(_data);} +inline uint32_t swap32(uint32_t _data) {return bswap32(_data);} +inline uint64_t swap64(uint64_t _data) {return bswap64(_data);} #elif defined(__GNUC__) -inline uint16 swap16(uint16 _data) {return (_data >> 8) | (_data << 8);} -inline uint32 swap32(uint32 _data) {return __builtin_bswap32(_data);} -inline uint64 swap64(uint64 _data) {return __builtin_bswap64(_data);} +inline uint16_t swap16(uint16_t _data) {return (_data >> 8) | (_data << 8);} +inline uint32_t swap32(uint32_t _data) {return __builtin_bswap32(_data);} +inline uint64_t swap64(uint64_t _data) {return __builtin_bswap64(_data);} #else // Slow generic implementation. Hopefully this never hits -inline uint16 swap16(uint16 data) {return (data >> 8) | (data << 8);} -inline uint32 swap32(uint32 data) {return (swap16(data) << 16) | swap16(data >> 16);} -inline uint64 swap64(uint64 data) {return ((uint64)swap32(data) << 32) | swap32(data >> 32);} +inline uint16_t swap16(uint16_t data) {return (data >> 8) | (data << 8);} +inline uint32_t swap32(uint32_t data) {return (swap16(data) << 16) | swap16(data >> 16);} +inline uint64_t swap64(uint64_t data) {return ((uint64_t)swap32(data) << 32) | swap32(data >> 32);} #endif -inline uint16 swap16(const uint8* _pData) {return swap16(*(const uint16*)_pData);} -inline uint32 swap32(const uint8* _pData) {return swap32(*(const uint32*)_pData);} -inline uint64 swap64(const uint8* _pData) {return swap64(*(const uint64*)_pData);} +inline uint16_t swap16(const uint8_t* _pData) {return swap16(*(const uint16_t*)_pData);} +inline uint32_t swap32(const uint8_t* _pData) {return swap32(*(const uint32_t*)_pData);} +inline uint64_t swap64(const uint8_t* _pData) {return swap64(*(const uint64_t*)_pData);} // Thread local storage #ifdef _WIN32 diff --git a/base/stringutil.cpp b/base/stringutil.cpp index f5a2675b18..dcc007d799 100644 --- a/base/stringutil.cpp +++ b/base/stringutil.cpp @@ -104,7 +104,7 @@ unsigned int parseHex(const char *_szValue) return Value; } -void DataToHexString(const uint8 *data, size_t size, std::string *output) { +void DataToHexString(const uint8_t *data, size_t size, std::string *output) { Buffer buffer; for (size_t i = 0; i < size; i++) { buffer.Printf("%02x ", data[i]); diff --git a/base/stringutil.h b/base/stringutil.h index aa6157383c..7452b4be82 100644 --- a/base/stringutil.h +++ b/base/stringutil.h @@ -89,7 +89,7 @@ inline bool endsWithNoCase(const std::string &str, const std::string &what) { return strncasecmp(str.c_str() + offset, what.c_str(), what.size()) == 0; } -void DataToHexString(const uint8 *data, size_t size, std::string *output); +void DataToHexString(const uint8_t *data, size_t size, std::string *output); inline void StringToHexString(const std::string &data, std::string *output) { DataToHexString((uint8_t *)(&data[0]), data.size(), output); } diff --git a/file/chunk_file.cpp b/file/chunk_file.cpp index d1b6d5bae0..0e39a9799f 100644 --- a/file/chunk_file.cpp +++ b/file/chunk_file.cpp @@ -82,7 +82,7 @@ void ChunkFile::writeInt(int i) { } //let's get into the business -bool ChunkFile::descend(uint32 id) { +bool ChunkFile::descend(uint32_t id) { id=flipID(id); if (read) { bool found = false; @@ -233,7 +233,7 @@ void ChunkFile::writeWString(const std::string &str) { delete [] text; } -static void toUnicode(const std::string &str, uint16 *t) { +static void toUnicode(const std::string &str, uint16_t *t) { for (size_t i = 0; i < str.size(); i++) { *t++ = str[i]; } diff --git a/file/chunk_file.h b/file/chunk_file.h index 520b45b5bb..e227a69f7c 100644 --- a/file/chunk_file.h +++ b/file/chunk_file.h @@ -15,7 +15,7 @@ #include "base/basictypes.h" #include "file/easy_file.h" -inline uint32 flipID(uint32 id) { +inline uint32_t flipID(uint32_t id) { return ((id>>24)&0xFF) | ((id>>8)&0xFF00) | ((id<<8)&0xFF0000) | ((id<<24)&0xFF000000); } @@ -26,7 +26,7 @@ public: ~ChunkFile(); - bool descend(uint32 id); + bool descend(uint32_t id); void ascend(); int readInt(); diff --git a/gfx_es2/draw_buffer.cpp b/gfx_es2/draw_buffer.cpp index c1bd2f166d..ee333ed3bc 100644 --- a/gfx_es2/draw_buffer.cpp +++ b/gfx_es2/draw_buffer.cpp @@ -93,7 +93,7 @@ void DrawBuffer::Flush(bool set_blend_state) { count_ = 0; } -void DrawBuffer::V(float x, float y, float z, uint32 color, float u, float v) { +void DrawBuffer::V(float x, float y, float z, uint32_t color, float u, float v) { if (count_ >= MAX_VERTS) { FLOG("Overflowed the DrawBuffer"); return; @@ -108,24 +108,24 @@ void DrawBuffer::V(float x, float y, float z, uint32 color, float u, float v) { vert->v = v; } -void DrawBuffer::Rect(float x, float y, float w, float h, uint32 color, int align) { +void DrawBuffer::Rect(float x, float y, float w, float h, uint32_t color, int align) { DoAlign(align, &x, &y, &w, &h); RectVGradient(x, y, w, h, color, color); } -void DrawBuffer::hLine(float x1, float y, float x2, uint32 color) { +void DrawBuffer::hLine(float x1, float y, float x2, uint32_t color) { Rect(x1, y, x2 - x1, pixel_in_dps, color); } -void DrawBuffer::vLine(float x, float y1, float y2, uint32 color) { +void DrawBuffer::vLine(float x, float y1, float y2, uint32_t color) { Rect(x, y1, pixel_in_dps, y2 - y1, color); } -void DrawBuffer::vLineAlpha50(float x, float y1, float y2, uint32 color) { +void DrawBuffer::vLineAlpha50(float x, float y1, float y2, uint32_t color) { Rect(x, y1, pixel_in_dps, y2 - y1, (color | 0xFF000000) & 0x7F000000); } -void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32 colorTop, uint32 colorBottom) { +void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32_t colorTop, uint32_t colorBottom) { V(x, y, 0, colorTop, 0, 0); V(x + w, y, 0, colorTop, 1, 0); V(x + w, y + h, 0, colorBottom, 1, 1); @@ -134,7 +134,7 @@ void DrawBuffer::RectVGradient(float x, float y, float w, float h, uint32 colorT V(x, y + h, 0, colorBottom, 0, 1); } -void DrawBuffer::RectOutline(float x, float y, float w, float h, uint32 color, int align) { +void DrawBuffer::RectOutline(float x, float y, float w, float h, uint32_t color, int align) { hLine(x, y, x + w + pixel_in_dps, color); hLine(x, y + h, x + w + pixel_in_dps, color); @@ -152,7 +152,7 @@ void DrawBuffer::MultiVGradient(float x, float y, float w, float h, GradientStop void DrawBuffer::Rect(float x, float y, float w, float h, float u, float v, float uw, float uh, - uint32 color) { + uint32_t color) { V(x, y, 0, color, u, v); V(x + w, y, 0, color, u + uw, v); V(x + w, y + h, 0, color, u + uw, v + uh); @@ -161,7 +161,7 @@ void DrawBuffer::Rect(float x, float y, float w, float h, V(x, y + h, 0, color, u, v + uh); } -void DrawBuffer::Line(int atlas_image, float x1, float y1, float x2, float y2, float thickness, uint32 color) { +void DrawBuffer::Line(int atlas_image, float x1, float y1, float x2, float y2, float thickness, uint32_t color) { const AtlasImage &image = atlas->images[atlas_image]; // No caps yet! @@ -260,7 +260,7 @@ void DrawBuffer::DrawImageRotated(ImageID atlas_image, float x, float y, float s } // TODO: add arc support -void DrawBuffer::Circle(float xc, float yc, float radius, float thickness, int segments, float startAngle, uint32 color, float u_mul) { +void DrawBuffer::Circle(float xc, float yc, float radius, float thickness, int segments, float startAngle, uint32_t color, float u_mul) { float angleDelta = PI * 2 / segments; float uDelta = 1.0f / segments; float t2 = thickness / 2.0f; diff --git a/gfx_es2/draw_buffer.h b/gfx_es2/draw_buffer.h index d83792025a..f08c580cc9 100644 --- a/gfx_es2/draw_buffer.h +++ b/gfx_es2/draw_buffer.h @@ -71,33 +71,33 @@ public: void Flush(bool set_blend_state = true); - void Rect(float x, float y, float w, float h, uint32 color, int align = ALIGN_TOPLEFT); - void hLine(float x1, float y, float x2, uint32 color); - void vLine(float x, float y1, float y2, uint32 color); - void vLineAlpha50(float x, float y1, float y2, uint32 color); + void Rect(float x, float y, float w, float h, uint32_t color, int align = ALIGN_TOPLEFT); + void hLine(float x1, float y, float x2, uint32_t color); + void vLine(float x, float y1, float y2, uint32_t color); + void vLineAlpha50(float x, float y1, float y2, uint32_t color); - void Line(int atlas_image, float x1, float y1, float x2, float y2, float thickness, uint32 color); + void Line(int atlas_image, float x1, float y1, float x2, float y2, float thickness, uint32_t color); - void RectOutline(float x, float y, float w, float h, uint32 color, int align = ALIGN_TOPLEFT); + void RectOutline(float x, float y, float w, float h, uint32_t color, int align = ALIGN_TOPLEFT); - void RectVGradient(float x, float y, float w, float h, uint32 colorTop, uint32 colorBottom); - void RectVDarkFaded(float x, float y, float w, float h, uint32 colorTop) { + void RectVGradient(float x, float y, float w, float h, uint32_t colorTop, uint32_t colorBottom); + void RectVDarkFaded(float x, float y, float w, float h, uint32_t colorTop) { RectVGradient(x, y, w, h, colorTop, darkenColor(colorTop)); } void MultiVGradient(float x, float y, float w, float h, GradientStop *stops, int numStops); - void RectCenter(float x, float y, float w, float h, uint32 color) { + void RectCenter(float x, float y, float w, float h, uint32_t color) { Rect(x - w/2, y - h/2, w, h, color); } - void Rect(float x, float y, float w, float h, float u, float v, float uw, float uh, uint32 color); + void Rect(float x, float y, float w, float h, float u, float v, float uw, float uh, uint32_t color); - void V(float x, float y, float z, uint32 color, float u, float v); - void V(float x, float y, uint32 color, float u, float v) { + void V(float x, float y, float z, uint32_t color, float u, float v); + void V(float x, float y, uint32_t color, float u, float v) { V(x, y, 0.0f, color, u, v); } - void Circle(float x, float y, float radius, float thickness, int segments, float startAngle, uint32 color, float u_mul); + void Circle(float x, float y, float radius, float thickness, int segments, float startAngle, uint32_t color, float u_mul); // New drawing APIs diff --git a/gfx_es2/vertex_format.cpp b/gfx_es2/vertex_format.cpp index c713ae2006..5c0fd6232f 100644 --- a/gfx_es2/vertex_format.cpp +++ b/gfx_es2/vertex_format.cpp @@ -58,7 +58,7 @@ void SetVertexFormat(const GLSLProgram *program, uint32_t vertexFormat) { } // TODO: Save state so that we can get rid of this. -void UnsetVertexFormat(const GLSLProgram *program, uint32 vertexFormat) { +void UnsetVertexFormat(const GLSLProgram *program, uint32_t vertexFormat) { glDisableVertexAttribArray(program->a_position); if (vertexFormat & NRM_MASK) glDisableVertexAttribArray(program->a_normal); diff --git a/image/zim_load.cpp b/image/zim_load.cpp index 5b1a3d09c0..52e4152f80 100644 --- a/image/zim_load.cpp +++ b/image/zim_load.cpp @@ -54,7 +54,7 @@ static unsigned int log2i(unsigned int val) { return ret; } -int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int *flags, uint8 **image) { +int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int *flags, uint8_t **image) { if (zim[0] != 'Z' || zim[1] != 'I' || zim[2] != 'M' || zim[3] != 'G') { ELOG("Not a ZIM file"); return 0; @@ -104,7 +104,7 @@ int LoadZIMPtr(const uint8_t *zim, size_t datasize, int *width, int *height, int return 0; } - image[0] = (uint8 *)malloc(total_data_size); + image[0] = (uint8_t *)malloc(total_data_size); for (int i = 1; i < num_levels; i++) { image[i] = image[i-1] + image_data_size[i-1]; } diff --git a/math/expression_parser.cpp b/math/expression_parser.cpp index 946898c586..f4aa82ff56 100644 --- a/math/expression_parser.cpp +++ b/math/expression_parser.cpp @@ -58,7 +58,7 @@ const ExpressionOpcode ExpressionOpcodes[] = { { "", 0, 0, 0, false } // EXOP_NONE }; -bool parseNumber(char* str, int defaultrad, int len, uint32& result) +bool parseNumber(char* str, int defaultrad, int len, uint32_t& result) { int val = 0; int r = 0; @@ -148,7 +148,7 @@ bool parseNumber(char* str, int defaultrad, int len, uint32& result) } // Parse only a float, and return as float bits. -static bool parseFloat(const char *str, int len, uint32 &result) +static bool parseFloat(const char *str, int len, uint32_t &result) { bool foundDecimal = false; for (int i = 0; i < len; ++i) @@ -237,7 +237,7 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf } subStr[subPos] = 0; - uint32 value; + uint32_t value; bool isFloat = false; if (parseFloat(subStr,subPos,value) == true) isFloat = true; @@ -257,7 +257,7 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf } subStr[subPos] = 0; - uint32 value; + uint32_t value; if (funcs->parseReference(subStr,value) == true) { dest.push_back(ExpressionPair(EXCOMM_REF,value)); @@ -391,11 +391,11 @@ bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, Postf return true; } -bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, uint32& dest) +bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, uint32_t& dest) { size_t num = 0; - uint32 opcode; - std::vector valueStack; + uint32_t opcode; + std::vector valueStack; unsigned int arg[5]; float fArg[5]; bool useFloat = false; @@ -440,7 +440,7 @@ bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, return false; } - uint32 val; + uint32_t val; if(funcs->getMemoryValue(arg[1],arg[0],val,expressionError) == false) { return false; @@ -449,7 +449,7 @@ bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, break; case EXOP_MEM: { - uint32 val; + uint32_t val; if (funcs->getMemoryValue(arg[0],4,val,expressionError) == false) { return false; @@ -579,7 +579,7 @@ bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, return true; } -bool parseExpression(char* exp, IExpressionFunctions* funcs, uint32& dest) +bool parseExpression(char* exp, IExpressionFunctions* funcs, uint32_t& dest) { PostfixExpression postfix; if (initPostfixExpression(exp,funcs,postfix) == false) return false; diff --git a/math/expression_parser.h b/math/expression_parser.h index 4f7b9f9068..306075c9c9 100644 --- a/math/expression_parser.h +++ b/math/expression_parser.h @@ -3,7 +3,7 @@ #include "../base/basictypes.h" #include -typedef std::pair ExpressionPair; +typedef std::pair ExpressionPair; typedef std::vector PostfixExpression; enum ExpressionType @@ -15,14 +15,14 @@ enum ExpressionType class IExpressionFunctions { public: - virtual bool parseReference(char* str, uint32& referenceIndex) = 0; - virtual bool parseSymbol(char* str, uint32& symbolValue) = 0; - virtual uint32 getReferenceValue(uint32 referenceIndex) = 0; - virtual ExpressionType getReferenceType(uint32 referenceIndex) = 0; - virtual bool getMemoryValue(uint32 address, int size, uint32& dest, char* error) = 0; + virtual bool parseReference(char* str, uint32_t& referenceIndex) = 0; + virtual bool parseSymbol(char* str, uint32_t& symbolValue) = 0; + virtual uint32_t getReferenceValue(uint32_t referenceIndex) = 0; + virtual ExpressionType getReferenceType(uint32_t referenceIndex) = 0; + virtual bool getMemoryValue(uint32_t address, int size, uint32_t& dest, char* error) = 0; }; bool initPostfixExpression(const char* infix, IExpressionFunctions* funcs, PostfixExpression& dest); -bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, uint32& dest); -bool parseExpression(const char* exp, IExpressionFunctions* funcs, uint32& dest); +bool parsePostfixExpression(PostfixExpression& exp, IExpressionFunctions* funcs, uint32_t& dest); +bool parseExpression(const char* exp, IExpressionFunctions* funcs, uint32_t& dest); const char* getExpressionError(); diff --git a/util/bits/bits.cpp b/util/bits/bits.cpp index 5267078abe..d8bf9d1296 100644 --- a/util/bits/bits.cpp +++ b/util/bits/bits.cpp @@ -23,15 +23,15 @@ static const unsigned char BitsSetTable256[] = { 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }; -int CountBits8(uint8 v) { +int CountBits8(uint8_t v) { return BitsSetTable256[v]; } -int CountBits16(uint16 v) { +int CountBits16(uint16_t v) { return BitsSetTable256[v & 0xFF] + BitsSetTable256[v >> 8]; } -int CountBits32(uint32 v) { +int CountBits32(uint32_t v) { v = v - ((v >> 1) & 0x55555555); // reuse input as temporary v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; // count diff --git a/util/bits/bits.h b/util/bits/bits.h index 6c1edd22b4..0c1b630f9b 100644 --- a/util/bits/bits.h +++ b/util/bits/bits.h @@ -5,17 +5,17 @@ namespace bits { -int CountBits8(uint8 v); -int CountBits16(uint16 v); -int CountBits32(uint32 v); +int CountBits8(uint8_t v); +int CountBits16(uint16_t v); +int CountBits32(uint32_t v); // where mask is 0, the result is a. // where mask is 1, the result is b. -inline uint32 MixBits(uint32 a, uint32 b, uint32 mask) { +inline uint32_t MixBits(uint32_t a, uint32_t b, uint32_t mask) { return a ^ ((a ^ b) & mask); } -inline uint32 ComputeParity(uint32 v) { +inline uint32_t ComputeParity(uint32_t v) { v ^= v >> 16; v ^= v >> 8; v ^= v >> 4; diff --git a/util/bits/varint.cpp b/util/bits/varint.cpp index fc29c069d1..2992599e72 100644 --- a/util/bits/varint.cpp +++ b/util/bits/varint.cpp @@ -17,7 +17,7 @@ uint32_t Decode32(const char **ptr) { uint32_t value = 0; const char *p = *ptr; while (true) { - uint8 b = *p++; + uint8_t b = *p++; if (b & 0x80) { *ptr = p; return value | (b & 0x7F); diff --git a/util/hash/hash.cpp b/util/hash/hash.cpp index 911486cdcb..3ebaea7d02 100644 --- a/util/hash/hash.cpp +++ b/util/hash/hash.cpp @@ -6,10 +6,10 @@ namespace hash { // uint32_t // WARNING - may read one more byte! Fine if the input is a null-terminated string. // Implementation from Wikipedia. -uint32 Fletcher(const uint8 *data_uint8, size_t length) { - const uint16 *data = (const uint16 *)data_uint8; +uint32_t Fletcher(const uint8_t *data_uint8, size_t length) { + const uint16_t *data = (const uint16_t *)data_uint8; size_t len = (length + 1) / 2; - uint32 sum1 = 0xffff, sum2 = 0xffff; + uint32_t sum1 = 0xffff, sum2 = 0xffff; while (len) { size_t tlen = len > 360 ? 360 : len; @@ -34,8 +34,8 @@ uint32 Fletcher(const uint8 *data_uint8, size_t length) { // Slightly slower than Fletcher above, but slighly more reliable. #define MOD_ADLER 65521 // data: Pointer to the data to be summed; len is in bytes -uint32 Adler32(const uint8 *data, size_t len) { - uint32 a = 1, b = 0; +uint32_t Adler32(const uint8_t *data, size_t len) { + uint32_t a = 1, b = 0; while (len) { size_t tlen = len > 5550 ? 5550 : len; len -= tlen; diff --git a/util/hash/hash.h b/util/hash/hash.h index 1091990534..0c7ac64326 100644 --- a/util/hash/hash.h +++ b/util/hash/hash.h @@ -7,8 +7,8 @@ namespace hash { -uint32 Fletcher(const uint8 *data_u8, size_t length); // FAST. Length & 1 == 0. -uint32 Adler32(const uint8 *data, size_t len); // Fairly accurate, slightly slower +uint32_t Fletcher(const uint8_t *data_u8, size_t length); // FAST. Length & 1 == 0. +uint32_t Adler32(const uint8_t *data, size_t len); // Fairly accurate, slightly slower } // namespace hash diff --git a/util/random/rng.h b/util/random/rng.h index 89e0808deb..15ace2bb71 100644 --- a/util/random/rng.h +++ b/util/random/rng.h @@ -15,7 +15,7 @@ public: m_z = ~seed; if (!m_z) m_z = 31337; } - uint32 R32() { + uint32_t R32() { m_z = 36969 * (m_z & 65535) + (m_z >> 16); m_w = 18000 * (m_w & 65535) + (m_w >> 16); return (m_z << 16) + m_w; @@ -25,8 +25,8 @@ public: } // public for easy save/load. Yes a bit ugly but better than moving DoState into native. - uint32 m_w; - uint32 m_z; + uint32_t m_w; + uint32_t m_z; };