Welcome to mirror list, hosted at ThFree Co, Russian Federation.

compiler.h « template « core « ble « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f01c7f32a76ce43564616bb9718fd8d823d93a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*****************************************************************************
 * @file    compiler.h
 * @author  MCD Application Team
 * @brief   This file contains the definitions which are compiler dependent.
 *****************************************************************************
 * @attention
 *
 * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * This software component is licensed by ST under Ultimate Liberty license
 * SLA0044, the "License"; You may not use this file except in compliance with
 * the License. You may obtain a copy of the License at:
 *                             www.st.com/SLA0044
 *
 ******************************************************************************
 */

#ifndef COMPILER_H__
#define COMPILER_H__


/**
  * @brief  This is the section dedicated to IAR toolchain
  */
#if defined(__ICCARM__) || defined(__IAR_SYSTEMS_ASM__)

#ifndef __WEAK
#define __WEAK __weak
#endif

#define QUOTE_(a) #a

/**
 * @brief  PACKED
 *         Use the PACKED macro for variables that needs to be packed.
 *         Usage:  PACKED(struct) myStruct_s
 *                 PACKED(union) myStruct_s
 */
#define PACKED(decl)                   __packed decl

/**
 * @brief  SECTION
 *         Use the SECTION macro to assign data or code in a specific section.
 *         Usage:  SECTION(".my_section")
 */
#define SECTION(name)                  _Pragma(QUOTE_(location=name))

/**
 * @brief  ALIGN_DEF
 *         Use the ALIGN_DEF macro to specify the alignment of a variable.
 *         Usage:  ALIGN_DEF(4)
 */
#define ALIGN_DEF(v)                   _Pragma(QUOTE_(data_alignment=v))

/**
 * @brief  NO_INIT
 *         Use the NO_INIT macro to declare a not initialized variable.
 *         Usage:  NO_INIT(int my_no_init_var)
 *         Usage:  NO_INIT(uint16_t my_no_init_array[10])
 */
#define NO_INIT(var)                   __no_init var

/**
 * @brief  This is the section dedicated to GNU toolchain
 */
#else
#ifdef __GNUC__

#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif

/**
 * @brief  PACKED
 *         Use the PACKED macro for variables that needs to be packed.
 *         Usage:  PACKED(struct) myStruct_s
 *                 PACKED(union) myStruct_s
 */
#define PACKED(decl)                    decl __attribute__((packed))

/**
 * @brief  SECTION
 *         Use the SECTION macro to assign data or code in a specific section.
 *         Usage:  SECTION(".my_section")
 */
#define SECTION(name)                   __attribute__((section(name)))

/**
 * @brief  ALIGN_DEF
 *         Use the ALIGN_DEF macro to specify the alignment of a variable.
 *         Usage:  ALIGN_DEF(4)
 */
#define ALIGN_DEF(N)                    __attribute__((aligned(N)))

/**
 * @brief  NO_INIT
 *         Use the NO_INIT macro to declare a not initialized variable.
 *         Usage:  NO_INIT(int my_no_init_var)
 *         Usage:  NO_INIT(uint16_t my_no_init_array[10])
 */
#define NO_INIT(var)                    var  __attribute__((section(".noinit")))

/**
 * @brief  This is the section dedicated to Keil toolchain
 */
#else
#ifdef __CC_ARM	

#ifndef __WEAK
#define __WEAK __weak
#endif

/**
 * @brief  PACKED
 *         Use the PACKED macro for variables that needs to be packed.
 *         Usage:  PACKED(struct) myStruct_s
 *                 PACKED(union) myStruct_s
 */
#define PACKED(decl)                        decl __attribute__((packed))

/**
 * @brief  SECTION
 *         Use the SECTION macro to assign data or code in a specific section.
 *         Usage:  SECTION(".my_section")
 */
#define SECTION(name)                       __attribute__((section(name)))

/**
 * @brief  ALIGN_DEF
 *         Use the ALIGN_DEF macro to specify the alignment of a variable.
 *         Usage:  ALIGN_DEF(4)
 */
#define ALIGN_DEF(N)                        __attribute__((aligned(N)))

/**
 * @brief  NO_INIT
 *         Use the NO_INIT macro to declare a not initialized variable.
 *         Usage:  NO_INIT(int my_no_init_var)
 *         Usage:  NO_INIT(uint16_t my_no_init_array[10])
 */
#define NO_INIT(var)                        var __attribute__((section("NoInit")))

#else

#error Neither ICCARM, CC ARM nor GNUC C detected. Define your macros.

#endif
#endif
#endif


#endif /* ! COMPILER_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE***/