Revert rewind.c

This commit is contained in:
twinaphex 2015-09-15 19:02:39 +02:00
parent 872314f910
commit 557347fba6

View File

@ -16,7 +16,6 @@
*/ */
#define __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -27,12 +26,12 @@
#include "rewind.h" #include "rewind.h"
#include "performance.h" #include "performance.h"
#ifndef UINT_FAST16_MAX #ifndef UINT16_MAX
#define UINT_FAST16_MAX 0xffff #define UINT16_MAX 0xffff
#endif #endif
#ifndef UINT_LEAST32_MAX #ifndef UINT32_MAX
#define UINT_LEAST32_MAX 0xffffffffu #define UINT32_MAX 0xffffffffu
#endif #endif
#undef CPU_X86 #undef CPU_X86
@ -68,7 +67,7 @@ size thisstart;
size_t state_manager_raw_maxsize(size_t uncomp) size_t state_manager_raw_maxsize(size_t uncomp)
{ {
/* bytes covered by a compressed block */ /* bytes covered by a compressed block */
const int maxcblkcover = UINT_FAST16_MAX * sizeof(uint16_t); const int maxcblkcover = UINT16_MAX * sizeof(uint16_t);
/* uncompressed size, rounded to 16 bits */ /* uncompressed size, rounded to 16 bits */
size_t uncomp16 = (uncomp + sizeof(uint16_t) - 1) & ~sizeof(uint16_t); size_t uncomp16 = (uncomp + sizeof(uint16_t) - 1) & ~sizeof(uint16_t);
/* number of blocks */ /* number of blocks */
@ -246,13 +245,15 @@ size_t state_manager_raw_compress(const void *src,
new16 += skip; new16 += skip;
num16s -= skip; num16s -= skip;
if (skip > UINT_FAST16_MAX) if (skip > UINT16_MAX)
{ {
/* This will make it scan the entire thing again, if (skip > UINT32_MAX)
* but it only hits on 8GB unchanged data anyways, {
* and if you're doing that, you've got bigger problems. */ /* This will make it scan the entire thing again,
if (skip > UINT_LEAST32_MAX) * but it only hits on 8GB unchanged data anyways,
skip = UINT_LEAST32_MAX; * and if you're doing that, you've got bigger problems. */
skip = UINT32_MAX;
}
*compressed16++ = 0; *compressed16++ = 0;
*compressed16++ = skip; *compressed16++ = skip;
*compressed16++ = skip >> 16; *compressed16++ = skip >> 16;
@ -261,8 +262,8 @@ size_t state_manager_raw_compress(const void *src,
} }
changed = find_same(old16, new16); changed = find_same(old16, new16);
if (changed > UINT_FAST16_MAX) if (changed > UINT16_MAX)
changed = UINT_FAST16_MAX; changed = UINT16_MAX;
*compressed16++ = changed; *compressed16++ = changed;
*compressed16++ = skip; *compressed16++ = skip;