Correction for printing long type variables in 32-bit system (#2094)

Due to change request from #2037
This commit is contained in:
Marcin Hajder
2024-10-01 17:45:39 +02:00
committed by GitHub
parent cd74e02643
commit 0395a1efef
2 changed files with 28 additions and 10 deletions

View File

@@ -81,7 +81,6 @@ struct printDataGenParameters
// Reference results - filled out at run-time
static std::vector<std::string> correctBufferInt;
static std::vector<std::string> correctBufferLong;
static std::vector<std::string> correctBufferHalf;
static std::vector<std::string> correctBufferFloat;
static std::vector<std::string> correctBufferDouble;

View File

@@ -23,7 +23,6 @@
// Helpers for generating runtime reference results
static void intRefBuilder(printDataGenParameters&, char*, const size_t);
static void longRefBuilder(printDataGenParameters&, char*, const size_t);
static void halfRefBuilder(printDataGenParameters&, char* rResult,
const size_t);
static void floatRefBuilder(printDataGenParameters&, char* rResult, const size_t);
@@ -158,6 +157,33 @@ std::vector<printDataGenParameters> printLongGenParameters = {
};
//--------------------------------------------------------
// Lookup table - [string]long-correct buffer |
//--------------------------------------------------------
// The table below is used to accommodate differences in `printf` output when
// using the `%ld` format specifier in 32-bit versus 64-bit compiled binaries
std::vector<std::string> correctBufferLong = {
"10000000000",
"-10000000000 ",
"000010000000000",
" -10000000000",
"+10000000000 ",
"000010000000000",
"-000010000000000"
};
//-----------------------------------------------
// test case for long |
@@ -172,7 +198,7 @@ testCase testCaseLong = {
printLongGenParameters,
longRefBuilder,
NULL,
klong
@@ -1594,13 +1620,6 @@ static void intRefBuilder(printDataGenParameters& params, char* refResult, const
atoi(params.dataRepresentation));
}
static void longRefBuilder(printDataGenParameters& params, char* refResult,
const size_t refSize)
{
snprintf(refResult, refSize, params.genericFormats.front().c_str(),
atoll(params.dataRepresentation));
}
static void halfRefBuilder(printDataGenParameters& params, char* refResult,
const size_t refSize)
{