test code 123

Dependencies:   mbed

Fork of LinkNode-Test by Qi Yao

Committer:
youkee
Date:
Thu Sep 01 05:14:03 2016 +0000
Revision:
0:1ad0e04b1bc5
change internal time from 1s to 200ms

Who changed what in which revision?

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