man-pages/man2/syscall.2.html
2021-03-31 01:06:50 +01:00

491 lines
21 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SYSCALL</TITLE>
</HEAD><BODY>
<H1>SYSCALL</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2020-02-09<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
syscall - indirect system call
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/unistd.h">unistd.h</A>&gt;</B>
<B>#include &lt;<A HREF="file:///usr/include/sys/syscall.h">sys/syscall.h</A>&gt; </B>/* For SYS_xxx definitions */
<B>long syscall(long </B><I>number</I><B>, ...);</B>
</PRE>
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<B>syscall</B>():
<DL COMPACT><DT id="1"><DD>
<DL COMPACT>
<DT id="2">Since glibc 2.19:<DD>
_DEFAULT_SOURCE
<DT id="3">Before glibc 2.19:<DD>
_BSD_SOURCE || _SVID_SOURCE
</DL>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>syscall</B>()
is a small library function that invokes
the system call whose assembly language
interface has the specified
<I>number</I>
with the specified arguments.
Employing
<B>syscall</B>()
is useful, for example,
when invoking a system call that has no wrapper function in the C library.
<P>
<B>syscall</B>()
saves CPU registers before making the system call,
restores the registers upon return from the system call,
and stores any error code returned by the system call in
<B><A HREF="/cgi-bin/man/man2html?3+errno">errno</A></B>(3)
if an error occurs.
<P>
Symbolic constants for system call numbers can be found in the header file
<I>&lt;<A HREF="file:///usr/include/sys/syscall.h">sys/syscall.h</A>&gt;</I>.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
The return value is defined by the system call being invoked.
In general, a 0 return value indicates success.
A -1 return value indicates an error,
and an error code is stored in
<I>errno</I>.
<A NAME="lbAF">&nbsp;</A>
<H2>NOTES</H2>
<B>syscall</B>()
first appeared in
4BSD.
<A NAME="lbAG">&nbsp;</A>
<H3>Architecture-specific requirements</H3>
Each architecture ABI has its own requirements on how
system call arguments are passed to the kernel.
For system calls that have a glibc wrapper (e.g., most system calls),
glibc handles the details of copying arguments to the right registers
in a manner suitable for the architecture.
However, when using
<B>syscall</B>()
to make a system call,
the caller might need to handle architecture-dependent details;
this requirement is most commonly encountered on certain 32-bit architectures.
<P>
For example, on the ARM architecture Embedded ABI (EABI), a
64-bit value (e.g.,
<I>long long</I>)
must be aligned to an even register pair.
Thus, using
<B>syscall</B>()
instead of the wrapper provided by glibc,
the
<B>readahead</B>()
system call would be invoked as follows on the ARM architecture with the EABI
in little endian mode:
<P>
syscall(SYS_readahead, fd, 0,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(unsigned&nbsp;int)&nbsp;(offset&nbsp;&amp;&nbsp;0xFFFFFFFF),
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(unsigned&nbsp;int)&nbsp;(offset&nbsp;&gt;&gt;&nbsp;32),
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count);
<P>
Since the offset argument is 64 bits, and the first argument
(<I>fd</I>)
is passed in
<I>r0</I>,
the caller must manually split and align the 64-bit value
so that it is passed in the
<I>r2</I>/<I>r3</I>
register pair.
That means inserting a dummy value into
<I>r1</I>
(the second argument of 0).
Care also must be taken so that the split follows endian conventions
(according to the C ABI for the platform).
<P>
Similar issues can occur on MIPS with the O32 ABI,
on PowerPC and parisc with the 32-bit ABI, and on Xtensa.
<P>
Note that while the parisc C ABI also uses aligned register pairs,
it uses a shim layer to hide the issue from user space.
<P>
The affected system calls are
<B><A HREF="/cgi-bin/man/man2html?2+fadvise64_64">fadvise64_64</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+ftruncate64">ftruncate64</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+posix_fadvise">posix_fadvise</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+pread64">pread64</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+pwrite64">pwrite64</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+readahead">readahead</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+sync_file_range">sync_file_range</A></B>(2),
and
<B><A HREF="/cgi-bin/man/man2html?2+truncate64">truncate64</A></B>(2).
<P>
This does not affect syscalls that manually split and assemble 64-bit values
such as
<B><A HREF="/cgi-bin/man/man2html?2+_llseek">_llseek</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+preadv">preadv</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+preadv2">preadv2</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+pwritev">pwritev</A></B>(2),
and
<B><A HREF="/cgi-bin/man/man2html?2+pwritev2">pwritev2</A></B>(2).
Welcome to the wonderful world of historical baggage.
<A NAME="lbAH">&nbsp;</A>
<H3>Architecture calling conventions</H3>
Every architecture has its own way of invoking and passing arguments to the
kernel.
The details for various architectures are listed in the two tables below.
<P>
The first table lists the instruction used to transition to kernel mode
(which might not be the fastest or best way to transition to the kernel,
so you might have to refer to
<B><A HREF="/cgi-bin/man/man2html?7+vdso">vdso</A></B>(7)),
the register used to indicate the system call number,
the register(s) used to return the system call result,
and the register used to signal an error.
<TABLE>
<TR VALIGN=top><TD>Arch/ABI&nbsp;&nbsp;</TD><TD>Instruction&nbsp;&nbsp;</TD><TD>System&nbsp;&nbsp;</TD><TD>Ret&nbsp;&nbsp;</TD><TD>Ret&nbsp;</TD><TD>Error&nbsp;&nbsp;</TD><TD>Notes<BR></TD></TR>
<TR VALIGN=top><TD>&nbsp;&nbsp;</TD><TD>&nbsp;&nbsp;</TD><TD>call #&nbsp;&nbsp;</TD><TD>val&nbsp;&nbsp;</TD><TD>val2&nbsp;</TD><TD>&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD COLSPAN=7><HR></TD></TR>
<TR VALIGN=top><TD>alpha&nbsp;&nbsp;</TD><TD>callsys&nbsp;&nbsp;</TD><TD>v0&nbsp;&nbsp;</TD><TD>v0&nbsp;&nbsp;</TD><TD>a4&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>1, 6<BR></TD></TR>
<TR VALIGN=top><TD>arc&nbsp;&nbsp;</TD><TD>trap0&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>r0&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>arm/OABI&nbsp;&nbsp;</TD><TD>swi NR&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>a1&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>2<BR></TD></TR>
<TR VALIGN=top><TD>arm/EABI&nbsp;&nbsp;</TD><TD>swi 0x0&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>r0&nbsp;&nbsp;</TD><TD>r1&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>arm64&nbsp;&nbsp;</TD><TD>svc #0&nbsp;&nbsp;</TD><TD>x8&nbsp;&nbsp;</TD><TD>x0&nbsp;&nbsp;</TD><TD>x1&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>blackfin&nbsp;&nbsp;</TD><TD>excpt 0x0&nbsp;&nbsp;</TD><TD>P0&nbsp;&nbsp;</TD><TD>R0&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>i386&nbsp;&nbsp;</TD><TD>int $0x80&nbsp;&nbsp;</TD><TD>eax&nbsp;&nbsp;</TD><TD>eax&nbsp;&nbsp;</TD><TD>edx&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>ia64&nbsp;&nbsp;</TD><TD>break 0x100000&nbsp;&nbsp;</TD><TD>r15&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>r9&nbsp;</TD><TD>r10&nbsp;&nbsp;</TD><TD>1, 6<BR></TD></TR>
<TR VALIGN=top><TD>m68k&nbsp;&nbsp;</TD><TD>trap #0&nbsp;&nbsp;</TD><TD>d0&nbsp;&nbsp;</TD><TD>d0&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>microblaze&nbsp;&nbsp;</TD><TD>brki r14,8&nbsp;&nbsp;</TD><TD>r12&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>mips&nbsp;&nbsp;</TD><TD>syscall&nbsp;&nbsp;</TD><TD>v0&nbsp;&nbsp;</TD><TD>v0&nbsp;&nbsp;</TD><TD>v1&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>1, 6<BR></TD></TR>
<TR VALIGN=top><TD>nios2&nbsp;&nbsp;</TD><TD>trap&nbsp;&nbsp;</TD><TD>r2&nbsp;&nbsp;</TD><TD>r2&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>parisc&nbsp;&nbsp;</TD><TD>ble 0x100(%sr2, %r0)&nbsp;&nbsp;</TD><TD>r20&nbsp;&nbsp;</TD><TD>r28&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>powerpc&nbsp;&nbsp;</TD><TD>sc&nbsp;&nbsp;</TD><TD>r0&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>r0&nbsp;&nbsp;</TD><TD>1<BR></TD></TR>
<TR VALIGN=top><TD>powerpc64&nbsp;&nbsp;</TD><TD>sc&nbsp;&nbsp;</TD><TD>r0&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>cr0.SO&nbsp;&nbsp;</TD><TD>1<BR></TD></TR>
<TR VALIGN=top><TD>riscv&nbsp;&nbsp;</TD><TD>ecall&nbsp;&nbsp;</TD><TD>a7&nbsp;&nbsp;</TD><TD>a0&nbsp;&nbsp;</TD><TD>a1&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>s390&nbsp;&nbsp;</TD><TD>svc 0&nbsp;&nbsp;</TD><TD>r1&nbsp;&nbsp;</TD><TD>r2&nbsp;&nbsp;</TD><TD>r3&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>3<BR></TD></TR>
<TR VALIGN=top><TD>s390x&nbsp;&nbsp;</TD><TD>svc 0&nbsp;&nbsp;</TD><TD>r1&nbsp;&nbsp;</TD><TD>r2&nbsp;&nbsp;</TD><TD>r3&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>3<BR></TD></TR>
<TR VALIGN=top><TD>superh&nbsp;&nbsp;</TD><TD>trap #0x17&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>r0&nbsp;&nbsp;</TD><TD>r1&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>4, 6<BR></TD></TR>
<TR VALIGN=top><TD>sparc/32&nbsp;&nbsp;</TD><TD>t 0x10&nbsp;&nbsp;</TD><TD>g1&nbsp;&nbsp;</TD><TD>o0&nbsp;&nbsp;</TD><TD>o1&nbsp;</TD><TD>psr/csr&nbsp;&nbsp;</TD><TD>1, 6<BR></TD></TR>
<TR VALIGN=top><TD>sparc/64&nbsp;&nbsp;</TD><TD>t 0x6d&nbsp;&nbsp;</TD><TD>g1&nbsp;&nbsp;</TD><TD>o0&nbsp;&nbsp;</TD><TD>o1&nbsp;</TD><TD>psr/csr&nbsp;&nbsp;</TD><TD>1, 6<BR></TD></TR>
<TR VALIGN=top><TD>tile&nbsp;&nbsp;</TD><TD>swint1&nbsp;&nbsp;</TD><TD>R10&nbsp;&nbsp;</TD><TD>R00&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>R01&nbsp;&nbsp;</TD><TD>1<BR></TD></TR>
<TR VALIGN=top><TD>x86-64&nbsp;&nbsp;</TD><TD>syscall&nbsp;&nbsp;</TD><TD>rax&nbsp;&nbsp;</TD><TD>rax&nbsp;&nbsp;</TD><TD>rdx&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>5<BR></TD></TR>
<TR VALIGN=top><TD>x32&nbsp;&nbsp;</TD><TD>syscall&nbsp;&nbsp;</TD><TD>rax&nbsp;&nbsp;</TD><TD>rax&nbsp;&nbsp;</TD><TD>rdx&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>5<BR></TD></TR>
<TR VALIGN=top><TD>xtensa&nbsp;&nbsp;</TD><TD>syscall&nbsp;&nbsp;</TD><TD>a2&nbsp;&nbsp;</TD><TD>a2&nbsp;&nbsp;</TD><TD>-&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
</TABLE>
<P>
Notes:
<DL COMPACT>
<DT id="4">[1]<DD>
On a few architectures,
a register is used as a boolean
(0 indicating no error, and -1 indicating an error) to signal that the
system call failed.
The actual error value is still contained in the return register.
On sparc, the carry bit
(<I>csr</I>)
in the processor status register
(<I>psr</I>)
is used instead of a full register.
On powerpc64, the summary overflow bit
(<I>SO</I>)
in field 0 of the condition register
(<I>cr0</I>)
is used.
<DT id="5">[2]<DD>
<I>NR</I>
is the system call number.
<DT id="6">[3]<DD>
For s390 and s390x,
<I>NR</I>
(the system call number) may be passed directly with
<I>svc&nbsp;NR</I>
if it is less than 256.
<DT id="7">[4]<DD>
On SuperH, the trap number controls the maximum number of arguments passed.
A
<I>trap&nbsp;#0x10</I>
can be used with only 0-argument system calls, a
<I>trap&nbsp;#0x11</I>
can be used with 0- or 1-argument system calls,
and so on up to
<I>trap #0x17</I>
for 7-argument system calls.
<DT id="8">[5]<DD>
The x32 ABI shares syscall table with x86-64 ABI, but there are some
nuances:
<DL COMPACT><DT id="9"><DD>
<DL COMPACT>
<DT id="10">&bull;<DD>
In order to indicate that a system call is called under the x32 ABI,
an additional bit,
<B>__X32_SYSCALL_BIT</B>,
is bitwise-ORed with the system call number.
The ABI used by a process affects some process behaviors,
including signal handling or system call restarting.
<DT id="11">&bull;<DD>
Since x32 has different sizes for
<I>long</I>
and pointer types, layouts of some (but not all;
<I>struct timeval</I>
or
<I>struct rlimit</I>
are 64-bit, for example) structures are different.
In order to handle this,
additional system calls are added to the system call table,
starting from number 512
(without the
<B>__X32_SYSCALL_BIT</B>).
For example,
<B>__NR_readv</B>
is defined as 19 for the x86-64 ABI and as
<I>__X32_SYSCALL_BIT</I> | <I></I><B>515</B>
for the x32 ABI.
Most of these additional system calls are actually identical
to the system calls used for providing i386 compat.
There are some notable exceptions, however, such as
<B><A HREF="/cgi-bin/man/man2html?2+preadv2">preadv2</A></B>(2),
which uses
<I>struct iovec</I>
entities with 4-byte pointers and sizes (&quot;compat_iovec&quot; in kernel terms),
but passes an 8-byte
<I>pos</I>
argument in a single register and not two, as is done in every other ABI.
</DL>
</DL>
<DT id="12">[6]<DD>
Some architectures
(namely, Alpha, IA-64, MIPS, SuperH, sparc/32, and sparc/64)
use an additional register (&quot;Retval2&quot; in the above table)
to pass back a second return value from the
<B><A HREF="/cgi-bin/man/man2html?2+pipe">pipe</A></B>(2)
system call;
Alpha uses this technique in the architecture-specific
<B><A HREF="/cgi-bin/man/man2html?2+getxpid">getxpid</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+getxuid">getxuid</A></B>(2),
and
<B><A HREF="/cgi-bin/man/man2html?2+getxgid">getxgid</A></B>(2)
system calls as well.
Other architectures do not use the second return value register
in the system call interface, even if it is defined in the System V ABI.
</DL>
<P>
The second table shows the registers used to pass the system call arguments.
<TABLE>
<TR VALIGN=top><TD>Arch/ABI</TD><TD>arg1&nbsp;&nbsp;</TD><TD>arg2&nbsp;&nbsp;</TD><TD>arg3&nbsp;&nbsp;</TD><TD>arg4&nbsp;&nbsp;</TD><TD>arg5&nbsp;&nbsp;</TD><TD>arg6&nbsp;&nbsp;</TD><TD>arg7&nbsp;&nbsp;</TD><TD>Notes<BR></TD></TR>
<TR VALIGN=top><TD COLSPAN=9><HR></TD></TR>
<TR VALIGN=top><TD>alpha</TD><TD>a0&nbsp;&nbsp;</TD><TD>a1&nbsp;&nbsp;</TD><TD>a2&nbsp;&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>a4&nbsp;&nbsp;</TD><TD>a5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>arc</TD><TD>r0&nbsp;&nbsp;</TD><TD>r1&nbsp;&nbsp;</TD><TD>r2&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>arm/OABI</TD><TD>a1&nbsp;&nbsp;</TD><TD>a2&nbsp;&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>a4&nbsp;&nbsp;</TD><TD>v1&nbsp;&nbsp;</TD><TD>v2&nbsp;&nbsp;</TD><TD>v3&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>arm/EABI</TD><TD>r0&nbsp;&nbsp;</TD><TD>r1&nbsp;&nbsp;</TD><TD>r2&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>arm64</TD><TD>x0&nbsp;&nbsp;</TD><TD>x1&nbsp;&nbsp;</TD><TD>x2&nbsp;&nbsp;</TD><TD>x3&nbsp;&nbsp;</TD><TD>x4&nbsp;&nbsp;</TD><TD>x5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>blackfin</TD><TD>R0&nbsp;&nbsp;</TD><TD>R1&nbsp;&nbsp;</TD><TD>R2&nbsp;&nbsp;</TD><TD>R3&nbsp;&nbsp;</TD><TD>R4&nbsp;&nbsp;</TD><TD>R5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>i386</TD><TD>ebx&nbsp;&nbsp;</TD><TD>ecx&nbsp;&nbsp;</TD><TD>edx&nbsp;&nbsp;</TD><TD>esi&nbsp;&nbsp;</TD><TD>edi&nbsp;&nbsp;</TD><TD>ebp&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>ia64</TD><TD>out0&nbsp;&nbsp;</TD><TD>out1&nbsp;&nbsp;</TD><TD>out2&nbsp;&nbsp;</TD><TD>out3&nbsp;&nbsp;</TD><TD>out4&nbsp;&nbsp;</TD><TD>out5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>m68k</TD><TD>d1&nbsp;&nbsp;</TD><TD>d2&nbsp;&nbsp;</TD><TD>d3&nbsp;&nbsp;</TD><TD>d4&nbsp;&nbsp;</TD><TD>d5&nbsp;&nbsp;</TD><TD>a0&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>microblaze</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>r9&nbsp;&nbsp;</TD><TD>r10&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>mips/o32</TD><TD>a0&nbsp;&nbsp;</TD><TD>a1&nbsp;&nbsp;</TD><TD>a2&nbsp;&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD>1<BR></TD></TR>
<TR VALIGN=top><TD>mips/n32,64</TD><TD>a0&nbsp;&nbsp;</TD><TD>a1&nbsp;&nbsp;</TD><TD>a2&nbsp;&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>a4&nbsp;&nbsp;</TD><TD>a5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>nios2</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>r9&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>parisc</TD><TD>r26&nbsp;&nbsp;</TD><TD>r25&nbsp;&nbsp;</TD><TD>r24&nbsp;&nbsp;</TD><TD>r23&nbsp;&nbsp;</TD><TD>r22&nbsp;&nbsp;</TD><TD>r21&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>powerpc</TD><TD>r3&nbsp;&nbsp;</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>r9&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>powerpc64</TD><TD>r3&nbsp;&nbsp;</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>riscv</TD><TD>a0&nbsp;&nbsp;</TD><TD>a1&nbsp;&nbsp;</TD><TD>a2&nbsp;&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>a4&nbsp;&nbsp;</TD><TD>a5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>s390</TD><TD>r2&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>s390x</TD><TD>r2&nbsp;&nbsp;</TD><TD>r3&nbsp;&nbsp;</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>superh</TD><TD>r4&nbsp;&nbsp;</TD><TD>r5&nbsp;&nbsp;</TD><TD>r6&nbsp;&nbsp;</TD><TD>r7&nbsp;&nbsp;</TD><TD>r0&nbsp;&nbsp;</TD><TD>r1&nbsp;&nbsp;</TD><TD>r2&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>sparc/32</TD><TD>o0&nbsp;&nbsp;</TD><TD>o1&nbsp;&nbsp;</TD><TD>o2&nbsp;&nbsp;</TD><TD>o3&nbsp;&nbsp;</TD><TD>o4&nbsp;&nbsp;</TD><TD>o5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>sparc/64</TD><TD>o0&nbsp;&nbsp;</TD><TD>o1&nbsp;&nbsp;</TD><TD>o2&nbsp;&nbsp;</TD><TD>o3&nbsp;&nbsp;</TD><TD>o4&nbsp;&nbsp;</TD><TD>o5&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>tile</TD><TD>R00&nbsp;&nbsp;</TD><TD>R01&nbsp;&nbsp;</TD><TD>R02&nbsp;&nbsp;</TD><TD>R03&nbsp;&nbsp;</TD><TD>R04&nbsp;&nbsp;</TD><TD>R05&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>x86-64</TD><TD>rdi&nbsp;&nbsp;</TD><TD>rsi&nbsp;&nbsp;</TD><TD>rdx&nbsp;&nbsp;</TD><TD>r10&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>r9&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>x32</TD><TD>rdi&nbsp;&nbsp;</TD><TD>rsi&nbsp;&nbsp;</TD><TD>rdx&nbsp;&nbsp;</TD><TD>r10&nbsp;&nbsp;</TD><TD>r8&nbsp;&nbsp;</TD><TD>r9&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
<TR VALIGN=top><TD>xtensa</TD><TD>a6&nbsp;&nbsp;</TD><TD>a3&nbsp;&nbsp;</TD><TD>a4&nbsp;&nbsp;</TD><TD>a5&nbsp;&nbsp;</TD><TD>a8&nbsp;&nbsp;</TD><TD>a9&nbsp;&nbsp;</TD><TD>-&nbsp;&nbsp;</TD><TD><BR></TD></TR>
</TABLE>
<P>
Notes:
<DL COMPACT>
<DT id="13">[1]<DD>
The mips/o32 system call convention passes
arguments 5 through 8 on the user stack.
</DL>
<P>
Note that these tables don't cover the entire calling convention---some
architectures may indiscriminately clobber other registers not listed here.
<A NAME="lbAI">&nbsp;</A>
<H2>EXAMPLE</H2>
#define _GNU_SOURCE
#include &lt;<A HREF="file:///usr/include/unistd.h">unistd.h</A>&gt;
#include &lt;<A HREF="file:///usr/include/sys/syscall.h">sys/syscall.h</A>&gt;
#include &lt;<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>&gt;
#include &lt;<A HREF="file:///usr/include/signal.h">signal.h</A>&gt;
<P>
int
main(int argc, char *argv[])
{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;pid_t&nbsp;tid;
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;tid&nbsp;=&nbsp;syscall(SYS_gettid);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;syscall(SYS_tgkill,&nbsp;getpid(),&nbsp;tid,&nbsp;SIGHUP);
}
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+_syscall">_syscall</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+intro">intro</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+syscalls">syscalls</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?3+errno">errno</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?7+vdso">vdso</A></B>(7)
<A NAME="lbAK">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="14"><A HREF="#lbAB">NAME</A><DD>
<DT id="15"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="16"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="17"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="18"><A HREF="#lbAF">NOTES</A><DD>
<DL>
<DT id="19"><A HREF="#lbAG">Architecture-specific requirements</A><DD>
<DT id="20"><A HREF="#lbAH">Architecture calling conventions</A><DD>
</DL>
<DT id="21"><A HREF="#lbAI">EXAMPLE</A><DD>
<DT id="22"><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT id="23"><A HREF="#lbAK">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:35 GMT, March 31, 2021
</BODY>
</HTML>