テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

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