Nordic stack and drivers for the mbed BLE API

Dependents:   idd_hw5_bleFanProto

Fork of nRF51822 by Nordic Semiconductor

Committer:
pgao
Date:
Thu Nov 06 05:29:15 2014 +0000
Revision:
70:c36c550b7208
Parent:
0:eff01767de02
asdf

Who changed what in which revision?

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