3      Copyright (C) Dean Camera, 2009. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this  
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in  
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting  
  17   documentation, and that the name of the author not be used in  
  18   advertising or publicity pertaining to distribution of the  
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  This file contains macros for applying GCC specific attributes to functions to control various optimizer 
  34  *  and code generation features of the compiler. Attributes may be placed in the function prototype in any 
  35  *  order, and multiple attributes can be specified for a single function via a space separated list. 
  37  *  On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are 
  38  *  critical to the code's function and thus must throw a compiler error when used. 
  40  *  \note Do not include this file directly, rather include the Common.h header file instead to gain this file's 
  44 /** \ingroup Group_Common 
  45  *  @defgroup Group_FuncAttr Function Attributes 
  47  *  Macros for easy access GCC function attributes, which can be applied to function prototypes. 
  52 #ifndef __FUNCATTR_H__ 
  53 #define __FUNCATTR_H__ 
  55         /* Preprocessor Checks: */ 
  56                 #if !defined(__COMMON_H__) 
  57                         #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. 
  60         /* Public Interface - May be used in end-application: */ 
  62                         #if (__GNUC__ >= 3) || defined(__DOXYGEN__) 
  63                                 /** Indicates to the compiler that the function can not ever return, so that any stack restoring or 
  64                                  *  return code may be omitted by the compiler in the resulting binary. 
  66                                 #define ATTR_NO_RETURN              __attribute__ ((noreturn)) 
  68                                 /** Indicates that the function returns a value which should not be ignored by the user code. When 
  69                                  *  applied, any ignored return value from calling the function will produce a compiler warning. 
  71                                 #define ATTR_WARN_UNUSED_RESULT     __attribute__ ((warn_unused_result)) 
  73                                 /** Indicates that the specified parameters of the function are pointers which should never be NULL. 
  74                                  *  When applied as a 1-based comma separated list the compiler will emit a warning if the specified 
  75                                  *  parameters are known at compiler time to be NULL at the point of calling the function. 
  77                                 #define ATTR_NON_NULL_PTR_ARG(...)  __attribute__ ((nonnull (__VA_ARGS__))) 
  79                                 /** Removes any preamble or postamble from the function. When used, the function will not have any 
  80                                  *  register or stack saving code. This should be used with caution, and when used the programmer 
  81                                  *  is responsible for maintaining stack and register integrity. 
  83                                 #define ATTR_NAKED                  __attribute__ ((naked)) 
  85                                 /** Prevents the compiler from considering a specified function for inlining. When applied, the given 
  86                                  *  function will not be inlined under any circumstances. 
  88                                 #define ATTR_NO_INLINE              __attribute__ ((noinline)) 
  90                                 /** Forces the compiler to inline the specified function. When applied, the given function will be 
  91                                  *  inlined under all circumstances. 
  93                                 #define ATTR_ALWAYS_INLINE          __attribute__ ((always_inline)) 
  95                                 /** Indicates that the specified function is pure, in that it has no side-effects other than global 
  96                                  *  or parameter variable access. 
  98                                 #define ATTR_PURE                   __attribute__ ((pure)) 
 100                                 /** Indicates that the specified function is constant, in that it has no side effects other than 
 103                                 #define ATTR_CONST                  __attribute__ ((const)) 
 105                                 /** Marks a given function as deprecated, which produces a warning if the function is called. */ 
 106                                 #define ATTR_DEPRECATED             __attribute__ ((deprecated)) 
 108                                 /** Marks a function as a weak reference, which can be overridden by other functions with an 
 109                                  *  identical name (in which case the weak reference is discarded at link time). 
 111                                 #define ATTR_WEAK                   __attribute__ ((weak)) 
 114                         /** Places the function in one of the initialization sections, which execute before the main function 
 115                          *  of the application. The init function number can be specified as "x", as an integer. Refer to the 
 116                          *  avr-libc manual for more information on the initialization sections. 
 118                         #define ATTR_INIT_SECTION(x)        __attribute__ ((naked, section (".init" #x ))) 
 120                         /** Marks a function as an alias for another function of name "x". */ 
 121                         #define ATTR_ALIAS(x)               __attribute__ ((alias( #x )))