4.1.15. __svc

The __svc keyword declares a SuperVisor Call (SVC) function taking up to four integer-like arguments and returning up to four results in a value_in_regs structure.

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

Syntax

__svc(int svc_num) return-type function-name([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.

Usage

This causes function invocations to be compiled inline as an AAPCS-compliant operation that behaves similarly to a normal call to a function.

The __value_in_regs qualifier can be used to specify that a small structure of up to 16 bytes is returned in registers, rather than by the usual structure-passing mechanism defined in the AAPCS.

Example

__svc(42) void terminate_1(int procnum); // terminate_1 returns no results
__svc(42) int terminate_2(int procnum);  // terminate_2 returns one result
typedef struct res_type
{
    int res_1;
    int res_2;
    int res_3;
    int res_4;
} res_type;

__svc(42) __value_in_regs res_type terminate_3(int procnum);
                                         // terminate_3 returns more than
                                         // one result

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