Official Sheffield ARMBand micro:bit program

Committer:
MrBedfordVan
Date:
Mon Oct 17 12:41:20 2016 +0000
Revision:
0:b9164b348919
Official Sheffield ARMBand Micro:bit program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MrBedfordVan 0:b9164b348919 1 /**************************************************************************/
MrBedfordVan 0:b9164b348919 2 /*!
MrBedfordVan 0:b9164b348919 3 @file compiler.h
MrBedfordVan 0:b9164b348919 4 @author hathach (tinyusb.org)
MrBedfordVan 0:b9164b348919 5
MrBedfordVan 0:b9164b348919 6 @section LICENSE
MrBedfordVan 0:b9164b348919 7
MrBedfordVan 0:b9164b348919 8 Software License Agreement (BSD License)
MrBedfordVan 0:b9164b348919 9
MrBedfordVan 0:b9164b348919 10 Copyright (c) 2013, K. Townsend (microBuilder.eu)
MrBedfordVan 0:b9164b348919 11 All rights reserved.
MrBedfordVan 0:b9164b348919 12
MrBedfordVan 0:b9164b348919 13 Redistribution and use in source and binary forms, with or without
MrBedfordVan 0:b9164b348919 14 modification, are permitted provided that the following conditions are met:
MrBedfordVan 0:b9164b348919 15 1. Redistributions of source code must retain the above copyright
MrBedfordVan 0:b9164b348919 16 notice, this list of conditions and the following disclaimer.
MrBedfordVan 0:b9164b348919 17 2. Redistributions in binary form must reproduce the above copyright
MrBedfordVan 0:b9164b348919 18 notice, this list of conditions and the following disclaimer in the
MrBedfordVan 0:b9164b348919 19 documentation and/or other materials provided with the distribution.
MrBedfordVan 0:b9164b348919 20 3. Neither the name of the copyright holders nor the
MrBedfordVan 0:b9164b348919 21 names of its contributors may be used to endorse or promote products
MrBedfordVan 0:b9164b348919 22 derived from this software without specific prior written permission.
MrBedfordVan 0:b9164b348919 23
MrBedfordVan 0:b9164b348919 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
MrBedfordVan 0:b9164b348919 25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
MrBedfordVan 0:b9164b348919 26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
MrBedfordVan 0:b9164b348919 27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
MrBedfordVan 0:b9164b348919 28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
MrBedfordVan 0:b9164b348919 29 INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
MrBedfordVan 0:b9164b348919 30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
MrBedfordVan 0:b9164b348919 31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
MrBedfordVan 0:b9164b348919 32 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
MrBedfordVan 0:b9164b348919 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
MrBedfordVan 0:b9164b348919 34 */
MrBedfordVan 0:b9164b348919 35 /**************************************************************************/
MrBedfordVan 0:b9164b348919 36
MrBedfordVan 0:b9164b348919 37 /** \file
MrBedfordVan 0:b9164b348919 38 * \brief GCC Header
MrBedfordVan 0:b9164b348919 39 */
MrBedfordVan 0:b9164b348919 40
MrBedfordVan 0:b9164b348919 41 /** \ingroup Group_Compiler
MrBedfordVan 0:b9164b348919 42 * \defgroup Group_GCC GNU GCC
MrBedfordVan 0:b9164b348919 43 * @{
MrBedfordVan 0:b9164b348919 44 */
MrBedfordVan 0:b9164b348919 45
MrBedfordVan 0:b9164b348919 46 #ifndef _COMPILER_GCC_H_
MrBedfordVan 0:b9164b348919 47 #define _COMPILER_GCC_H_
MrBedfordVan 0:b9164b348919 48
MrBedfordVan 0:b9164b348919 49 #ifdef __cplusplus
MrBedfordVan 0:b9164b348919 50 extern "C" {
MrBedfordVan 0:b9164b348919 51 #endif
MrBedfordVan 0:b9164b348919 52
MrBedfordVan 0:b9164b348919 53 #include "projectconfig.h"
MrBedfordVan 0:b9164b348919 54
MrBedfordVan 0:b9164b348919 55 //#ifndef __GNUC__
MrBedfordVan 0:b9164b348919 56 // #define ATTR_ALWAYS_INLINE
MrBedfordVan 0:b9164b348919 57 // #define ATTR_CONST
MrBedfordVan 0:b9164b348919 58 //#else
MrBedfordVan 0:b9164b348919 59
MrBedfordVan 0:b9164b348919 60 #ifdef _TEST_
MrBedfordVan 0:b9164b348919 61 #define ATTR_ALWAYS_INLINE
MrBedfordVan 0:b9164b348919 62 #define STATIC_
MrBedfordVan 0:b9164b348919 63 #define INLINE_
MrBedfordVan 0:b9164b348919 64 #else
MrBedfordVan 0:b9164b348919 65 #define STATIC_ static
MrBedfordVan 0:b9164b348919 66 #define INLINE_ inline
MrBedfordVan 0:b9164b348919 67
MrBedfordVan 0:b9164b348919 68 #if CFG_DEBUG == 3
MrBedfordVan 0:b9164b348919 69 #define ATTR_ALWAYS_INLINE // no inline for debug = 3
MrBedfordVan 0:b9164b348919 70 #endif
MrBedfordVan 0:b9164b348919 71 #endif
MrBedfordVan 0:b9164b348919 72
MrBedfordVan 0:b9164b348919 73 #define ALIGN_OF(x) __alignof__(x)
MrBedfordVan 0:b9164b348919 74
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 76 #define ATTR_SECTION(section) __attribute__ ((#section))
MrBedfordVan 0:b9164b348919 77
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 79 #define ATTR_ERROR(Message) __attribute__ ((error(Message)))
MrBedfordVan 0:b9164b348919 80
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 82 #define ATTR_WARNING(Message) __attribute__ ((warning(Message)))
MrBedfordVan 0:b9164b348919 83
MrBedfordVan 0:b9164b348919 84 /**
MrBedfordVan 0:b9164b348919 85 * \defgroup Group_VariableAttr Variable Attributes
MrBedfordVan 0:b9164b348919 86 * @{
MrBedfordVan 0:b9164b348919 87 */
MrBedfordVan 0:b9164b348919 88
MrBedfordVan 0:b9164b348919 89 /// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
MrBedfordVan 0:b9164b348919 90 #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
MrBedfordVan 0:b9164b348919 91
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 93 #define ATTR_PACKED __attribute__ ((packed))
MrBedfordVan 0:b9164b348919 94
MrBedfordVan 0:b9164b348919 95 #define ATTR_PREPACKED
MrBedfordVan 0:b9164b348919 96
MrBedfordVan 0:b9164b348919 97 #define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed))
MrBedfordVan 0:b9164b348919 98 /** @} */
MrBedfordVan 0:b9164b348919 99
MrBedfordVan 0:b9164b348919 100 /**
MrBedfordVan 0:b9164b348919 101 * \defgroup Group_FuncAttr Function Attributes
MrBedfordVan 0:b9164b348919 102 * @{
MrBedfordVan 0:b9164b348919 103 */
MrBedfordVan 0:b9164b348919 104
MrBedfordVan 0:b9164b348919 105 #ifndef ATTR_ALWAYS_INLINE
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 107 #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))
MrBedfordVan 0:b9164b348919 108 #endif
MrBedfordVan 0:b9164b348919 109
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 111 #define ATTR_NON_NULL __attribute__ ((nonull))
MrBedfordVan 0:b9164b348919 112
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 114 #define ATTR_PURE __attribute__ ((pure))
MrBedfordVan 0:b9164b348919 115
MrBedfordVan 0:b9164b348919 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.
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 118 #define ATTR_CONST __attribute__ ((const))
MrBedfordVan 0:b9164b348919 119
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 121 #define ATTR_DEPRECATED __attribute__ ((deprecated))
MrBedfordVan 0:b9164b348919 122
MrBedfordVan 0:b9164b348919 123 /// Same as the deprecated attribute with optional message in the warning
MrBedfordVan 0:b9164b348919 124 #define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess)))
MrBedfordVan 0:b9164b348919 125
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 127 #define ATTR_WEAK __attribute__ ((weak))
MrBedfordVan 0:b9164b348919 128
MrBedfordVan 0:b9164b348919 129 /// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
MrBedfordVan 0:b9164b348919 130 #define ATTR_ALIAS(func) __attribute__ ((alias(#func)))
MrBedfordVan 0:b9164b348919 131
MrBedfordVan 0:b9164b348919 132 /// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
MrBedfordVan 0:b9164b348919 133 #define ATTR_WEAKREF(func) __attribute__ ((weakref(#func)))
MrBedfordVan 0:b9164b348919 134
MrBedfordVan 0:b9164b348919 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
MrBedfordVan 0:b9164b348919 136 #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
MrBedfordVan 0:b9164b348919 137
MrBedfordVan 0:b9164b348919 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.
MrBedfordVan 0:b9164b348919 139 #define ATTR_USED __attribute__ ((used))
MrBedfordVan 0:b9164b348919 140
MrBedfordVan 0:b9164b348919 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.
MrBedfordVan 0:b9164b348919 142 #define ATTR_UNUSED __attribute__ ((unused))
MrBedfordVan 0:b9164b348919 143
MrBedfordVan 0:b9164b348919 144 /** @} */
MrBedfordVan 0:b9164b348919 145
MrBedfordVan 0:b9164b348919 146 #ifdef __cplusplus
MrBedfordVan 0:b9164b348919 147 }
MrBedfordVan 0:b9164b348919 148 #endif
MrBedfordVan 0:b9164b348919 149
MrBedfordVan 0:b9164b348919 150 #endif /* _COMPILER_GCC_H_ */
MrBedfordVan 0:b9164b348919 151
MrBedfordVan 0:b9164b348919 152 /// @}