public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gjl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/53256] New: [avr] Attribute 'interrupt' shall override attribute 'signal'
Date: Sun, 06 May 2012 11:41:00 -0000	[thread overview]
Message-ID: <bug-53256-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53256

             Bug #: 53256
           Summary: [avr] Attribute 'interrupt' shall override attribute
                    'signal'
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: gjl@gcc.gnu.org
        ReportedBy: gjl@gcc.gnu.org
                CC: j@uriah.heep.sax.de
            Target: avr


AVR-LibC offered attributes 'interrupt' and 'signal' as INTERRUPT and SIGNAL
through its API.  This changed at some point in time to ISR which may lead to
code that adds attribute 'interrupt' and attribute 'signal' at the same time.

This leads to code that is not IRQ-safe in the current implementation which is:

1) Attributes 'interrupt' and 'signal' are exclusive. Specifying both at the
same time for the same function has not a well-defined behavior.

2) 'interrupt' emits a SEI instruction as the very first instruction of the
function.

3) Neither attributes make assumptions on the function's worker code. In
particular, they do *not* assume that interrupts are not (re-)enabled by the
user code.  Thus, it is safe to enable IRQs at any place in the function body. 
This "safe" covers only the generated code and IRQ-safeness of SP changes and
the instructions themselves, it does *not* cover the IRQ and timing layout of
the application.

4) The AVR hardware globally disables IRQs when an IRQ is raised. This allows
more efficient code in 'signal' prologues compared to 'interrupt' prologues in
cases where the stack pointer has to be written.  Writing SP is not an atomic
operation on all devices, and special precautions must be taken if SP is
written and IRQs might be on.


As of this extension request 1) shall be changed to:

1') Attribute 'interrupt' shall override attribute 'signal'. No warning should
be issued in such a case.  The documentation should be extended.


             reply	other threads:[~2012-05-06 11:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-06 11:41 gjl at gcc dot gnu.org [this message]
2012-05-06 12:27 ` [Bug target/53256] " gjl at gcc dot gnu.org
2012-05-09 16:40 ` gjl at gcc dot gnu.org
2012-05-09 16:41 ` gjl at gcc dot gnu.org
2012-05-09 17:11 ` gjl at gcc dot gnu.org
2012-06-08 22:42 ` gjl at gcc dot gnu.org

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=bug-53256-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).