Last bit of string cleanup. string.h finally gone.

This commit is contained in:
Ben Vanik
2014-08-17 11:48:29 -07:00
parent 383d3acbb0
commit 24fe169f36
28 changed files with 148 additions and 236 deletions

View File

@@ -45,7 +45,7 @@ int FinalizationPass::Run(HIRBuilder* builder) {
if (!label->name) {
const size_t label_len = 6 + 4 + 1;
char* name = (char*)arena->Alloc(label_len);
xesnprintfa(name, label_len, "_label%d", label->id);
snprintf(name, label_len, "_label%d", label->id);
label->name = name;
}
label = label->next;

View File

@@ -32,7 +32,7 @@ bool PPCContext::CompareRegWithString(const char* name, const char* value,
if (sscanf(name, "r%d", &n) == 1) {
uint64_t expected = ParseInt64(value);
if (this->r[n] != expected) {
xesnprintfa(out_value, out_value_size, "%016llX", this->r[n]);
snprintf(out_value, out_value_size, "%016llX", this->r[n]);
return false;
}
return true;

View File

@@ -294,7 +294,7 @@ void Disasm_bcx(InstrData& i, StringBuffer* str) {
}
char s2[8] = {0};
if (!select_bits(i.B.BO, 4, 4)) {
xesnprintfa(s2, poly::countof(s2), "cr%d, ", i.B.BI >> 2);
snprintf(s2, poly::countof(s2), "cr%d, ", i.B.BI >> 2);
}
uint32_t nia;
if (i.B.AA) {
@@ -310,7 +310,7 @@ void Disasm_bcctrx(InstrData& i, StringBuffer* str) {
const char* s0 = i.XL.LK ? "lr, " : "";
char s2[8] = {0};
if (!select_bits(i.XL.BO, 4, 4)) {
xesnprintfa(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2);
snprintf(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2);
}
str->Append("%-8s %s%sctr", i.type->name, s0, s2);
// TODO(benvanik): resolve target name?
@@ -328,7 +328,7 @@ void Disasm_bclrx(InstrData& i, StringBuffer* str) {
}
char s2[8] = {0};
if (!select_bits(i.XL.BO, 4, 4)) {
xesnprintfa(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2);
snprintf(s2, poly::countof(s2), "cr%d, ", i.XL.BI >> 2);
}
str->Append("%-8s %s%s", name, s1, s2);
}

View File

@@ -168,8 +168,8 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, uint32_t flags) {
void PPCHIRBuilder::AnnotateLabel(uint64_t address, Label* label) {
char name_buffer[13];
xesnprintfa(name_buffer, poly::countof(name_buffer), "loc_%.8X",
(uint32_t)address);
snprintf(name_buffer, poly::countof(name_buffer), "loc_%.8X",
(uint32_t)address);
label->name = (char*)arena_->Alloc(sizeof(name_buffer));
xe_copy_struct(label->name, name_buffer, sizeof(name_buffer));
}

View File

@@ -30,28 +30,28 @@ void InstrOperand::Dump(std::string& out_str) {
case InstrOperand::kRegister:
switch (reg.set) {
case InstrRegister::kXER:
xesnprintfa(buffer, max_count, "XER");
snprintf(buffer, max_count, "XER");
break;
case InstrRegister::kLR:
xesnprintfa(buffer, max_count, "LR");
snprintf(buffer, max_count, "LR");
break;
case InstrRegister::kCTR:
xesnprintfa(buffer, max_count, "CTR");
snprintf(buffer, max_count, "CTR");
break;
case InstrRegister::kCR:
xesnprintfa(buffer, max_count, "CR%d", reg.ordinal);
snprintf(buffer, max_count, "CR%d", reg.ordinal);
break;
case InstrRegister::kFPSCR:
xesnprintfa(buffer, max_count, "FPSCR");
snprintf(buffer, max_count, "FPSCR");
break;
case InstrRegister::kGPR:
xesnprintfa(buffer, max_count, "r%d", reg.ordinal);
snprintf(buffer, max_count, "r%d", reg.ordinal);
break;
case InstrRegister::kFPR:
xesnprintfa(buffer, max_count, "f%d", reg.ordinal);
snprintf(buffer, max_count, "f%d", reg.ordinal);
break;
case InstrRegister::kVMX:
xesnprintfa(buffer, max_count, "vr%d", reg.ordinal);
snprintf(buffer, max_count, "vr%d", reg.ordinal);
break;
}
break;
@@ -59,30 +59,30 @@ void InstrOperand::Dump(std::string& out_str) {
switch (imm.width) {
case 1:
if (imm.is_signed) {
xesnprintfa(buffer, max_count, "%d", (int32_t)(int8_t)imm.value);
snprintf(buffer, max_count, "%d", (int32_t)(int8_t)imm.value);
} else {
xesnprintfa(buffer, max_count, "0x%.2X", (uint8_t)imm.value);
snprintf(buffer, max_count, "0x%.2X", (uint8_t)imm.value);
}
break;
case 2:
if (imm.is_signed) {
xesnprintfa(buffer, max_count, "%d", (int32_t)(int16_t)imm.value);
snprintf(buffer, max_count, "%d", (int32_t)(int16_t)imm.value);
} else {
xesnprintfa(buffer, max_count, "0x%.4X", (uint16_t)imm.value);
snprintf(buffer, max_count, "0x%.4X", (uint16_t)imm.value);
}
break;
case 4:
if (imm.is_signed) {
xesnprintfa(buffer, max_count, "%d", (int32_t)imm.value);
snprintf(buffer, max_count, "%d", (int32_t)imm.value);
} else {
xesnprintfa(buffer, max_count, "0x%.8X", (uint32_t)imm.value);
snprintf(buffer, max_count, "0x%.8X", (uint32_t)imm.value);
}
break;
case 8:
if (imm.is_signed) {
xesnprintfa(buffer, max_count, "%lld", (int64_t)imm.value);
snprintf(buffer, max_count, "%lld", (int64_t)imm.value);
} else {
xesnprintfa(buffer, max_count, "0x%.16llX", imm.value);
snprintf(buffer, max_count, "0x%.16llX", imm.value);
}
break;
}

View File

@@ -625,7 +625,7 @@ void HIRBuilder::Comment(const char* format, ...) {
char buffer[1024];
va_list args;
va_start(args, format);
xevsnprintfa(buffer, 1024, format, args);
vsnprintf(buffer, 1024, format, args);
va_end(args);
size_t len = strlen(buffer);
if (!len) {