mirror of
https://github.com/facebook/zstd.git
synced 2025-07-29 11:21:22 +03:00
fix confusion between unsigned <-> U32
as suggested in #1441. generally U32 and unsigned are the same thing, except when they are not ... case : 32-bit compilation for MIPS (uint32_t == unsigned long) A vast majority of transformation consists in transforming U32 into unsigned. In rare cases, it's the other way around (typically for internal code, such as seeds). Among a few issues this patches solves : - some parameters were declared with type `unsigned` in *.h, but with type `U32` in their implementation *.c . - some parameters have type unsigned*, but the caller user a pointer to U32 instead. These fixes are useful. However, the bulk of changes is about %u formating, which requires unsigned type, but generally receives U32 values instead, often just for brevity (U32 is shorter than unsigned). These changes are generally minor, or even annoying. As a consequence, the amount of code changed is larger than I would expect for such a patch. Testing is also a pain : it requires manually modifying `mem.h`, in order to lie about `U32` and force it to be an `unsigned long` typically. On a 64-bit system, this will break the equivalence unsigned == U32. Unfortunately, it will also break a few static_assert(), controlling structure sizes. So it also requires modifying `debug.h` to make `static_assert()` a noop. And then reverting these changes. So it's inconvenient, and as a consequence, this property is currently not checked during CI tests. Therefore, these problems can emerge again in the future. I wonder if it is worth ensuring proper distinction of U32 != unsigned in CI tests. It's another restriction for coding, adding more frustration during merge tests, since most platforms don't need this distinction (hence contributor will not see it), and while this can matter in theory, the number of platforms impacted seems minimal. Thoughts ?
This commit is contained in:
@ -201,7 +201,7 @@ static int invRangeMap(varInds_t param, U32 value)
|
||||
}
|
||||
|
||||
/* display of params */
|
||||
static void displayParamVal(FILE* f, varInds_t param, U32 value, int width)
|
||||
static void displayParamVal(FILE* f, varInds_t param, unsigned value, int width)
|
||||
{
|
||||
switch(param) {
|
||||
case wlog_ind:
|
||||
@ -636,7 +636,7 @@ static void optimizerAdjustInput(paramValues_t* pc, const size_t maxBlockSize)
|
||||
if(adjust != pc->vals[wlog_ind]) {
|
||||
pc->vals[wlog_ind] = adjust;
|
||||
DISPLAY("Warning: windowLog larger than src/block size, adjusted to %u\n",
|
||||
pc->vals[wlog_ind]);
|
||||
(unsigned)pc->vals[wlog_ind]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,7 +652,7 @@ static void optimizerAdjustInput(paramValues_t* pc, const size_t maxBlockSize)
|
||||
if(pc->vals[clog_ind] > maxclog) {
|
||||
pc->vals[clog_ind] = maxclog;
|
||||
DISPLAY("Warning: chainlog too much larger than windowLog size, adjusted to %u\n",
|
||||
pc->vals[clog_ind]);
|
||||
(unsigned)pc->vals[clog_ind]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -660,7 +660,7 @@ static void optimizerAdjustInput(paramValues_t* pc, const size_t maxBlockSize)
|
||||
if(pc->vals[wlog_ind] + 1 < pc->vals[hlog_ind]) {
|
||||
pc->vals[hlog_ind] = pc->vals[wlog_ind] + 1;
|
||||
DISPLAY("Warning: hashlog too much larger than windowLog size, adjusted to %u\n",
|
||||
pc->vals[hlog_ind]);
|
||||
(unsigned)pc->vals[hlog_ind]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ static void optimizerAdjustInput(paramValues_t* pc, const size_t maxBlockSize)
|
||||
if(pc->vals[slog_ind] > pc->vals[clog_ind]) {
|
||||
pc->vals[clog_ind] = pc->vals[slog_ind];
|
||||
DISPLAY("Warning: searchLog larger than chainLog, adjusted to %u\n",
|
||||
pc->vals[slog_ind]);
|
||||
(unsigned)pc->vals[slog_ind]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -705,7 +705,7 @@ BMK_paramValues_into_commandLine(FILE* f, const paramValues_t params)
|
||||
if (!first) { fprintf(f, ","); }
|
||||
fprintf(f,"%s=", g_paramNames[v]);
|
||||
|
||||
if (v == strt_ind) { fprintf(f,"%u", params.vals[v]); }
|
||||
if (v == strt_ind) { fprintf(f,"%u", (unsigned)params.vals[v]); }
|
||||
else { displayParamVal(f, v, params.vals[v], 0); }
|
||||
first = 0;
|
||||
}
|
||||
@ -1532,7 +1532,7 @@ static void display_params_tested(paramValues_t cParams)
|
||||
varInds_t vi;
|
||||
DISPLAYLEVEL(3, "\r testing :");
|
||||
for (vi=0; vi < NUM_PARAMS; vi++) {
|
||||
DISPLAYLEVEL(3, "%3u,", cParams.vals[vi]);
|
||||
DISPLAYLEVEL(3, "%3u,", (unsigned)cParams.vals[vi]);
|
||||
}
|
||||
DISPLAYLEVEL(3, "\b \r");
|
||||
}
|
||||
@ -2456,9 +2456,9 @@ optimizeForSize(const char* const * const fileNamesTable, const size_t nbFiles,
|
||||
DISPLAYLEVEL(2, "optimizing for %lu Files", (unsigned long)nbFiles);
|
||||
}
|
||||
|
||||
if(target.cSpeed != 0) { DISPLAYLEVEL(2," - limit compression speed %u MB/s", target.cSpeed >> 20); }
|
||||
if(target.dSpeed != 0) { DISPLAYLEVEL(2, " - limit decompression speed %u MB/s", target.dSpeed >> 20); }
|
||||
if(target.cMem != (U32)-1) { DISPLAYLEVEL(2, " - limit memory %u MB", target.cMem >> 20); }
|
||||
if(target.cSpeed != 0) { DISPLAYLEVEL(2," - limit compression speed %u MB/s", (unsigned)(target.cSpeed >> 20)); }
|
||||
if(target.dSpeed != 0) { DISPLAYLEVEL(2, " - limit decompression speed %u MB/s", (unsigned)(target.dSpeed >> 20)); }
|
||||
if(target.cMem != (U32)-1) { DISPLAYLEVEL(2, " - limit memory %u MB", (unsigned)(target.cMem >> 20)); }
|
||||
|
||||
DISPLAYLEVEL(2, "\n");
|
||||
init_clockGranularity();
|
||||
@ -2640,7 +2640,8 @@ static int usage_advanced(void)
|
||||
DISPLAY( " -S : Single run \n");
|
||||
DISPLAY( " --zstd : Single run, parameter selection same as zstdcli \n");
|
||||
DISPLAY( " -P# : generated sample compressibility (default : %.1f%%) \n", COMPRESSIBILITY_DEFAULT * 100);
|
||||
DISPLAY( " -t# : Caps runtime of operation in seconds (default : %u seconds (%.1f hours)) \n", g_timeLimit_s, (double)g_timeLimit_s / 3600);
|
||||
DISPLAY( " -t# : Caps runtime of operation in seconds (default : %u seconds (%.1f hours)) \n",
|
||||
(unsigned)g_timeLimit_s, (double)g_timeLimit_s / 3600);
|
||||
DISPLAY( " -v : Prints Benchmarking output\n");
|
||||
DISPLAY( " -D : Next argument dictionary file\n");
|
||||
DISPLAY( " -s : Seperate Files\n");
|
||||
@ -2875,7 +2876,7 @@ int main(int argc, const char** argv)
|
||||
case 'B':
|
||||
argument++;
|
||||
g_blockSize = readU32FromChar(&argument);
|
||||
DISPLAY("using %u KB block size \n", g_blockSize>>10);
|
||||
DISPLAY("using %u KB block size \n", (unsigned)(g_blockSize>>10));
|
||||
break;
|
||||
|
||||
/* caps runtime (in seconds) */
|
||||
|
Reference in New Issue
Block a user