Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature...
[pub/USBasp.git] / LUFA / Common / FunctionAttributes.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 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.
20
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
28 this software.
29 */
30
31 /** \file
32 *
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.
36 *
37 * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's
38 * functionality.
39 */
40
41 /** \ingroup Group_Common
42 * @defgroup Group_FuncAttr Function Attributes
43 *
44 * Macros for easy access GCC function attributes, which can be applied to function prototypes.
45 *
46 * @{
47 */
48
49 #ifndef __FUNCATTR_H__
50 #define __FUNCATTR_H__
51
52 /* Preprocessor Checks: */
53 #if !defined(__COMMON_H__)
54 #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.
55 #endif
56
57 /* Public Interface - May be used in end-application: */
58 /* Macros: */
59 /** Indicates to the compiler that the function can not ever return, so that any stack restoring or
60 * return code may be omitted by the compiler in the resulting binary.
61 */
62 #define ATTR_NO_RETURN __attribute__ ((noreturn))
63
64 /** Places the function in one of the initialization sections, which execute before the main function
65 * of the application. The init function number can be specified as "x", as an integer. Refer to the
66 * avr-libc manual for more information on the initialization sections.
67 */
68 #define ATTR_INIT_SECTION(x) __attribute__ ((naked, section (".init" #x )))
69
70 /** Indicates that the function returns a value which should not be ignored by the user code. When
71 * applied, any ignored return value from calling the function will produce a compiler warning.
72 */
73 #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
74
75 /** Indicates that the specified parameters of the function are pointers which should never be NULL.
76 * When applied as a 1-based comma separated list the compiler will emit a warning if the specified
77 * parameters are known at compiler time to be NULL at the point of calling the function.
78 */
79 #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__)))
80
81 /** Removes any preamble or postamble from the function. When used, the function will not have any
82 * register or stack saving code. This should be used with caution, and when used the programmer
83 * is responsible for maintaining stack and register integrity.
84 */
85 #define ATTR_NAKED __attribute__ ((naked))
86
87 /** Prevents the compiler from considering a specified function for inlining. When applied, the given
88 * function will not be inlined under any circumstances.
89 */
90 #define ATTR_NOINLINE __attribute__ ((noinline))
91
92 /** Forces the compiler to inline the specified function. When applied, the given function will be
93 * inlined under all circumstances.
94 */
95 #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
96
97 /** Indicates that the specified function is pure, in that it has no side-effects other than global
98 * or parameter variable access.
99 */
100 #define ATTR_PURE __attribute__ ((pure))
101
102 /** Indicates that the specified function is constant, in that it has no side effects other than
103 * parameter access.
104 */
105 #define ATTR_CONST __attribute__ ((const))
106
107 /** Marks a given function as deprecated, which produces a warning if the function is called. */
108 #define ATTR_DEPRECATED __attribute__ ((deprecated))
109
110 /** Marks a function as a weak reference, which can be overridden by other functions with an
111 * identical name (in which case the weak reference is discarded at link time).
112 */
113 #define ATTR_WEAK __attribute__ ((weak))
114
115 /** Marks a function as an alias for another function of name "x". */
116 #define ATTR_ALIAS(x) __attribute__ ((alias( #x )))
117
118 #endif
119
120 /** @} */