mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 16:48:45 +08:00
Printf handler: enure that long format uses always 64 bit integers
Related-To: NEO-7384 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
bbc31e6aac
commit
4d3a017d9b
@@ -113,6 +113,17 @@ void PrintFormatter::stripVectorTypeConversion(char *format) {
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void PrintFormatter::adjustFormatString<int64_t>(std::string &formatString) {
|
||||
auto longPosition = formatString.find('l');
|
||||
|
||||
UNRECOVERABLE_IF(longPosition == std::string::npos || longPosition == formatString.size() - 1);
|
||||
|
||||
if (formatString.at(longPosition + 1) != 'l') {
|
||||
formatString.insert(longPosition, "l");
|
||||
}
|
||||
}
|
||||
|
||||
size_t PrintFormatter::printToken(char *output, size_t size, const char *formatString) {
|
||||
PRINTF_DATA_TYPE type(PRINTF_DATA_TYPE::INVALID);
|
||||
read(&type);
|
||||
|
||||
@@ -81,29 +81,36 @@ class PrintFormatter {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
size_t typedPrintToken(char *output, size_t size, const char *formatString) {
|
||||
void adjustFormatString(std::string &formatString) {}
|
||||
|
||||
template <class T>
|
||||
size_t typedPrintToken(char *output, size_t size, const char *inputFormatString) {
|
||||
T value{0};
|
||||
read(&value);
|
||||
constexpr auto offsetToBeDwordAligned = static_cast<uint32_t>(std::max(int64_t(sizeof(int) - sizeof(T)), int64_t(0)));
|
||||
currentOffset += offsetToBeDwordAligned;
|
||||
return simpleSprintf(output, size, formatString, value);
|
||||
std::string formatString(inputFormatString);
|
||||
adjustFormatString<T>(formatString);
|
||||
return simpleSprintf(output, size, formatString.c_str(), value);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
size_t typedPrintVectorToken(char *output, size_t size, const char *formatString) {
|
||||
size_t typedPrintVectorToken(char *output, size_t size, const char *inputFormatString) {
|
||||
T value = {0};
|
||||
int valueCount = 0;
|
||||
read(&valueCount);
|
||||
|
||||
size_t charactersPrinted = 0;
|
||||
char strippedFormat[1024];
|
||||
char strippedFormat[1024]{};
|
||||
|
||||
stripVectorFormat(formatString, strippedFormat);
|
||||
stripVectorFormat(inputFormatString, strippedFormat);
|
||||
stripVectorTypeConversion(strippedFormat);
|
||||
std::string formatString(strippedFormat);
|
||||
adjustFormatString<T>(formatString);
|
||||
|
||||
for (int i = 0; i < valueCount; i++) {
|
||||
read(&value);
|
||||
charactersPrinted += simpleSprintf(output + charactersPrinted, size - charactersPrinted, strippedFormat, value);
|
||||
charactersPrinted += simpleSprintf(output + charactersPrinted, size - charactersPrinted, formatString.c_str(), value);
|
||||
if (i < valueCount - 1) {
|
||||
charactersPrinted += simpleSprintf(output + charactersPrinted, size - charactersPrinted, "%c", ',');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user