All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Anton Blanchard <anton@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org, paulus@samba.org, wschmidt@us.ibm.com
Subject: Re: BUG_ON and gcc don't mix
Date: Tue, 20 Aug 2013 14:02:11 +0930	[thread overview]
Message-ID: <20130820043211.GC3430@bubble.grove.modra.org> (raw)
In-Reply-To: <20130820123750.7353f2f1@kryten>

On Tue, Aug 20, 2013 at 12:37:50PM +1000, Anton Blanchard wrote:
> address of the trap instruction for our bug exception table. Maybe
> we need a gcc builtin in which we can get a label on the trap
> instruction. Would that be possible?

Not your actual _EMIT_BUG_ENTRY, but something like this ought to work.
The only trick here is not putting anything after __builtin_trap()..

#define BUG_ON(x) do { \
	if (x) {					\
		__asm__ __volatile__ ("\n1:"		\
			"\t.section __bug_table,\"a\""	\
			"\n\t.long 1b"			\
			"\n\t.previous");		\
                __builtin_trap();			\
	}						\
} while (0)

int foo(unsigned int *bar)
{
        unsigned int holder_cpu;

        holder_cpu = *bar & 0xffff;
        BUG_ON(holder_cpu >= 32);

        return 1;
}

-- 
Alan Modra
Australia Development Lab, IBM



-- 
Alan Modra
Australia Development Lab, IBM

  parent reply	other threads:[~2013-08-20  4:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20  2:37 BUG_ON and gcc don't mix Anton Blanchard
2013-08-20  4:24 ` Benjamin Herrenschmidt
2013-08-20  4:32 ` Alan Modra [this message]
2013-08-20  4:45   ` Alan Modra
2013-08-20  8:36     ` David Laight
2013-08-20 10:55       ` Anton Blanchard

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=20130820043211.GC3430@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=anton@samba.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    --cc=wschmidt@us.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.