문제

I'm building legacy code using the GNUARM C compiler and trying to resolve all the implicit declarations of functions.

I've come across some ARM specific functions and can't find the header file containing the declarations for these functions:

get_pc 
get_cpsr 
get_sp

I have searched the web and only came up with source code containing these functions without any non-standard include files.

I'll also settle for the function declarations.

Since I will also be porting the code to the Cygwin / Windows platform, what are the equivalent declarations for Cygwin GNU GCC?

Thanks.

도움이 되었습니까?

해결책

Are you sure those are functions? I'm not very familiar with ARM, but those sound like compiler intrinsics to me. If you're moving to GCC, you might be better off replacing those with inline assembly.

다른 팁

Just write your own if you really need those functions, asm is easier than inline asm:

.globl get_pc
get_pc:
    mov r0,pc
    bx lr

.globl get_sp
get_sp:
    mov r0,sp
    bx lr

.globl get_cpsr
get_cpsr:
    mrs r0,cpsr
    bx lr

At least for arm. if you are porting to x86 and need the equivalents, I have to wonder what the code needs with those things anyway. the cpsr in particular you would likely have to change any code that uses the result as the status registers across processor vendors/families pretty much never match. The x86 equivalents should still be about the same level of effort, takes longer to do a google search and read the results than it is to just write the code (if you know the processor).

Depending on what your application is doing it is probably better to just comment out any code that calls those functions and/or uses the return value. I can imagine a few reasons why those items would be used, but it could get into architecture specific stuff and that is more involved than just porting a few register read functions. So what user786653 asked is the key question. How are these functions used? Not where can I find them but how are they used and why do you think you need them.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top