Mistake on this page?
Report an issue in GitHub or email us
ssi_pal_compiler.h
Go to the documentation of this file.
1 /**************************************************************************************
2 * Copyright (c) 2016-2017, ARM Limited or its affiliates. All rights reserved *
3 * *
4 * This file and the related binary are licensed under the following license: *
5 * *
6 * ARM Object Code and Header Files License, v1.0 Redistribution. *
7 * *
8 * Redistribution and use of object code, header files, and documentation, without *
9 * modification, are permitted provided that the following conditions are met: *
10 * *
11 * 1) Redistributions must reproduce the above copyright notice and the *
12 * following disclaimer in the documentation and/or other materials *
13 * provided with the distribution. *
14 * *
15 * 2) Unless to the extent explicitly permitted by law, no reverse *
16 * engineering, decompilation, or disassembly of is permitted. *
17 * *
18 * 3) Redistribution and use is permitted solely for the purpose of *
19 * developing or executing applications that are targeted for use *
20 * on an ARM-based product. *
21 * *
22 * DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
23 * CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT *
24 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, *
25 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED *
28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
33 **************************************************************************************/
34 
35 
36 #ifndef __SSI_PAL_COMPILER_H__
37 #define __SSI_PAL_COMPILER_H__
38 
39 /*!
40 @file
41 @brief This file contains compiler related definitions.
42 @defgroup ssi_pal_compiler CryptoCell PAL platform dependant compiler specific definitions
43 @{
44 @ingroup ssi_pal
45 
46 */
47 
48 #ifdef __GNUC__
49 
50 /************************ Defines ******************************/
51 
52 /*! Associate a symbol with a link section. */
53 #define SASI_PAL_COMPILER_SECTION(sectionName) __attribute__((section(sectionName)))
54 
55 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
56 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
57 
58 /*! Make given data item aligned (alignment in bytes). */
59 #define SASI_PAL_COMPILER_ALIGN(alignement) __attribute__((aligned(alignement)))
60 
61 /*! Mark function that never returns. */
62 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS __attribute__((noreturn))
63 
64 /*! Prevent function from being inlined */
65 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE __attribute__((noinline))
66 
67 /*! Given data type may cast (alias) another data type pointer. */
68 /* (this is used for "superclass" struct casting) */
69 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS __attribute__((__may_alias__))
70 
71 /*! Get sizeof for a structure type member. */
72 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
73  sizeof(((type_name *)0)->member_name)
74 
75 /*! Assertion. */
76 #define SASI_ASSERT_CONCAT_(a, b) a##b
77 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
78 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
79  enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
80 
81 #elif defined(__ARM_DSM__) || defined(__CC_ARM)
82 #define inline
83 /*! Associate a symbol with a link section. */
84 #define SASI_PAL_COMPILER_SECTION(sectionName) __attribute__((section(sectionName)))
85 
86 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
87 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
88 
89 /*! Make given data item aligned (alignment in bytes). */
90 #define SASI_PAL_COMPILER_ALIGN(alignement) __attribute__((aligned(alignement)))
91 
92 /*! Mark function that never returns. */
93 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS __attribute__((noreturn))
94 
95 /*! Prevent function from being inlined. */
96 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE __attribute__((noinline))
97 
98 /*! Given data type may cast (alias) another data type pointer. */
99 /* (this is used for "superclass" struct casting) */
100 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS __attribute__((__may_alias__))
101 
102 /*! Get sizeof for a structure type member. */
103 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
104  sizeof(((type_name *)0)->member_name)
105 
106 /*! Assertion. */
107 #define SASI_ASSERT_CONCAT_(a, b) a##b
108 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
109 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
110  enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
111 #elif defined(__ARM_DS__)
112 #define inline
113 /*! Associate a symbol with a link section. */
114 #define SASI_PAL_COMPILER_SECTION(sectionName) __attribute__((section(sectionName)))
115 
116 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
117 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
118 
119 /*! Make given data item aligned (alignment in bytes). */
120 #define SASI_PAL_COMPILER_ALIGN(alignement) __attribute__((aligned(alignement)))
121 
122 /*! Mark function that never returns. */
123 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS __attribute__((noreturn))
124 
125 /*! Prevent function from being inlined. */
126 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE __attribute__((noinline))
127 
128 /*! Given data type may cast (alias) another data type pointer. */
129 /* (this is used for "superclass" struct casting) */
130 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS
131 
132 /*! Get sizeof for a structure type member. */
133 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
134  sizeof(((type_name *)0)->member_name)
135 
136 /*! Assertion. */
137 #define SASI_ASSERT_CONCAT_(a, b) a##b
138 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
139 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
140  enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
141 #elif defined(__ICCARM__)
142 
143 /************************ Defines ******************************/
144 
145 /*! Associate a symbol with a link section. */
146 #define SASI_PAL_COMPILER_SECTION(sectionName) __attribute__((section(sectionName)))
147 
148 /*! Mark symbol as used, i.e., prevent garbage collector from dropping it. */
149 #define SASI_PAL_COMPILER_KEEP_SYMBOL __attribute__((used))
150 
151 
152 #define STRING_PRAGMA(x) _Pragma(#x)
153 /*! Make given data item aligned (alignment in bytes). Not implemented */
154 /* Used in crys_rsa_types.h. This is telling the compiler about buffer alignment. */
155 /* IAR treats alignment a bit different. Nonetheless, this is used only for RSA, which was not ported yet. */
156 #define SASI_PAL_COMPILER_ALIGN(n)
157 
158 /*! Mark function that never returns. Not implemented. */
159 /* Not used anywhere, and probably located due to legacy reasons.*/
160 #define SASI_PAL_COMPILER_FUNC_NEVER_RETURNS
161 
162 /* Prevent function from being inlined */
163 #define SASI_PAL_COMPILER_FUNC_DONT_INLINE STRING_PRAGMA(optimize = no_inline)
164 
165 /*! Given data type may cast (alias) another data type pointer. */
166 /* (this is used for "superclass" struct casting). Not implemented */
167 /* Used in crys_rsa_local.h. for some compilers it translates to __may_alias__. */
168 /* For IAR, there is probably no need for this attribute, as the typedef */
169 /* is equivalent. Nonetheless, this is RSA code, which was not yet ported to Mbed TLS.*/
170 #define SASI_PAL_COMPILER_TYPE_MAY_ALIAS
171 
172 /*! Get sizeof for a structure type member. */
173 #define SASI_PAL_COMPILER_SIZEOF_STRUCT_MEMBER(type_name, member_name) \
174  sizeof(((type_name *)0)->member_name)
175 
176 /*! Assertion. */
177 #define SASI_ASSERT_CONCAT_(a, b) a##b
178 #define SASI_ASSERT_CONCAT(a, b) SASI_ASSERT_CONCAT_(a, b)
179 
180 #define SASI_PAL_COMPILER_ASSERT(cond, message) \
181  enum { SASI_ASSERT_CONCAT(assert_line_, __LINE__) = 1/(!!(cond)) }
182 #else
183 #error Unsupported compiler.
184 #endif
185 /**
186 @}
187  */
188 #endif /*__SSI_PAL_COMPILER_H__*/
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.