Penguin
Annotated edit history of intro(2) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 INTRO
2 !!!INTRO
3 NAME
4 DESCRIPTION
5 EXAMPLE
6 Sample Output
7 NOTES
8 CONFORMING TO
9 FILES
10 SEE ALSO
11 ----
12 !!NAME
13
14
15 intro - Introduction to system calls
16 !!DESCRIPTION
17
18
19 This chapter describes the Linux system calls. For a list of
20 the 164 syscalls present in Linux 2.0, see
21 syscalls(2).
22
23
24 __Calling Directly__
25
26
27 In most cases, it is unnecessary to invoke a system call
28 directly, but there are times when the Standard C library
29 does not implement a nice function call for
30 you.
31
32
33 __Synopsis__
34
35
36 __#include __
37
38
39 A _syscall macro
40
41
42 desired system call
43
44
45 __Setup__
46
47
48 The important thing to know about a system call is its
49 prototype. You need to know how many arguments, their types,
50 and the function return type. There are six macros that make
51 the actual call into the system easier. They have the
52 form:
53
54
55 _syscall''X''(''type'',''name'',''type1'',''arg1'',''type2'',''arg2'',...)
56
57
58 where ''X'' is 0-5, which are the number of arguments
59 taken by the system call
60
61
62 ''type'' is the return type of the system
63 call
64
65
66 ''name'' is the name of the system call
67
68
69 ''typeN'' is the Nth argument's type
70
71
72 ''argN'' is the name of the Nth argument
73
74
75 These macros create a function called ''name'' with the
76 arguments you specify. Once you include the _syscall() in
77 your source file, you call the system call by
78 ''name''.
79 !!EXAMPLE
80
81
82 #include
83 !!Sample Output
84
85
86 code error = 0
87 uptime = 502034s
88 Load: 1 min 13376 / 5 min 5504 / 15 min 1152
89 RAM: total 15343616 / free 827392 / shared 8237056
90 Memory in buffers = 5066752
91 Swap: total 27881472 / free 24698880
92 Number of processes = 40
93 !!NOTES
94
95
96 The _syscall() macros DO NOT produce a prototype. You may
97 have to create one, especially for C++ users.
98
99
100 System calls are not required to return only positive or
101 negative error codes. You need to read the source to be sure
102 how it will return errors. Usually, it is the negative of a
103 standard error code, e.g., -__EPERM__. The _syscall()
104 macros will return the result ''r'' of the system call
105 when ''r'' is nonnegative, but will return -1 and set the
106 variable ''errno'' to -''r'' when ''r'' is
107 negative. For the error codes, see
108 errno(3).
109
110
111 Some system calls, such as __mmap__, require more than
112 five arguments. These are handled by pushing the arguments
113 on the stack and passing a pointer to the block of
114 arguments.
115
116
117 When defining a system call, the argument types MUST be
118 passed by-value or by-pointer (for aggregates like
119 structs).
120 !!CONFORMING TO
121
122
123 Certain codes are used to indicate Unix variants and
124 standards to which calls in the section conform. These
125 are:
126
127
128 SVr4
129
130
131 System V Release 4 Unix, as described in the
132
133
134 SVID
135
136
137 System V Interface Definition, as described in
138
139
140 POSIX.1
141
142
143 IEEE 1003.1-1990 part 1, aka ISO/IEC 9945-1:1990s, aka
144
145
146 POSIX.1b
147
148
149 IEEE Std 1003.1b-1993 (POSIX.1b standard) describing
150 real-time facilities for portable operating systems, aka
151 ISO/IEC 9945-1:1996, as elucidated in
152
153
154 SUS, SUSv2
155
156
157 Single Unix Specification. (Developed by X/Open and The Open
158 Group. See also http://www.UNIX-systems.org/version2/
159 .)
160
161
162 4.3BSD/4.4BSD
163
164
165 The 4.3 and 4.4 distributions of Berkeley Unix. 4.4BSD was
166 upward-compatible from 4.3.
167
168
169 V7
170
171
172 Version 7, the ancestral Unix from Bell Labs.
173 !!FILES
174
175
176 ''/usr/include/linux/unistd.h''
177 !!SEE ALSO
178
179
180 errno(3)
181 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.