diff --git a/libretro-common/encodings/encoding_crc32.c b/libretro-common/encodings/encoding_crc32.c index d080917572..d62393b835 100644 --- a/libretro-common/encodings/encoding_crc32.c +++ b/libretro-common/encodings/encoding_crc32.c @@ -20,7 +20,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -static const unsigned long crc_table[256] = { +#include + +static const uint32_t crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, @@ -75,18 +77,14 @@ static const unsigned long crc_table[256] = { 0x2d02ef8dL }; -#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); +#define DO1_CRC32(buf) crc = crc_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8); #define DO2_CRC32(buf) DO1_CRC32(buf); DO1_CRC32(buf); #define DO4_CRC32(buf) DO2_CRC32(buf); DO2_CRC32(buf); #define DO8_CRC32(buf) DO4_CRC32(buf); DO4_CRC32(buf); -unsigned long encoding_crc32( - unsigned long crc, const unsigned char *buf, unsigned int len) +uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len) { - if (buf == 0) - return 0L; - - crc = crc ^ 0xffffffffL; + crc = crc ^ 0xffffffff; while (len >= 8) { @@ -101,5 +99,5 @@ unsigned long encoding_crc32( } while (--len); } - return crc ^ 0xffffffffL; + return crc ^ 0xffffffff; } diff --git a/libretro-common/include/encodings/crc32.h b/libretro-common/include/encodings/crc32.h index 69e3da4e8d..b7dc00f95d 100644 --- a/libretro-common/include/encodings/crc32.h +++ b/libretro-common/include/encodings/crc32.h @@ -26,6 +26,6 @@ #include #include -unsigned long encoding_crc32(unsigned long crc, const unsigned char *buf, unsigned int len); +uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len); #endif