Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ssi_pal_compiler.h Source File

ssi_pal_compiler.h

Go to the documentation of this file.
00001 /**************************************************************************************
00002 * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved         *
00003 *                                                                                     *
00004 * This file and the related binary are licensed under the following license:          *
00005 *                                                                                     *
00006 * ARM Object Code and Header Files License, v1.0 Redistribution.                      *
00007 *                                                                                     *
00008 * Redistribution and use of object code, header files, and documentation, without     *
00009 * modification, are permitted provided that the following conditions are met:         *
00010 *                                                                                     *
00011 * 1) Redistributions must reproduce the above copyright notice and the                *
00012 *    following disclaimer in the documentation and/or other materials                 *
00013 *    provided with the distribution.                                                  *
00014 *                                                                                     *
00015 * 2) Unless to the extent explicitly permitted by law, no reverse                     *
00016 *    engineering, decompilation, or disassembly of is permitted.                      *
00017 *                                                                                     *
00018 * 3) Redistribution and use is permitted solely for the purpose of                    *
00019 *    developing or executing applications that are targeted for use                   *
00020 *    on an ARM-based product.                                                         *
00021 *                                                                                     *
00022 * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND                  *
00023 * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT             *
00024 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT,        *
00025 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE          *
00026 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   *
00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED            *
00028 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR              *
00029 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF              *
00030 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING                *
00031 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS                  *
00032 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                        *
00033 **************************************************************************************/
00034 
00035 
00036 #ifndef __SSI_PAL_COMPILER_H__
00037 #define __SSI_PAL_COMPILER_H__
00038 
00039 /*!
00040 @file
00041 @brief This file contains compiler related definitions.
00042 @defgroup ssi_pal_compiler CryptoCell PAL platform dependant compiler specific definitions
00043 @{
00044 @ingroup ssi_pal
00045 
00046 */
00047 
00048 #ifdef __GNUC__
00049 
00050 /************************ Defines ******************************/
00051 
00052 /*! Associate a symbol with a link section. */
00053 #define SASI_PAL_COMPILER_SECTION(sectionName)  __attribute__((section(sectionName)))
00054 
00055 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
00056 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
00057 
00058 /*! Make given data item aligned (alignment in bytes). */
00059 #define SASI_PAL_COMPILER_ALIGN(alignement)  __attribute__((aligned(alignement)))
00060 
00061 /*! Mark function that never returns. */
00062 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS __attribute__((noreturn))
00063 
00064 /*! Prevent function from being inlined */
00065 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE __attribute__((noinline))
00066 
00067 /*! Given data type may cast (alias) another data type pointer. */
00068 /* (this is used for "superclass" struct casting)             */
00069 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS __attribute__((__may_alias__))
00070 
00071 /*! Get sizeof for a structure type member. */
00072 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
00073     sizeof(((type_name *)0)->member_name)
00074 
00075 /*! Assertion. */
00076 #define SASI_ASSERT_CONCAT_(a, b) a##b
00077 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
00078 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
00079     enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
00080 
00081 #elif defined(__ARM_DSM__) || defined(__CC_ARM)
00082 #define inline
00083 /*! Associate a symbol with a link section. */
00084 #define SASI_PAL_COMPILER_SECTION(sectionName)  __attribute__((section(sectionName)))
00085 
00086 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
00087 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
00088 
00089 /*! Make given data item aligned (alignment in bytes). */
00090 #define SASI_PAL_COMPILER_ALIGN(alignement)  __attribute__((aligned(alignement)))
00091 
00092 /*! Mark function that never returns. */
00093 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS __attribute__((noreturn))
00094 
00095 /*! Prevent function from being inlined. */
00096 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE __attribute__((noinline))
00097 
00098 /*! Given data type may cast (alias) another data type pointer. */
00099 /* (this is used for "superclass" struct casting)             */
00100 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS __attribute__((__may_alias__))
00101 
00102 /*! Get sizeof for a structure type member. */
00103 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
00104     sizeof(((type_name *)0)->member_name)
00105 
00106 /*! Assertion. */
00107 #define SASI_ASSERT_CONCAT_(a, b) a##b
00108 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
00109 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
00110     enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
00111 #elif defined(__ARM_DS__)
00112 #define inline
00113 /*! Associate a symbol with a link section. */
00114 #define SASI_PAL_COMPILER_SECTION(sectionName)  __attribute__((section(sectionName)))
00115 
00116 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
00117 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
00118 
00119 /*! Make given data item aligned (alignment in bytes). */
00120 #define SASI_PAL_COMPILER_ALIGN(alignement)  __attribute__((aligned(alignement)))
00121 
00122 /*! Mark function that never returns. */
00123 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS __attribute__((noreturn))
00124 
00125 /*! Prevent function from being inlined. */
00126 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE __attribute__((noinline))
00127 
00128 /*! Given data type may cast (alias) another data type pointer. */
00129 /* (this is used for "superclass" struct casting)             */
00130 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS
00131 
00132 /*! Get sizeof for a structure type member. */
00133 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
00134     sizeof(((type_name *)0)->member_name)
00135 
00136 /*! Assertion. */
00137 #define SASI_ASSERT_CONCAT_(a, b) a##b
00138 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
00139 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
00140     enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
00141 #elif defined(__ICCARM__)
00142 
00143 /************************ Defines ******************************/
00144 
00145 /*! Associate a symbol with a link section. */
00146 #define SASI_PAL_COMPILER_SECTION(sectionName)  __attribute__((section(sectionName)))
00147 
00148 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
00149 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
00150 
00151 
00152 #define STRING_PRAGMA(x) _Pragma(#x)
00153 /*! Make given data item aligned (alignment in bytes).  Not implemented */
00154 /*  Used in crys_rsa_types.h. This is telling the compiler about buffer alignment. */
00155 /*  IAR treats alignment a bit different. Nonetheless, this is used only for RSA, which was not ported yet. */
00156 #define SASI_PAL_COMPILER_ALIGN(n)
00157 
00158 /*! Mark function that never returns. Not implemented. */
00159 /*  Not used anywhere, and probably located due to legacy reasons.*/
00160 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS
00161 
00162 /* Prevent function from being inlined */
00163 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE STRING_PRAGMA(optimize = no_inline)
00164 
00165 /*! Given data type may cast (alias) another data type pointer. */
00166 /* (this is used for "superclass" struct casting). Not implemented */
00167 /* Used in crys_rsa_local.h. for some compilers it translates to __may_alias__. */
00168 /* For IAR, there is probably no need for this attribute, as the typedef  */
00169 /* is equivalent. Nonetheless, this is RSA code, which was not yet ported to Mbed TLS.*/
00170 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS 
00171 
00172 /*! Get sizeof for a structure type member. */
00173 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
00174     sizeof(((type_name *)0)->member_name)
00175 
00176 /*! Assertion. */
00177 #define SASI_ASSERT_CONCAT_(a, b) a##b
00178 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
00179 
00180 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
00181     enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
00182 #else
00183 #error Unsupported compiler.
00184 #endif
00185 /**
00186 @}
00187  */
00188 #endif /*__SSI_PAL_COMPILER_H__*/