Merge pull request #2109 from Rot127/inter-os-printf-formatting

Use OS independent printf formatting.
This commit is contained in:
Wu ChenXu 2023-07-24 19:47:51 +08:00 committed by GitHub
commit e1af2e249a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -28,9 +28,14 @@ void print_insn_detail_arm(csh handle, cs_insn *ins)
case ARM_OP_REG: case ARM_OP_REG:
printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg)); printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
break; break;
case ARM_OP_IMM: case ARM_OP_IMM: {
printf("\t\toperands[%u].type: IMM = 0x%x\n", i, op->imm); bool neg_imm = op->imm < 0;
if (neg_imm)
printf("\t\toperands[%u].type: IMM = -0x%" PRIx32 "\n", i, -(op->imm));
else
printf("\t\toperands[%u].type: IMM = 0x%" PRIx32 "\n", i, op->imm);
break; break;
}
case ARM_OP_FP: case ARM_OP_FP:
#if defined(_KERNEL_MODE) #if defined(_KERNEL_MODE)
// Issue #681: Windows kernel does not support formatting float point // Issue #681: Windows kernel does not support formatting float point
@ -56,10 +61,10 @@ void print_insn_detail_arm(csh handle, cs_insn *ins)
break; break;
case ARM_OP_PIMM: case ARM_OP_PIMM:
printf("\t\toperands[%u].type: P-IMM = %u\n", i, op->imm); printf("\t\toperands[%u].type: P-IMM = %" PRIu32 "\n", i, op->imm);
break; break;
case ARM_OP_CIMM: case ARM_OP_CIMM:
printf("\t\toperands[%u].type: C-IMM = %u\n", i, op->imm); printf("\t\toperands[%u].type: C-IMM = %" PRIu32 "\n", i, op->imm);
break; break;
case ARM_OP_SETEND: case ARM_OP_SETEND:
printf("\t\toperands[%u].type: SETEND = %s\n", i, op->setend == ARM_SETEND_BE? "be" : "le"); printf("\t\toperands[%u].type: SETEND = %s\n", i, op->setend == ARM_SETEND_BE? "be" : "le");