4.1.17. __svc_indirect_r7

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

__svcindirect_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

Thumb applications on ARM Linux use __svc_indirect_r7 to make kernel syscalls.

You can also 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.

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential