linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org, Stephen Rothwell <sfr@canb.auug.org.au>
Subject: [PATCH] Use __builtin_trap() to indicate that BUG() never returns
Date: Thu, 21 Sep 2006 16:48:40 +1000	[thread overview]
Message-ID: <20060921064840.9F31367BB8@ozlabs.org> (raw)

By using __builtin_trap() in BUG() we tell the compiler that we
don't expect the code below to be executed, and in certain circumstances
this allows the compiler to elide that code altogether.

In fact it works so well that we have to put the bug section stuff
before the __builtin_trap() or else it isn't generated at all.

Tested on P5 LPAR, line numbers etc. all OK.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---

 include/asm-powerpc/bug.h |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Index: to-merge/include/asm-powerpc/bug.h
===================================================================
--- to-merge.orig/include/asm-powerpc/bug.h
+++ to-merge/include/asm-powerpc/bug.h
@@ -37,12 +37,13 @@ struct bug_entry *find_bug(unsigned long
  */
 
 #define BUG() do {							 \
-	__asm__ __volatile__(						 \
-		"1:	twi 31,0,0\n"					 \
+       __asm__ __volatile__(                                            \
 		".section __bug_table,\"a\"\n"				 \
-		"\t"PPC_LONG"	1b,%0,%1,%2\n"				 \
-		".previous"						 \
+		"\t"PPC_LONG"	1f,%0,%1,%2\n"				 \
+		".previous\n"						 \
+                "1:     "                                           \
 		: : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
+       __builtin_trap();                                                \
 } while (0)
 
 #define BUG_ON(x) do {						\

                 reply	other threads:[~2006-09-21  6:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060921064840.9F31367BB8@ozlabs.org \
    --to=michael@ellerman.id.au \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).