Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Arm Compiler 6 compatibility #1710

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/rp2_common/hardware_sync/include/hardware/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ typedef volatile uint32_t spin_lock_t;

* The SEV (send event) instruction sends an event to both cores.
*/
#if !__has_builtin(__sev)
#if !__has_builtin(__sev) && !defined(__sev)
__force_inline static void __sev(void) {
pico_default_asm_volatile ("sev");
}
Expand All @@ -126,7 +126,7 @@ __force_inline static void __sev(void) {
* The WFE (wait for event) instruction waits until one of a number of
* events occurs, including events signalled by the SEV instruction on either core.
*/
#if !__has_builtin(__wfe)
#if !__has_builtin(__wfe) && !defined(__wfe)
__force_inline static void __wfe(void) {
pico_default_asm_volatile ("wfe");
}
Expand All @@ -137,7 +137,7 @@ __force_inline static void __wfe(void) {
*
* The WFI (wait for interrupt) instruction waits for a interrupt to wake up the core.
*/
#if !__has_builtin(__wfi)
#if !__has_builtin(__wfi) && !defined(__wfi)
__force_inline static void __wfi(void) {
pico_default_asm_volatile("wfi");
}
Expand All @@ -149,9 +149,11 @@ __force_inline static void __wfi(void) {
* The DMB (data memory barrier) acts as a memory barrier, all memory accesses prior to this
* instruction will be observed before any explicit access after the instruction.
*/
#ifndef __dmb
__force_inline static void __dmb(void) {
pico_default_asm_volatile("dmb" : : : "memory");
}
#endif

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

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

/*! \brief Acquire a memory fence
* \ingroup hardware_sync
Expand Down
13 changes: 11 additions & 2 deletions src/rp2_common/pico_platform/include/pico/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ extern "C" {
*/
#define __no_inline_not_in_flash_func(func_name) __noinline __not_in_flash_func(func_name)

#ifndef __packed_aligned
#define __packed_aligned __packed __aligned(4)
#endif

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

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

#define WRAPPER_FUNC(x) __wrap_ ## x
#define REAL_FUNC(x) __real_ ## x
#if defined(__IS_COMPILER_ARM_COMPILER_6__)
#define WRAPPER_FUNC(__FUNC) $Sub$$##__FUNC
#define REAL_FUNC(__FUNC) $Super$$## __FUNC
#else
#define WRAPPER_FUNC(x) __wrap_ ## x
#define REAL_FUNC(x) __real_ ## x
#endif

/*! \brief Helper method to busy-wait for at least the given number of cycles
* \ingroup pico_platform
Expand Down
6 changes: 6 additions & 0 deletions src/rp2_common/pico_runtime/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void runtime_init(void) {
RESETS_RESET_USBCTRL_BITS
));

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

Expand All @@ -104,6 +105,7 @@ void runtime_init(void) {
for (void (**p)(void) = &__preinit_array_start; p < &__preinit_array_end; ++p) {
(*p)();
}
#endif

// After calling preinit we have enough runtime to do the exciting maths
// in clocks_init
Expand Down Expand Up @@ -165,6 +167,7 @@ void runtime_init(void) {
irq_init_priorities();
alarm_pool_init_default();

#ifdef __init_array_start
// Start and end points of the constructor list,
// defined by the linker script.
extern void (*__init_array_start)(void);
Expand All @@ -176,6 +179,7 @@ void runtime_init(void) {
for (void (**p)(void) = &__init_array_start; p < &__init_array_end; ++p) {
(*p)();
}
#endif

}

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

#if defined(__clock_t_defined) || defined(_CLOCK_T_DECLARED)
__attribute__((weak)) void *_sbrk(int incr) {
extern char end; /* Set by linker. */
static char *heap_end;
Expand Down Expand Up @@ -259,6 +264,7 @@ __attribute((weak)) int _kill(__unused pid_t pid, __unused int sig) {
void exit(int status) {
_exit(status);
}
#endif

// incorrect warning from GCC 6
GCC_Pragma("GCC diagnostic push")
Expand Down
Loading