a3c9a8a3a86d783040a4bd8d235039e83c052bb5
3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 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
32 * \brief AVR-GCC special function attribute macros.
34 * This file contains macros for applying GCC specific attributes to functions to control various optimizer
35 * and code generation features of the compiler. Attributes may be placed in the function prototype in any
36 * order, and multiple attributes can be specified for a single function via a space separated list.
38 * On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are
39 * critical to the code's function and thus must throw a compiler error when used.
41 * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's
45 /** \ingroup Group_Common
46 * @defgroup Group_FuncAttr Function Attributes
48 * Macros for easy access GCC function attributes, which can be applied to function prototypes.
53 #ifndef __FUNCATTR_H__
54 #define __FUNCATTR_H__
56 /* Preprocessor Checks: */
57 #if !defined(__COMMON_H__)
58 #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.
61 /* Public Interface - May be used in end-application: */
63 #if (__GNUC__ >= 3) || defined(__DOXYGEN__)
64 /** Indicates to the compiler that the function can not ever return, so that any stack restoring or
65 * return code may be omitted by the compiler in the resulting binary.
67 #define ATTR_NO_RETURN __attribute__ ((noreturn))
69 /** Indicates that the function returns a value which should not be ignored by the user code. When
70 * applied, any ignored return value from calling the function will produce a compiler warning.
72 #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
74 /** Indicates that the specified parameters of the function are pointers which should never be NULL.
75 * When applied as a 1-based comma separated list the compiler will emit a warning if the specified
76 * parameters are known at compiler time to be NULL at the point of calling the function.
78 #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__)))
80 /** Removes any preamble or postamble from the function. When used, the function will not have any
81 * register or stack saving code. This should be used with caution, and when used the programmer
82 * is responsible for maintaining stack and register integrity.
84 #define ATTR_NAKED __attribute__ ((naked))
86 /** Prevents the compiler from considering a specified function for inlining. When applied, the given
87 * function will not be inlined under any circumstances.
89 #define ATTR_NO_INLINE __attribute__ ((noinline))
91 /** Forces the compiler to inline the specified function. When applied, the given function will be
92 * inlined under all circumstances.
94 #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
96 /** Indicates that the specified function is pure, in that it has no side-effects other than global
97 * or parameter variable access.
99 #define ATTR_PURE __attribute__ ((pure))
101 /** Indicates that the specified function is constant, in that it has no side effects other than
104 #define ATTR_CONST __attribute__ ((const))
106 /** Marks a given function as deprecated, which produces a warning if the function is called. */
107 #define ATTR_DEPRECATED __attribute__ ((deprecated))
109 /** Marks a function as a weak reference, which can be overridden by other functions with an
110 * identical name (in which case the weak reference is discarded at link time).
112 #define ATTR_WEAK __attribute__ ((weak))
115 /** Places the function in one of the initialization sections, which execute before the main function
116 * of the application. The init function number can be specified as "x", as an integer. Refer to the
117 * avr-libc manual for more information on the initialization sections.
119 #define ATTR_INIT_SECTION(x) __attribute__ ((naked, section (".init" #x )))
121 /** Marks a function as an alias for another function of name "x". */
122 #define ATTR_ALIAS(x) __attribute__ ((alias( #x )))