gcc 中的 ARM ACLE 支持
我正在编写一个应用程序,我想在其中检测是否从 ISR 调用了某个函数。忽略应用程序的具体情况,它的目标是 Cortex M0。为了避免直接使用 asm
标签,我想使用 ARM ACLE 实现来使代码更容易阅读。因此,使用 __arm_rsr 函数似乎是一个合理的函数。只是为了测试我在 godbolt 只是为了测试它的基础知识,但令我惊讶的是它无法编译。根据 gcc 本身,他们支持 ARM完全的 ACLE v1.1。根据 ARM 自己定义__arm_rsr
在 ACLE v1.1 中。作为对照,我决定用 Clang 仔细检查一下,结果编译得很好。我只是错过了一些明显的东西,还是 GCC 根本不完全支持任何版本的 ARM ACLE?
测试应用:
#include <arm_acle.h>
int main() {
uint32_t tmp = __arm_rsr("IPSR");
return 0;
}
I'm writing an application where I'd like to detect whether a function is called from an ISR. Ignoring the specifics of the application it is targeting a Cortex M0. In an effort to avoid having to use asm
tags directly I wanted to use the ARM ACLE implementations to make the code a little easier to read. As such using the __arm_rsr
function seemed like a reasonable function to use. Just to test I put together a simple application in godbolt just to test the basics of it but to my surprise it fails to compile. According to gcc themselves, they support ARM ACLE v1.1 completely. According to ARM themselves __arm_rsr
is defined in ACLE v1.1. As a control I decided to just double check with Clang and that compiled just fine. Am I just missing something obvious or does GCC simply not support any version of ARM ACLE completely?
The test application:
#include <arm_acle.h>
int main() {
uint32_t tmp = __arm_rsr("IPSR");
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的 arm-none-eabi-gcc (8.3.1) 有
arm_acle.h
但没有__arm_rsr
。执行此操作的正常方法是使用
__get_IPSR()
。这是在
cmsis_gcc.h
中定义的,但不要直接包含它,因为它需要首先定义某些宏。包含适合您设备的 CMSIS 标头,例如:#include "stm32f4xx.h"
。My arm-none-eabi-gcc (8.3.1) has
arm_acle.h
but not__arm_rsr
.The normal way to do this is use
__get_IPSR()
.This is defined in
cmsis_gcc.h
, but don't include that directly because it requires certain macros to be defined first. Include the appropriate CMSIS header for your device, eg:#include "stm32f4xx.h"
.