linux-mips
[Top] [All Lists]

Re: [PATCH] MIPS: Make BUG() __noreturn.

To: Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: Make BUG() __noreturn.
From: "Maciej W. Rozycki" <macro@linux-mips.org>
Date: Mon, 24 Nov 2008 19:04:40 +0000 (GMT)
Cc: Geert Uytterhoeven <geert@linux-m68k.org>, David Daney <ddaney@caviumnetworks.com>, gcc@gcc.gnu.org, Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-mips <linux-mips@linux-mips.org>, linux-kernel@vger.kernel.org, Adam Nemet <anemet@caviumnetworks.com>
In-reply-to: <20081121221619.GB28154@linux-mips.org>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <49260E4C.8080500@caviumnetworks.com> <20081121100035.3f5a640b@lxorguk.ukuu.org.uk> <Pine.LNX.4.64.0811211126420.26004@anakin> <4926E499.4070706@caviumnetworks.com> <Pine.LNX.4.64.0811211940450.29539@anakin> <20081121221619.GB28154@linux-mips.org>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Alpine 1.10 (LFD 962 2008-03-14)
On Fri, 21 Nov 2008, Ralf Baechle wrote:

> MIPS ISA newer than MIPS I also have conditional break codes allowing
> something like this:
> 
> #define BUG_ON(condition)                                               \
> do {                                                                    \
>         __asm__ __volatile__("tne $0, %0, %1"                           \
>                              : : "r" (condition), "i" (BRK_BUG));       \
> } while (0)
> 
> that is test of condition and the trap as a single instruction.  Note there
> are break and trap instructions on MIPS and they are basically doing the
> same job ...

 GCC is actually smart enough to combine sequences like:

if (something)
        __builtin_trap();

into appropriate conditional trap instructions on MIPS.  As noted by David 
trap codes other than the default cannot be emitted this way though.

  Maciej

<Prev in Thread] Current Thread [Next in Thread>