xref: /minix3/lib/libc/sys/syscall.2 (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras.\"	$NetBSD: syscall.2,v 1.18 2009/08/07 19:34:46 dsl Exp $
2*2fe8fb19SBen Gras.\"
3*2fe8fb19SBen Gras.\" Copyright (c) 1980, 1991, 1993
4*2fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
5*2fe8fb19SBen Gras.\"
6*2fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
7*2fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
8*2fe8fb19SBen Gras.\" are met:
9*2fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
10*2fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
11*2fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
12*2fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
13*2fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
14*2fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
15*2fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
16*2fe8fb19SBen Gras.\"    without specific prior written permission.
17*2fe8fb19SBen Gras.\"
18*2fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19*2fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20*2fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21*2fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22*2fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23*2fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24*2fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25*2fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26*2fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27*2fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28*2fe8fb19SBen Gras.\" SUCH DAMAGE.
29*2fe8fb19SBen Gras.\"
30*2fe8fb19SBen Gras.\"     @(#)syscall.2	8.1 (Berkeley) 6/16/93
31*2fe8fb19SBen Gras.\"
32*2fe8fb19SBen Gras.Dd August 7, 2009
33*2fe8fb19SBen Gras.Dt SYSCALL 2
34*2fe8fb19SBen Gras.Os
35*2fe8fb19SBen Gras.Sh NAME
36*2fe8fb19SBen Gras.Nm syscall ,
37*2fe8fb19SBen Gras.Nm __syscall
38*2fe8fb19SBen Gras.Nd indirect system call
39*2fe8fb19SBen Gras.Sh LIBRARY
40*2fe8fb19SBen Gras.Lb libc
41*2fe8fb19SBen Gras.Sh SYNOPSIS
42*2fe8fb19SBen Gras.In sys/syscall.h
43*2fe8fb19SBen Gras.In unistd.h
44*2fe8fb19SBen Gras.Ft int
45*2fe8fb19SBen Gras.Fn syscall "int number" "..."
46*2fe8fb19SBen Gras.Ft quad_t
47*2fe8fb19SBen Gras.Fn __syscall "quad_t number" "..."
48*2fe8fb19SBen Gras.Sh DESCRIPTION
49*2fe8fb19SBen Gras.Fn syscall
50*2fe8fb19SBen Grasperforms the system call whose assembly language
51*2fe8fb19SBen Grasinterface has the specified
52*2fe8fb19SBen Gras.Fa number
53*2fe8fb19SBen Graswith the specified arguments.
54*2fe8fb19SBen GrasSymbolic constants for system calls can be found in the header file
55*2fe8fb19SBen Gras.Ao Pa sys/syscall.h Ac .
56*2fe8fb19SBen GrasThe
57*2fe8fb19SBen Gras.Nm __syscall
58*2fe8fb19SBen Grasform should be used when one or more of the parameters is a
59*2fe8fb19SBen Gras64-bit argument to ensure that argument alignment is correct.
60*2fe8fb19SBen Gras.Pp
61*2fe8fb19SBen GrasThis system call is useful for testing new system calls that
62*2fe8fb19SBen Grasdo not have entries in the C library.
63*2fe8fb19SBen GrasIt should not be used in normal applications.
64*2fe8fb19SBen Gras.Sh RETURN VALUES
65*2fe8fb19SBen GrasThe return values are defined by the system call being invoked.
66*2fe8fb19SBen GrasIn general, a 0 return value indicates success.
67*2fe8fb19SBen GrasA \-1 return value indicates an error,
68*2fe8fb19SBen Grasand an error code is stored in
69*2fe8fb19SBen Gras.Va errno .
70*2fe8fb19SBen Gras.Sh HISTORY
71*2fe8fb19SBen GrasThe
72*2fe8fb19SBen Gras.Fn syscall
73*2fe8fb19SBen Grasfunction call appeared in
74*2fe8fb19SBen Gras.Bx 4.0 .
75*2fe8fb19SBen Gras.Sh BUGS
76*2fe8fb19SBen GrasThere is no way to simulate system calls that have multiple return values
77*2fe8fb19SBen Grassuch as
78*2fe8fb19SBen Gras.Xr pipe 2 .
79*2fe8fb19SBen Gras.Pp
80*2fe8fb19SBen GrasSince architectures return 32 bit and 64 bit results in different registers,
81*2fe8fb19SBen Grasit may be impossible to portably convert the result of
82*2fe8fb19SBen Gras.Fn __syscall
83*2fe8fb19SBen Grasto a 32bit value.
84*2fe8fb19SBen GrasFor instance sparc returns 32 bit values in %o0 and 64 bit values in %o0:%o1
85*2fe8fb19SBen Gras(with %o0 containing the most significant part) so a 32 bit right shift
86*2fe8fb19SBen Grasof the result is needed to get a correct 32 bit result.
87*2fe8fb19SBen Gras.Pp
88*2fe8fb19SBen GrasMany architectures mask off the unwanted high bits of the syscall number,
89*2fe8fb19SBen Grasrather than returning an error.
90*2fe8fb19SBen Gras.Pp
91*2fe8fb19SBen GrasDue to ABI implementation differences in passing struct or union
92*2fe8fb19SBen Grastype arguments to system calls between different processors, all
93*2fe8fb19SBen Grassystem calls pass instead pointers to such structs or unions, even
94*2fe8fb19SBen Graswhen the documentation of the system call mentions otherwise.
95*2fe8fb19SBen GrasThe conversion between passing structs and unions is handled normally
96*2fe8fb19SBen Grasvia userland stubs.
97*2fe8fb19SBen GrasThe correct arguments for the kernel entry
98*2fe8fb19SBen Graspoints for each system call can be found in the header file
99*2fe8fb19SBen Gras.Ao Pa sys/syscallargs.h Ac
100