avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Re: More interrupt oddity


From: Peter N Lewis
Subject: [avr-gcc-list] Re: More interrupt oddity
Date: Sun, 21 Oct 2001 08:59:09 +0800

On 21 Oct 2001, at 12:01, address@hidden wrote:

 > The goofy part is that the linker didn't give any errors or warnings
 that something may be wrong. Shouldn't it fail with an undefined
 > symbol or something?

If you look in the docs, aka sig-avr.h, you see that:

#define SIG_INTERRUPT0 _interrupt0_

SIG_INTERRUPT0 is just defined to be the name of the routine (_interrupt0_), and that name (_interrupt0_) happens to be used in the jump table, so the linker knows it can be called.

#define SIGNAL(signame)                                 \
void signame (void) __attribute__ ((signal));           \
void signame (void)

So your code just ended up being:

void SIG_INTERRUPT0 (void) __attribute__ ((signal));
void SIG_INTERRUPT0 (void)

This is just a function which preserves more registers and flags than normal. And it is never called, so I guess the linker would be free to remove it entirely or optimize away all the code which has no effect.

There isn't ny good way for the code to defend against this problem, unless there was perhaps some what to add to the #define a warning if the input parameter was SIG_* since that would presumably indicate a misspelling.

Enjoy,
   Peter.

--
Sungroper Solar Car Association <http://www.sungroper.asn.au/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]