Abraham Marsen / Mbed 2 deprecated Jazz_Hands_Nordic

Dependencies:   mbed

Committer:
Grimmkey
Date:
Thu Apr 30 20:46:27 2015 +0000
Revision:
0:b8221deeaa87
Georgia Institute of Technology ECE 4180 Spring 2015 Jazz Hands project, Nordic nRF51822 half

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Grimmkey 0:b8221deeaa87 1 /**************************************************************************/
Grimmkey 0:b8221deeaa87 2 /*!
Grimmkey 0:b8221deeaa87 3 @file compiler.h
Grimmkey 0:b8221deeaa87 4 @author hathach (tinyusb.org)
Grimmkey 0:b8221deeaa87 5
Grimmkey 0:b8221deeaa87 6 @section LICENSE
Grimmkey 0:b8221deeaa87 7
Grimmkey 0:b8221deeaa87 8 Software License Agreement (BSD License)
Grimmkey 0:b8221deeaa87 9
Grimmkey 0:b8221deeaa87 10 Copyright (c) 2013, K. Townsend (microBuilder.eu)
Grimmkey 0:b8221deeaa87 11 All rights reserved.
Grimmkey 0:b8221deeaa87 12
Grimmkey 0:b8221deeaa87 13 Redistribution and use in source and binary forms, with or without
Grimmkey 0:b8221deeaa87 14 modification, are permitted provided that the following conditions are met:
Grimmkey 0:b8221deeaa87 15 1. Redistributions of source code must retain the above copyright
Grimmkey 0:b8221deeaa87 16 notice, this list of conditions and the following disclaimer.
Grimmkey 0:b8221deeaa87 17 2. Redistributions in binary form must reproduce the above copyright
Grimmkey 0:b8221deeaa87 18 notice, this list of conditions and the following disclaimer in the
Grimmkey 0:b8221deeaa87 19 documentation and/or other materials provided with the distribution.
Grimmkey 0:b8221deeaa87 20 3. Neither the name of the copyright holders nor the
Grimmkey 0:b8221deeaa87 21 names of its contributors may be used to endorse or promote products
Grimmkey 0:b8221deeaa87 22 derived from this software without specific prior written permission.
Grimmkey 0:b8221deeaa87 23
Grimmkey 0:b8221deeaa87 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
Grimmkey 0:b8221deeaa87 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Grimmkey 0:b8221deeaa87 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Grimmkey 0:b8221deeaa87 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
Grimmkey 0:b8221deeaa87 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Grimmkey 0:b8221deeaa87 29 INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Grimmkey 0:b8221deeaa87 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
Grimmkey 0:b8221deeaa87 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Grimmkey 0:b8221deeaa87 32 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
Grimmkey 0:b8221deeaa87 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Grimmkey 0:b8221deeaa87 34 */
Grimmkey 0:b8221deeaa87 35 /**************************************************************************/
Grimmkey 0:b8221deeaa87 36
Grimmkey 0:b8221deeaa87 37 /** \file
Grimmkey 0:b8221deeaa87 38 * \brief GCC Header
Grimmkey 0:b8221deeaa87 39 */
Grimmkey 0:b8221deeaa87 40
Grimmkey 0:b8221deeaa87 41 /** \ingroup Group_Compiler
Grimmkey 0:b8221deeaa87 42 * \defgroup Group_GCC GNU GCC
Grimmkey 0:b8221deeaa87 43 * @{
Grimmkey 0:b8221deeaa87 44 */
Grimmkey 0:b8221deeaa87 45
Grimmkey 0:b8221deeaa87 46 #ifndef _COMPILER_GCC_H_
Grimmkey 0:b8221deeaa87 47 #define _COMPILER_GCC_H_
Grimmkey 0:b8221deeaa87 48
Grimmkey 0:b8221deeaa87 49 #ifdef __cplusplus
Grimmkey 0:b8221deeaa87 50 extern "C" {
Grimmkey 0:b8221deeaa87 51 #endif
Grimmkey 0:b8221deeaa87 52
Grimmkey 0:b8221deeaa87 53 #include "projectconfig.h"
Grimmkey 0:b8221deeaa87 54
Grimmkey 0:b8221deeaa87 55 //#ifndef __GNUC__
Grimmkey 0:b8221deeaa87 56 // #define ATTR_ALWAYS_INLINE
Grimmkey 0:b8221deeaa87 57 // #define ATTR_CONST
Grimmkey 0:b8221deeaa87 58 //#else
Grimmkey 0:b8221deeaa87 59
Grimmkey 0:b8221deeaa87 60 #ifdef _TEST_
Grimmkey 0:b8221deeaa87 61 #define ATTR_ALWAYS_INLINE
Grimmkey 0:b8221deeaa87 62 #define STATIC_
Grimmkey 0:b8221deeaa87 63 #define INLINE_
Grimmkey 0:b8221deeaa87 64 #else
Grimmkey 0:b8221deeaa87 65 #define STATIC_ static
Grimmkey 0:b8221deeaa87 66 #define INLINE_ inline
Grimmkey 0:b8221deeaa87 67
Grimmkey 0:b8221deeaa87 68 #if CFG_DEBUG == 3
Grimmkey 0:b8221deeaa87 69 #define ATTR_ALWAYS_INLINE // no inline for debug = 3
Grimmkey 0:b8221deeaa87 70 #endif
Grimmkey 0:b8221deeaa87 71 #endif
Grimmkey 0:b8221deeaa87 72
Grimmkey 0:b8221deeaa87 73 #define ALIGN_OF(x) __alignof__(x)
Grimmkey 0:b8221deeaa87 74
Grimmkey 0:b8221deeaa87 75 /// Normally, the compiler places the objects it generates in sections like data or bss & function in text. Sometimes, however, you need additional sections, or you need certain particular variables to appear in special sections, for example to map to special hardware. The section attribute specifies that a variable (or function) lives in a particular section
Grimmkey 0:b8221deeaa87 76 #define ATTR_SECTION(section) __attribute__ ((#section))
Grimmkey 0:b8221deeaa87 77
Grimmkey 0:b8221deeaa87 78 /// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, an error that includes message is diagnosed. This is useful for compile-time checking
Grimmkey 0:b8221deeaa87 79 #define ATTR_ERROR(Message) __attribute__ ((error(Message)))
Grimmkey 0:b8221deeaa87 80
Grimmkey 0:b8221deeaa87 81 /// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, a warning that includes message is diagnosed. This is useful for compile-time checking
Grimmkey 0:b8221deeaa87 82 #define ATTR_WARNING(Message) __attribute__ ((warning(Message)))
Grimmkey 0:b8221deeaa87 83
Grimmkey 0:b8221deeaa87 84 /**
Grimmkey 0:b8221deeaa87 85 * \defgroup Group_VariableAttr Variable Attributes
Grimmkey 0:b8221deeaa87 86 * @{
Grimmkey 0:b8221deeaa87 87 */
Grimmkey 0:b8221deeaa87 88
Grimmkey 0:b8221deeaa87 89 /// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
Grimmkey 0:b8221deeaa87 90 #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
Grimmkey 0:b8221deeaa87 91
Grimmkey 0:b8221deeaa87 92 /// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute
Grimmkey 0:b8221deeaa87 93 #define ATTR_PACKED __attribute__ ((packed))
Grimmkey 0:b8221deeaa87 94
Grimmkey 0:b8221deeaa87 95 #define ATTR_PREPACKED
Grimmkey 0:b8221deeaa87 96
Grimmkey 0:b8221deeaa87 97 #define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed))
Grimmkey 0:b8221deeaa87 98 /** @} */
Grimmkey 0:b8221deeaa87 99
Grimmkey 0:b8221deeaa87 100 /**
Grimmkey 0:b8221deeaa87 101 * \defgroup Group_FuncAttr Function Attributes
Grimmkey 0:b8221deeaa87 102 * @{
Grimmkey 0:b8221deeaa87 103 */
Grimmkey 0:b8221deeaa87 104
Grimmkey 0:b8221deeaa87 105 #ifndef ATTR_ALWAYS_INLINE
Grimmkey 0:b8221deeaa87 106 /// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
Grimmkey 0:b8221deeaa87 107 #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
Grimmkey 0:b8221deeaa87 108 #endif
Grimmkey 0:b8221deeaa87 109
Grimmkey 0:b8221deeaa87 110 /// The nonnull attribute specifies that some function parameters should be non-null pointers. f the compiler determines that a null pointer is passed in an argument slot marked as non-null, and the -Wnonnull option is enabled, a warning is issued. All pointer arguments are marked as non-null
Grimmkey 0:b8221deeaa87 111 #define ATTR_NON_NULL __attribute__ ((nonull))
Grimmkey 0:b8221deeaa87 112
Grimmkey 0:b8221deeaa87 113 /// Many functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure
Grimmkey 0:b8221deeaa87 114 #define ATTR_PURE __attribute__ ((pure))
Grimmkey 0:b8221deeaa87 115
Grimmkey 0:b8221deeaa87 116 /// Many functions do not examine any values except their arguments, and have no effects except the return value. Basically this is just slightly more strict class than the pure attribute below, since function is not allowed to read global memory.
Grimmkey 0:b8221deeaa87 117 /// Note that a function that has pointer arguments and examines the data pointed to must not be declared const. Likewise, a function that calls a non-const function usually must not be const. It does not make sense for a const function to return void
Grimmkey 0:b8221deeaa87 118 #define ATTR_CONST __attribute__ ((const))
Grimmkey 0:b8221deeaa87 119
Grimmkey 0:b8221deeaa87 120 /// The deprecated attribute results in a warning if the function is used anywhere in the source file. This is useful when identifying functions that are expected to be removed in a future version of a program. The warning also includes the location of the declaration of the deprecated function, to enable users to easily find further information about why the function is deprecated, or what they should do instead. Note that the warnings only occurs for uses
Grimmkey 0:b8221deeaa87 121 #define ATTR_DEPRECATED __attribute__ ((deprecated))
Grimmkey 0:b8221deeaa87 122
Grimmkey 0:b8221deeaa87 123 /// Same as the deprecated attribute with optional message in the warning
Grimmkey 0:b8221deeaa87 124 #define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess)))
Grimmkey 0:b8221deeaa87 125
Grimmkey 0:b8221deeaa87 126 /// The weak attribute causes the declaration to be emitted as a weak symbol rather than a global. This is primarily useful in defining library functions that can be overridden in user code
Grimmkey 0:b8221deeaa87 127 #define ATTR_WEAK __attribute__ ((weak))
Grimmkey 0:b8221deeaa87 128
Grimmkey 0:b8221deeaa87 129 /// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
Grimmkey 0:b8221deeaa87 130 #define ATTR_ALIAS(func) __attribute__ ((alias(#func)))
Grimmkey 0:b8221deeaa87 131
Grimmkey 0:b8221deeaa87 132 /// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
Grimmkey 0:b8221deeaa87 133 #define ATTR_WEAKREF(func) __attribute__ ((weakref(#func)))
Grimmkey 0:b8221deeaa87 134
Grimmkey 0:b8221deeaa87 135 /// The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug
Grimmkey 0:b8221deeaa87 136 #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
Grimmkey 0:b8221deeaa87 137
Grimmkey 0:b8221deeaa87 138 /// This attribute, attached to a function, means that code must be emitted for the function even if it appears that the function is not referenced. This is useful, for example, when the function is referenced only in inline assembly.
Grimmkey 0:b8221deeaa87 139 #define ATTR_USED __attribute__ ((used))
Grimmkey 0:b8221deeaa87 140
Grimmkey 0:b8221deeaa87 141 /// This attribute, attached to a function, means that the function is meant to be possibly unused. GCC does not produce a warning for this function.
Grimmkey 0:b8221deeaa87 142 #define ATTR_UNUSED __attribute__ ((unused))
Grimmkey 0:b8221deeaa87 143
Grimmkey 0:b8221deeaa87 144 /** @} */
Grimmkey 0:b8221deeaa87 145
Grimmkey 0:b8221deeaa87 146 #ifdef __cplusplus
Grimmkey 0:b8221deeaa87 147 }
Grimmkey 0:b8221deeaa87 148 #endif
Grimmkey 0:b8221deeaa87 149
Grimmkey 0:b8221deeaa87 150 #endif /* _COMPILER_GCC_H_ */
Grimmkey 0:b8221deeaa87 151
Grimmkey 0:b8221deeaa87 152 /// @}