Received: from eggs.gnu.org ([2001:4830:134:3::10]:56028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNk2D-0001tZ-Aq for qemu-devel@nongnu.org; Mon, 25 Jan 2016 11:30:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNk2C-0000ts-AK for qemu-devel@nongnu.org; Mon, 25 Jan 2016 11:30:33 -0500 From: Peter Maydell Date: Mon, 25 Jan 2016 16:30:29 +0000 Message-Id: <1453739429-31477-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] libvixl: Avoid std::abs() of 64-bit type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Franz-Josef Haider , patches@linaro.org The std::abs() function did not get a version that works on 'long long' until C++11. Avoid it, so that we can compile on 32-bit platforms (where int64_t is 'long long') with older compilers (which don't support C++11). Reported-by: Franz-Josef Haider Signed-off-by: Peter Maydell --- I've reported this as an upstream VIXL bug and expect it will be fixed in a future version. I didn't use llabs() because of its undefined behaviour if the input value happens to be the most negative integer. --- disas/libvixl/vixl/a64/disasm-a64.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/disas/libvixl/vixl/a64/disasm-a64.cc b/disas/libvixl/vixl/a64/disasm-a64.cc index 20caba4..7a58a5c 100644 --- a/disas/libvixl/vixl/a64/disasm-a64.cc +++ b/disas/libvixl/vixl/a64/disasm-a64.cc @@ -2688,8 +2688,12 @@ void Disassembler::AppendRegisterNameToOutput(const Instruction* instr, void Disassembler::AppendPCRelativeOffsetToOutput(const Instruction* instr, int64_t offset) { USE(instr); + uint64_t abs_offset = offset; char sign = (offset < 0) ? '-' : '+'; - AppendToOutput("#%c0x%" PRIx64, sign, std::abs(offset)); + if (offset < 0) { + abs_offset = -abs_offset; + } + AppendToOutput("#%c0x%" PRIx64, sign, abs_offset); } -- 1.9.1