Nordic stack and drivers for the mbed BLE API. Version to work around build bug.

Dependents:   microbit_rubber_ducky microbit_mouse_BLE microbit_mouse_BLE_daybreak_version microbit_presenter

Fork of nRF51822 by Nordic Semiconductor

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers compiler.h Source File

compiler.h

Go to the documentation of this file.
00001 /**************************************************************************/
00002 /*!
00003     @file     compiler.h
00004     @author   hathach (tinyusb.org)
00005 
00006     @section LICENSE
00007 
00008     Software License Agreement (BSD License)
00009 
00010     Copyright (c) 2013, K. Townsend (microBuilder.eu)
00011     All rights reserved.
00012 
00013     Redistribution and use in source and binary forms, with or without
00014     modification, are permitted provided that the following conditions are met:
00015     1. Redistributions of source code must retain the above copyright
00016     notice, this list of conditions and the following disclaimer.
00017     2. Redistributions in binary form must reproduce the above copyright
00018     notice, this list of conditions and the following disclaimer in the
00019     documentation and/or other materials provided with the distribution.
00020     3. Neither the name of the copyright holders nor the
00021     names of its contributors may be used to endorse or promote products
00022     derived from this software without specific prior written permission.
00023 
00024     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
00025     EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00026     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00028     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029     INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
00031     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00032     INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
00033     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 */
00035 /**************************************************************************/
00036 
00037 /** \file
00038  *  \brief GCC Header
00039  */
00040 
00041 /** \ingroup Group_Compiler
00042  *  \defgroup Group_GCC GNU GCC
00043  *  @{
00044  */
00045 
00046 #ifndef _COMPILER_GCC_H_
00047 #define _COMPILER_GCC_H_
00048 
00049 #ifdef __cplusplus
00050  extern "C" {
00051 #endif
00052 
00053 #include "projectconfig.h"
00054 
00055 //#ifndef __GNUC__
00056 //  #define ATTR_ALWAYS_INLINE
00057 //  #define ATTR_CONST
00058 //#else
00059 
00060 #ifdef _TEST_
00061   #define ATTR_ALWAYS_INLINE
00062   #define STATIC_
00063   #define INLINE_
00064 #else
00065   #define STATIC_ static
00066   #define INLINE_ inline
00067 
00068   #if CFG_DEBUG == 3
00069     #define ATTR_ALWAYS_INLINE  // no inline for debug = 3
00070   #endif
00071 #endif
00072 
00073 #define ALIGN_OF(x)                __alignof__(x)
00074 
00075 /// 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
00076 #define ATTR_SECTION(section)      __attribute__ ((#section))
00077 
00078 /// 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
00079 #define ATTR_ERROR(Message)        __attribute__ ((error(Message)))
00080 
00081 /// 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
00082 #define ATTR_WARNING(Message)      __attribute__ ((warning(Message)))
00083 
00084 /**
00085  *  \defgroup Group_VariableAttr Variable Attributes
00086  *  @{
00087  */
00088 
00089 /// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
00090 #define ATTR_ALIGNED(Bytes)        __attribute__ ((aligned(Bytes)))
00091 
00092 /// 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
00093 #define ATTR_PACKED                __attribute__ ((packed))
00094 
00095 #define ATTR_PREPACKED
00096 
00097 #define ATTR_PACKED_STRUCT(x)    x __attribute__ ((packed))
00098 /** @} */
00099 
00100 /**
00101  *  \defgroup Group_FuncAttr Function Attributes
00102  *  @{
00103  */
00104 
00105 #ifndef ATTR_ALWAYS_INLINE
00106 /// 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
00107 #define ATTR_ALWAYS_INLINE         __attribute__ ((always_inline))
00108 #endif
00109 
00110 /// 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
00111 #define ATTR_NON_NULL              __attribute__ ((nonull))
00112 
00113 /// 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
00114 #define ATTR_PURE                  __attribute__ ((pure))
00115 
00116 /// 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.
00117 /// 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
00118 #define ATTR_CONST                 __attribute__ ((const))
00119 
00120 /// 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
00121 #define ATTR_DEPRECATED            __attribute__ ((deprecated))
00122 
00123 /// Same as the deprecated attribute with optional message in the warning
00124 #define ATTR_DEPRECATED_MESS(mess) __attribute__ ((deprecated(mess)))
00125 
00126 /// 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
00127 #define ATTR_WEAK                  __attribute__ ((weak))
00128 
00129 /// The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified
00130 #define ATTR_ALIAS(func)           __attribute__ ((alias(#func)))
00131 
00132 /// The weakref attribute marks a declaration as a weak reference. It is equivalent with weak + alias attribute, but require function is static
00133 #define ATTR_WEAKREF(func)         __attribute__ ((weakref(#func)))
00134 
00135 /// 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
00136 #define ATTR_WARN_UNUSED_RESULT    __attribute__ ((warn_unused_result))
00137 
00138 /// 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.
00139 #define ATTR_USED                  __attribute__ ((used))
00140 
00141 /// 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.
00142 #define ATTR_UNUSED                __attribute__ ((unused))
00143 
00144 /** @} */
00145 
00146 #ifdef __cplusplus
00147  }
00148 #endif
00149 
00150 #endif /* _COMPILER_GCC_H_ */
00151 
00152 /// @}