diff mbox

[DOC] Attribute 'naked'

Message ID 539FEBAD.20408@LimeGreenSocks.com
State New
Headers show

Commit Message

David Wohlferd June 17, 2014, 7:18 a.m. UTC
I don't have permissions to commit this patch, but I do have a release 
on file with the FSF.

Problem description:
The docs for the function attribute 'naked' are confusing and 
self-contradictory.  Also, discussion on this thread 
https://gcc.gnu.org/ml/gcc/2014-05/msg00100.html has lead to changing 
the text from the vague "avoid using" to the very clear "not supported" 
regarding the usage of Extended asm with 'naked.'  Lastly, this 
attribute should be mentioned when describing the differences between 
Basic and Extended asm.

ChangeLog:
2014-06-17  David Wohlferd <dw@LimeGreenSocks.com>

         * doc/extend.texi (Function Attributes): Update 'naked' 
attribute doc.

dw

Comments

Gerald Pfeifer June 25, 2014, 11:20 p.m. UTC | #1
On Tue, 17 Jun 2014, David Wohlferd wrote:
> 2014-06-17  David Wohlferd <dw@LimeGreenSocks.com>
> 
>         * doc/extend.texi (Function Attributes): Update 'naked' attribute doc.

This patch makes sense to me and I've seen feedback on an earlier
iteration that lead to this now.  So, I am planning to commit this
unless anyone objects in the next day or two.

Gerald
Gerald Pfeifer June 29, 2014, 9:22 p.m. UTC | #2
On Thu, 26 Jun 2014, Gerald Pfeifer wrote:
>> 2014-06-17  David Wohlferd <dw@LimeGreenSocks.com>
>> 
>>         * doc/extend.texi (Function Attributes): Update 'naked' attribute
>> doc.
> This patch makes sense to me and I've seen feedback on an earlier
> iteration that lead to this now.  So, I am planning to commit this
> unless anyone objects in the next day or two.

Done.  The patch is in after another round of (bootstrap) testing
on i386-unknown-freebsd10.0.

Thanks for the contribution and patience, David!

Gerald
diff mbox

Patch

Index: extend.texi
===================================================================
--- extend.texi	(revision 210624)
+++ extend.texi	(working copy)
@@ -3332,16 +3332,15 @@ 
 
 @item naked
 @cindex function without a prologue/epilogue code
-Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU
-ports to indicate that the specified function does not need prologue/epilogue
-sequences generated by the compiler.
-It is up to the programmer to provide these sequences. The
-only statements that can be safely included in naked functions are
-@code{asm} statements that do not have operands.  All other statements,
-including declarations of local variables, @code{if} statements, and so
-forth, should be avoided.  Naked functions should be used to implement the
-body of an assembly function, while allowing the compiler to construct
-the requisite function declaration for the assembler.
+This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32,
+RL78, RX and SPU ports.  It allows the compiler to construct the
+requisite function declaration, while allowing the body of the
+function to be assembly code. The specified function will not have
+prologue/epilogue sequences generated by the compiler. Only Basic
+@code{asm} statements can safely be included in naked functions
+(@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of
+Basic @code{asm} and ``C'' code may appear to work, they cannot be
+depended upon to work reliably and are not supported.
 
 @item near
 @cindex functions that do not handle memory bank switching on 68HC11/68HC12
@@ -6269,6 +6268,8 @@ 
 efficient code, and in most cases it is a better solution. When writing 
 inline assembly language outside of C functions, however, you must use Basic 
 @code{asm}. Extended @code{asm} statements have to be inside a C function.
+Functions declared with the @code{naked} attribute also require Basic 
+@code{asm} (@pxref{Function Attributes}).
 
 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
 assembly code when optimizing. This can lead to unexpected duplicate 
@@ -6388,6 +6389,8 @@ 
 
 Note that Extended @code{asm} statements must be inside a function. Only 
 Basic @code{asm} may be outside functions (@pxref{Basic Asm}).
+Functions declared with the @code{naked} attribute also require Basic 
+@code{asm} (@pxref{Function Attributes}).
 
 While the uses of @code{asm} are many and varied, it may help to think of an 
 @code{asm} statement as a series of low-level instructions that convert input