From patchwork Mon Jan 25 16:30:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 8111461 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 10B14BEEE5 for ; Mon, 25 Jan 2016 16:30:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63823202E6 for ; Mon, 25 Jan 2016 16:30:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81BBE202DD for ; Mon, 25 Jan 2016 16:30:41 +0000 (UTC) Received: from localhost ([::1]:39546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNk2K-0001tu-KX for patchwork-qemu-devel@patchwork.kernel.org; Mon, 25 Jan 2016 11:30:40 -0500 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 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:59594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNk2C-0000tg-3O; Mon, 25 Jan 2016 11:30:32 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1aNk29-0008CA-BM; Mon, 25 Jan 2016 16:30:29 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 25 Jan 2016 16:30:29 +0000 Message-Id: <1453739429-31477-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:8b0:1d0::1 Cc: qemu-arm@nongnu.org, Franz-Josef Haider , patches@linaro.org Subject: [Qemu-devel] [PATCH] libvixl: Avoid std::abs() of 64-bit type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }