9.18 __svc_indirect_r7

The __svc_indirect_r7 keyword behaves like __svc_indirect, but uses r7 instead of r12.

__svc_indirect_r7 is a function qualifier. It affects the type of a function.

Syntax

__svc_indirect_r7(int svc_num) return-type function-name(int real_num[, argument-list]);
Where:
svc_num
Is the immediate value used in the SVC instruction.
It is an expression evaluating to an integer in the range:
  • 0 to 224–1 (a 24-bit value) in an ARM instruction
    .
  • 0-255 (an 8-bit value) in a 16-bit Thumb instruction.
real_num
Is the value passed in r7 to the handler to determine the function to perform.

Usage

You can use this feature to implement indirect SVCs.

Example

long __svc_indirect_r7(0) \
        SVC_write(unsigned, int fd, const char * buf, size_t count);
#define write(fd, buf, count) SVC_write(4, (fd), (buf), (count))
Calling:
write(fd, buf, count);
compiles to SVC #0 with r0 = fd, r1 = buf, r2 = count, and r7 = 4.

Errors

When an ARM architecture variant or ARM architecture-based processor that does not support an SVC instruction is specified on the command line using the --cpu option, the compiler generates an error.
Related reference
9.16 __svc
9.17 __svc_indirect
7.29 --cpu=name compiler option
9.19 __value_in_regs
Related information
SVC
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.