mirror of https://github.com/mkerrisk/man-pages
getgid.2, getpid.2, getuid.2, pipe.2, syscall.2: Describe 2nd return value peculiarity
Some architectures (ab)use second return value register for additional return value in some system calls. Let's describe this. Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
f3f3ab82ee
commit
70ea1968cc
|
@ -59,6 +59,25 @@ The glibc
|
||||||
and
|
and
|
||||||
.BR getegid ()
|
.BR getegid ()
|
||||||
wrapper functions transparently deal with the variations across kernel versions.
|
wrapper functions transparently deal with the variations across kernel versions.
|
||||||
|
.PP
|
||||||
|
On Alpha, instead of pair of
|
||||||
|
.BR getgid "() and " getegid ()
|
||||||
|
system calls, single
|
||||||
|
.BR getxgid ()
|
||||||
|
system call is provided, which returns a pair of real and effective GIDs.
|
||||||
|
The glibc
|
||||||
|
.BR getgid ()
|
||||||
|
and
|
||||||
|
.BR getegid ()
|
||||||
|
wrapper functions transparently deal with this.
|
||||||
|
See
|
||||||
|
.BR syscall (2)
|
||||||
|
for details regarding register mapping.
|
||||||
|
Other examples of such peculiarity are Alpha-specific
|
||||||
|
.BR getxpid "(2) and " getxuid (2),
|
||||||
|
along with
|
||||||
|
.BR pipe (2)
|
||||||
|
on several architectures.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR getresgid (2),
|
.BR getresgid (2),
|
||||||
.BR setgid (2),
|
.BR setgid (2),
|
||||||
|
|
|
@ -136,6 +136,25 @@ calls to
|
||||||
always invoke the actual system call, rather than returning a cached value.
|
always invoke the actual system call, rather than returning a cached value.
|
||||||
.\" FIXME .
|
.\" FIXME .
|
||||||
.\" Review progress of https://bugzilla.redhat.com/show_bug.cgi?id=1469757
|
.\" Review progress of https://bugzilla.redhat.com/show_bug.cgi?id=1469757
|
||||||
|
.PP
|
||||||
|
On Alpha, instead of pair of
|
||||||
|
.BR getpid "() and " getppid ()
|
||||||
|
system calls, single
|
||||||
|
.BR getxpid ()
|
||||||
|
system call is provided, which returns a pair of PID and parent PID.
|
||||||
|
The glibc
|
||||||
|
.BR getpid ()
|
||||||
|
and
|
||||||
|
.BR getppid ()
|
||||||
|
wrapper functions transparently deal with this.
|
||||||
|
See
|
||||||
|
.BR syscall (2)
|
||||||
|
for details regarding register mapping.
|
||||||
|
Other examples of such peculiarity are Alpha-specific
|
||||||
|
.BR getxuid "(2) and " getxgid (2),
|
||||||
|
along with
|
||||||
|
.BR pipe (2)
|
||||||
|
on several architectures.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR clone (2),
|
.BR clone (2),
|
||||||
.BR fork (2),
|
.BR fork (2),
|
||||||
|
|
|
@ -70,6 +70,25 @@ The glibc
|
||||||
and
|
and
|
||||||
.BR geteuid ()
|
.BR geteuid ()
|
||||||
wrapper functions transparently deal with the variations across kernel versions.
|
wrapper functions transparently deal with the variations across kernel versions.
|
||||||
|
.PP
|
||||||
|
On Alpha, instead of pair of
|
||||||
|
.BR getuid "() and " geteuid ()
|
||||||
|
system calls, single
|
||||||
|
.BR getxuid ()
|
||||||
|
system call is provided, which returns a pair of real and effective UIDs.
|
||||||
|
The glibc
|
||||||
|
.BR getuid ()
|
||||||
|
and
|
||||||
|
.BR geteuid ()
|
||||||
|
wrapper functions transparently deal with this.
|
||||||
|
See
|
||||||
|
.BR syscall (2)
|
||||||
|
for details regarding register mapping.
|
||||||
|
Other examples of such peculiarity are Alpha-specific
|
||||||
|
.BR getxpid "(2) and " getxgid (2),
|
||||||
|
along with
|
||||||
|
.BR pipe (2)
|
||||||
|
on several architectures.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR getresuid (2),
|
.BR getresuid (2),
|
||||||
.BR setreuid (2),
|
.BR setreuid (2),
|
||||||
|
|
26
man2/pipe.2
26
man2/pipe.2
|
@ -40,6 +40,13 @@ pipe, pipe2 \- create pipe
|
||||||
.nf
|
.nf
|
||||||
.B #include <unistd.h>
|
.B #include <unistd.h>
|
||||||
.PP
|
.PP
|
||||||
|
/* On Alpha, IA-64, MIPS, SuperH, and SPARC/SPARC64; see NOTES */
|
||||||
|
.B struct fd_pair {
|
||||||
|
.B " long fd[2];"
|
||||||
|
.B "};"
|
||||||
|
.B struct fd_pair pipe();
|
||||||
|
.PP
|
||||||
|
/* On all other architectures */
|
||||||
.BI "int pipe(int " pipefd "[2]);"
|
.BI "int pipe(int " pipefd "[2]);"
|
||||||
|
|
||||||
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
|
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
|
||||||
|
@ -184,6 +191,25 @@ has been reached and the caller is not privileged; see
|
||||||
was added to Linux in version 2.6.27;
|
was added to Linux in version 2.6.27;
|
||||||
glibc support is available starting with
|
glibc support is available starting with
|
||||||
version 2.9.
|
version 2.9.
|
||||||
|
.SH NOTES
|
||||||
|
.\" See http://math-atlas.sourceforge.net/devel/assembly/64.psabi.1.33.ps.Z
|
||||||
|
.\" for example, section 3.2.1 "Registers and the Stack Frame".
|
||||||
|
SystemV ABI on some architectures allows using more than one register
|
||||||
|
for returning multiple values; several architectures
|
||||||
|
(namely, Alpha, IA-64, MIPS, SuperH, and SPARC/SPARC64)
|
||||||
|
(ab)use this feature in order to implement
|
||||||
|
.BR pipe ()
|
||||||
|
system call in a functional manner: it doesn't take any arguments and returns
|
||||||
|
a pair of file descriptors as a return value on success.
|
||||||
|
The glibc
|
||||||
|
.BR pipe ()
|
||||||
|
wrapper function transparently deal with this.
|
||||||
|
See
|
||||||
|
.BR syscall (2)
|
||||||
|
for information regarding registers used for storing second file descriptor.
|
||||||
|
Other examples of such peculiarity are
|
||||||
|
.BR getxpid (2)/ getxuid (2)/ getxgid (2)
|
||||||
|
on Alpha.
|
||||||
.SH CONFORMING TO
|
.SH CONFORMING TO
|
||||||
.BR pipe ():
|
.BR pipe ():
|
||||||
POSIX.1-2001, POSIX.1-2008.
|
POSIX.1-2001, POSIX.1-2008.
|
||||||
|
|
|
@ -172,39 +172,39 @@ The first table lists the instruction used to transition to kernel mode
|
||||||
so you might have to refer to
|
so you might have to refer to
|
||||||
.BR vdso (7)),
|
.BR vdso (7)),
|
||||||
the register used to indicate the system call number,
|
the register used to indicate the system call number,
|
||||||
the register used to return the system call result,
|
the register(s) used to return the system call result,
|
||||||
and the register used to signal an error.
|
and the register used to signal an error.
|
||||||
.if t \{\
|
.if t \{\
|
||||||
.ft CW
|
.ft CW
|
||||||
\}
|
\}
|
||||||
.TS
|
.TS
|
||||||
l2 l2 l2 l2 l2 l.
|
l2 l2 l2 l2 l2 l2 l.
|
||||||
arch/ABI instruction syscall # retval error Notes
|
arch/ABI instruction syscall # retval retval2 error Notes
|
||||||
_
|
_
|
||||||
alpha callsys v0 v0 a3 [1]
|
alpha callsys v0 v0 a4 a3 [1], [6]
|
||||||
arc trap0 r8 r0 -
|
arc trap0 r8 r0 - -
|
||||||
arm/OABI swi NR - a1 - [2]
|
arm/OABI swi NR - a1 - - [2]
|
||||||
arm/EABI swi 0x0 r7 r0 -
|
arm/EABI swi 0x0 r7 r0 r1 -
|
||||||
arm64 svc #0 x8 x0 -
|
arm64 svc #0 x8 x0 x1 -
|
||||||
blackfin excpt 0x0 P0 R0 -
|
blackfin excpt 0x0 P0 R0 - -
|
||||||
i386 int $0x80 eax eax -
|
i386 int $0x80 eax eax edx -
|
||||||
ia64 break 0x100000 r15 r8 r10 [1]
|
ia64 break 0x100000 r15 r8 r9 r10 [1], [6]
|
||||||
m68k trap #0 d0 d0 -
|
m68k trap #0 d0 d0 - -
|
||||||
microblaze brki r14,8 r12 r3 -
|
microblaze brki r14,8 r12 r3 - -
|
||||||
mips syscall v0 v0 a3 [1]
|
mips syscall v0 v0 v1 a3 [1], [6]
|
||||||
nios2 trap r2 r2 r7
|
nios2 trap r2 r2 - r7
|
||||||
parisc ble 0x100(%sr2, %r0) r20 r28 -
|
parisc ble 0x100(%sr2, %r0) r20 r28 - -
|
||||||
powerpc sc r0 r3 r0 [1]
|
powerpc sc r0 r3 - r0 [1]
|
||||||
riscv scall a7 a0 -
|
riscv scall a7 a0 a1 -
|
||||||
s390 svc 0 r1 r2 - [3]
|
s390 svc 0 r1 r2 r3 - [3]
|
||||||
s390x svc 0 r1 r2 - [3]
|
s390x svc 0 r1 r2 r3 - [3]
|
||||||
superh trap #0x17 r3 r0 - [4]
|
superh trap #0x17 r3 r0 r1 - [4], [6]
|
||||||
sparc/32 t 0x10 g1 o0 psr/csr [1]
|
sparc/32 t 0x10 g1 o0 o1 psr/csr [1], [6]
|
||||||
sparc/64 t 0x6d g1 o0 psr/csr [1]
|
sparc/64 t 0x6d g1 o0 o1 psr/csr [1], [6]
|
||||||
tile swint1 R10 R00 R01 [1]
|
tile swint1 R10 R00 - R01 [1]
|
||||||
x86-64 syscall rax rax - [5]
|
x86-64 syscall rax rax rdx - [5]
|
||||||
x32 syscall rax rax - [5]
|
x32 syscall rax rax rdx - [5]
|
||||||
xtensa syscall a2 a2 -
|
xtensa syscall a2 a2 - -
|
||||||
.TE
|
.TE
|
||||||
.PP
|
.PP
|
||||||
Notes:
|
Notes:
|
||||||
|
@ -279,6 +279,17 @@ but passes an 8-byte
|
||||||
.I pos
|
.I pos
|
||||||
argument in a single register and not two, as is done in every other ABI.
|
argument in a single register and not two, as is done in every other ABI.
|
||||||
.RE
|
.RE
|
||||||
|
.IP [6]
|
||||||
|
Some architectures
|
||||||
|
(namely, Alpha, IA-64, MIPS, SuperH, and SPARC/SPARC64)
|
||||||
|
use second return value register in order to pass second return value in
|
||||||
|
.BR pipe (2)
|
||||||
|
system call;
|
||||||
|
Alpha uses it in the architecture-specific
|
||||||
|
.BR getxpid "(2), " getxuid "(2), and " getxgid (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 SystemV ABI.
|
||||||
.RE
|
.RE
|
||||||
.if t \{\
|
.if t \{\
|
||||||
.in
|
.in
|
||||||
|
|
Loading…
Reference in New Issue