• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************/
18 #ifndef COMPILER_H_
19 #define COMPILER_H_
20 
21 #define _attribute_noinline_ __attribute__((noinline))
22 
23 #define _attribute_ram_code_sec_          __attribute__((section(".ram_code")))
24 #define _attribute_ram_code_sec_noinline_ __attribute__((section(".ram_code"))) __attribute__((noinline))
25 
26 #define _attribute_text_sec_ __attribute__((section(".text")))
27 
28 #define _attribute_aes_data_sec_ __attribute__((section(".aes_data")))
29 
30 #define _attribute_aligned_(s) __attribute__((aligned(s)))
31 
32 // Pack a structure field
33 #define __PACKED __attribute__((__packed__))
34 
35 /*******************************      BLE Stack Use     ******************************/
36 #include "common/config/user_config.h"
37 
38 #define _attribute_packed_      __attribute__((packed))
39 #define _attribute_session_(s)  __attribute__((section(s)))
40 #define _attribute_custom_code_ _attribute_session_(".custom") volatile
41 #define _attribute_no_inline_   __attribute__((noinline))
42 #define _inline_                inline
43 #define _attribute_data_dlm_    _attribute_session_(".dlm_data")  // dlm:Data Local Memory
44 
45 #if (BLC_PM_DEEP_RETENTION_MODE_EN)
46 #define _attribute_data_retention_sec_ __attribute__((section(".retention_data")))
47 #define _attribute_data_retention_     __attribute__((section(".retention_data")))
48 #define _attribute_ble_data_retention_ __attribute__((section(".retention_data")))
49 #else
50 #define _attribute_data_retention_sec_
51 #define _attribute_data_retention_
52 #define _attribute_ble_data_retention_
53 #endif
54 
55 #define _attribute_ram_code_ __attribute__((section(".ram_code"))) __attribute__((noinline))
56 
57 #define _attribute_text_code_ __attribute__((section(".text")))
58 
59 // define the static keyword for this compiler
60 #define __STATIC static
61 
62 // define the force inlining attribute for this compiler
63 #define __INLINE static __attribute__((__always_inline__)) inline
64 
65 // define the IRQ handler attribute for this compiler
66 #define __IRQ __attribute__((interrupt("machine"), aligned(4)))
67 
68 // define the BLE IRQ handler attribute for this compiler
69 #define __BTIRQ
70 
71 // define the BLE IRQ handler attribute for this compiler
72 #define __BLEIRQ
73 
74 // define the FIQ handler attribute for this compiler
75 #define __FIQ __attribute__((__interrupt__("FIQ")))
76 
77 // define size of an empty array (used to declare structure with an array size not defined)
78 #define __ARRAY_EMPTY
79 
80 // Function returns struct in registers (4 in rvds, var with gnuarm).
81 // With Gnuarm, feature depends on command line options and
82 // impacts ALL functions returning 2-words max structs
83 // (check -freg-struct-return and -mabi=xxx)
84 #define __VIR
85 
86 // function has no side effect and return depends only on arguments
87 #define __PURE __attribute__((const))
88 
89 // Align instantiated lvalue or struct member on 4 bytes
90 #define __ALIGN4 __attribute__((aligned(4)))
91 
92 // __MODULE__ comes from the RVDS compiler that supports it
93 #define __MODULE__ __BASE_FILE__
94 
95 // Put a variable in a memory maintained during deep sleep
96 #define __LOWPOWER_SAVED
97 
98 #define ASSERT_ERR(x)
99 
100 #endif
101