9.16 __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.
You can use the __value_in_regs qualifier 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.

Examples

__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.
Related reference
7.27 --cpu=name compiler option
9.19 __value_in_regs
Related information
SVC
Non-ConfidentialPDF file icon PDF versionARM DUI0375E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.