[Top][All Lists]

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

Re: [avr-libc-dev] Cool, looks like it may work...

From: Björn Haase
Subject: Re: [avr-libc-dev] Cool, looks like it may work...
Date: Tue, 1 Nov 2005 21:55:38 +0100
User-agent: KMail/1.7.1

Darcy Watkins wrote on Dienstag, 1. November 2005 19:42 :
> void myfunction (void) __attribute__ ((naked));
> void myfunction (void)
> {
>       // my code inserted here...
> }
Frankly speaking I don't recognize why something like this should be useful. 
IMO doing this is something really unsafe that should not be encouraged to be 
done at all. I know that IRQ prologues are not ideal for AVR. However the 
right solution for cases where timing/memory is so extremely critical that 
the standard prologues could not be used is, IMO, to use assembly functions.

When using prologue macros the problem always will be that you will have to 
save possibly *more* registers than are actually used by the function (in 
order to be on the safe side) and secondly, you will never be able to capture 
the cases where the prologue allocates memory on the stack. E.g., we recently 
had a problem report where some function call in a "naked" function happened 
to end up to be inlined so that more registers needed to be saved and even a 
couple of bytes of stack memory was necessary. This recent PR showed me, that 
IMO one should discourage any use of the __naked__ attribute unless one is 
always controlling the assembly output. In this case, however, one probably 
is better off with using assembly right away.


reply via email to

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