Skip to content

Commit f9c5f6a

Browse files
committed
Improve Arm Compiler 6 compatibility
1 parent 6a7db34 commit f9c5f6a

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/rp2_common/hardware_sync/include/hardware/sync.h

+6
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ __force_inline static void __wfi(void) {
149149
* The DMB (data memory barrier) acts as a memory barrier, all memory accesses prior to this
150150
* instruction will be observed before any explicit access after the instruction.
151151
*/
152+
#ifndef __dmb
152153
__force_inline static void __dmb(void) {
153154
pico_default_asm_volatile("dmb" : : : "memory");
154155
}
156+
#endif
155157

156158
/*! \brief Insert a DSB instruction in to the code path.
157159
* \ingroup hardware_sync
@@ -160,9 +162,11 @@ __force_inline static void __dmb(void) {
160162
* memory barrier (DMB). The DSB operation completes when all explicit memory
161163
* accesses before this instruction complete.
162164
*/
165+
#ifndef __dsb
163166
__force_inline static void __dsb(void) {
164167
pico_default_asm_volatile("dsb" : : : "memory");
165168
}
169+
#endif
166170

167171
/*! \brief Insert a ISB instruction in to the code path.
168172
* \ingroup hardware_sync
@@ -171,9 +175,11 @@ __force_inline static void __dsb(void) {
171175
* so that all instructions following the ISB are fetched from cache or memory again, after
172176
* the ISB instruction has been completed.
173177
*/
178+
#ifndef __isb
174179
__force_inline static void __isb(void) {
175180
pico_default_asm_volatile("isb" ::: "memory");
176181
}
182+
#endif
177183

178184
/*! \brief Acquire a memory fence
179185
* \ingroup hardware_sync

src/rp2_common/pico_platform/include/pico/platform.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ extern "C" {
297297
*/
298298
#define __no_inline_not_in_flash_func(func_name) __noinline __not_in_flash_func(func_name)
299299

300+
#ifndef __packed_aligned
300301
#define __packed_aligned __packed __aligned(4)
302+
#endif
301303

302304
/*! \brief Attribute to force inlining of a function regardless of optimization level
303305
* \ingroup pico_platform
@@ -311,8 +313,10 @@ extern "C" {
311313
#if PICO_C_COMPILER_IS_GNU && (__GNUC__ <= 6 || (__GNUC__ == 7 && (__GNUC_MINOR__ < 3 || !defined(__cplusplus))))
312314
#define __force_inline inline __always_inline
313315
#else
316+
#ifndef __force_inline
314317
#define __force_inline __always_inline
315318
#endif
319+
#endif
316320

317321
/*! \brief Macro to determine the number of elements in an array
318322
* \ingroup pico_platform
@@ -484,8 +488,13 @@ static __force_inline uint __get_current_exception(void) {
484488
return exception;
485489
}
486490

487-
#define WRAPPER_FUNC(x) __wrap_ ## x
488-
#define REAL_FUNC(x) __real_ ## x
491+
#if defined(__IS_COMPILER_ARM_COMPILER_6__)
492+
#define WRAPPER_FUNC(__FUNC) $Sub$$##__FUNC
493+
#define REAL_FUNC(__FUNC) $Super$$## __FUNC
494+
#else
495+
#define WRAPPER_FUNC(x) __wrap_ ## x
496+
#define REAL_FUNC(x) __real_ ## x
497+
#endif
489498

490499
/*! \brief Helper method to busy-wait for at least the given number of cycles
491500
* \ingroup pico_platform

src/rp2_common/pico_runtime/runtime.c

+6
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void runtime_init(void) {
9090
RESETS_RESET_USBCTRL_BITS
9191
));
9292

93+
#ifdef __preinit_array_start
9394
// pre-init runs really early since we need it even for memcpy and divide!
9495
// (basically anything in aeabi that uses bootrom)
9596

@@ -104,6 +105,7 @@ void runtime_init(void) {
104105
for (void (**p)(void) = &__preinit_array_start; p < &__preinit_array_end; ++p) {
105106
(*p)();
106107
}
108+
#endif
107109

108110
// After calling preinit we have enough runtime to do the exciting maths
109111
// in clocks_init
@@ -165,6 +167,7 @@ void runtime_init(void) {
165167
irq_init_priorities();
166168
alarm_pool_init_default();
167169

170+
#ifdef __init_array_start
168171
// Start and end points of the constructor list,
169172
// defined by the linker script.
170173
extern void (*__init_array_start)(void);
@@ -176,6 +179,7 @@ void runtime_init(void) {
176179
for (void (**p)(void) = &__init_array_start; p < &__init_array_end; ++p) {
177180
(*p)();
178181
}
182+
#endif
179183

180184
}
181185

@@ -189,6 +193,7 @@ void __attribute__((noreturn)) __attribute__((weak)) _exit(__unused int status)
189193
#endif
190194
}
191195

196+
#if defined(__clock_t_defined) || defined(_CLOCK_T_DECLARED)
192197
__attribute__((weak)) void *_sbrk(int incr) {
193198
extern char end; /* Set by linker. */
194199
static char *heap_end;
@@ -259,6 +264,7 @@ __attribute((weak)) int _kill(__unused pid_t pid, __unused int sig) {
259264
void exit(int status) {
260265
_exit(status);
261266
}
267+
#endif
262268

263269
// incorrect warning from GCC 6
264270
GCC_Pragma("GCC diagnostic push")

0 commit comments

Comments
 (0)