OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man2 / _syscall.2
1 .\"
2 .\" Copyright (c) 1993 Michael Haardt (michael@moria.de),
3 .\"   Fri Apr  2 11:32:09 MET DST 1993
4 .\"
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, write to the Free
22 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
23 .\" USA.
24 .\"
25 .\" Tue Jul  6 12:42:46 MDT 1993 <dminer@nyx.cs.du.edu>
26 .\" Added "Calling Directly" and supporting paragraphs
27 .\"
28 .\" Modified Sat Jul 24 15:19:12 1993 by Rik Faith <faith@cs.unc.edu>
29 .\"
30 .\" Modified 21 Aug 1994 by Michael Chastain <mec@shell.portal.com>:
31 .\"   Added explanation of arg stacking when 6 or more args.
32 .\"
33 .\" Modified 10 June 1995 by Andries Brouwer <aeb@cwi.nl>
34 .\"
35 .\" 2007-10-23 mtk: created as a new page, by taking the content
36 .\" specific to the _syscall() macros from intro(2).
37 .\"
38 .\" Japanese Version Copyright (c) 2008  Akihiro MOTOKI
39 .\"         all rights reserved.
40 .\" Translated 2008-02-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
41 .\" 
42 .TH _SYSCALL 2 2007-12-19 "Linux" "Linux Programmer's Manual"
43 .\"O .SH NAME
44 .SH 名前
45 .\"O _syscall \- invoking a system call without library support (OBSOLETE)
46 _syscall \- ライブラリのサポートなしでシステムコールを起動する (昔の方法)
47 .\"O .SH "SYNOPSIS"
48 .SH 書式
49 .B #include <linux/unistd.h>
50
51 A _syscall macro
52
53 desired system call
54 .\"O .SH DESCRIPTION
55 .SH 説明
56 .\"O The important thing to know about a system call is its prototype.
57 .\"O You need to know how many arguments, their types,
58 .\"O and the function return type.
59 .\"O There are seven macros that make the actual call into the system easier.
60 .\"O They have the form:
61 システムコールに関してそのプロトタイプを知ることが重要である。
62 引き数の個数、それらの型、返り値の型を知る必要がある。
63 実際の使用にあたっては、システムコールをシステムに呼び出しやすくするために、
64 7 個のマクロが用意されている。これらのマクロは以下の形である。
65 .sp
66 .RS
67 .RI _syscall X ( type , name , type1 , arg1 , type2 , arg2 ,...)
68 .RE
69 .PP
70 .\"O where
71 ここで
72 .IP
73 .\"O \fIX\fP is 0\(en6, which are the number of arguments taken by the
74 .\"O system call
75 \fIX\fP は 0〜6 で、システムコールが取る引き数の個数である。
76 .IP
77 .\"O \fItype\fP is the return type of the system call
78 \fItype\fP はシステムコールの返り値の型である。
79 .IP
80 .\"O \fIname\fP is the name of the system call
81 \fIname\fP はシステムコールの名前である。
82 .IP
83 .\"O \fItypeN\fP is the Nth argument's type
84 \fItypeN\fP は N 番目の引き数の型である。
85 .IP
86 .\"O \fIargN\fP is the name of the Nth argument
87 \fIargN\fP は N 番目の引き数の名前である。
88 .PP
89 .\"O These macros create a function called \fIname\fP with the arguments you
90 .\"O specify.
91 .\"O Once you include the _syscall() in your source file,
92 .\"O you call the system call by \fIname\fP.
93 これらのマクロは、指定した引き数を持つ \fIname\fP という名前の関数を生成する。
94 一度ソースファイルの中で _syscall() をインクルードしておくと、
95 そのシステムコールを \fIname\fP という名前で呼ぶことができる。
96 .\"O .SH FILES
97 .SH ファイル
98 .I /usr/include/linux/unistd.h
99 .\"O .SH "CONFORMING TO"
100 .SH 準拠
101 .\"O The use of these macros is Linux-specific, and deprecated.
102 これらのマクロは Linux 固有であり、その使用は非推奨である。
103 .\"O .SH NOTES
104 .SH 注意
105 .\"O Starting around kernel 2.6.18, the _syscall macros were removed
106 .\"O from header files supplied to user space.
107 .\"O Use
108 .\"O .BR syscall (2)
109 .\"O instead.
110 .\"O (Some architectures, notably ia64, never provided the _syscall macros;
111 .\"O on those architectures,
112 .\"O .BR syscall (2)
113 .\"O was always required.)
114 カーネル 2.6.18 あたりから、_syscall マクロ群はユーザ空間に対して提供される
115 ヘッダファイルから削除された。代わりに
116 .BR syscall (2)
117 を使用すること。
118 (いくつかのアーキテクチャ、特に ia64、では、これまで _syscall マクロが
119 提供されたことはない。このようなアーキテクチャでは、常に
120 .BR syscall (2)
121 が必要であった。)
122
123 .\"O The _syscall() macros \fIdo not\fP produce a prototype.
124 .\"O You may have to
125 .\"O create one, especially for C++ users.
126 _syscall() マクロはプロトタイプを「生成しない」。
127 ユーザはプロトタイプを自分で書かなければならないかもしれない。
128 とりわけ C++ ユーザの場合はそうであろう。
129
130 .\"O System calls are not required to return only positive or negative error
131 .\"O codes.
132 .\"O You need to read the source to be sure how it will return errors.
133 .\"O Usually, it is the negative of a standard error code,
134 .\"O for example, \-\fBEPERM\fP.
135 .\"O The _syscall() macros will return the result \fIr\fP of the system call
136 .\"O when \fIr\fP is nonnegative, but will return \-1 and set the variable
137 .\"O .I errno
138 .\"O to \-\fIr\fP when \fIr\fP is negative.
139 .\"O For the error codes, see
140 .\"O .BR errno (3).
141 システムコールは、正のエラーコードのみ、または負のエラーコードのみを返すように
142 定められている訳ではない。そのシステムコールがどのようなエラーコードを返すかを
143 確認するには、そのソースコードを読む必要がある。たいていの場合は、標準のエラー
144 コードを負にしたものである (例えば \-\fBEPERM\fP)。
145 _syscall() マクロは、そのシステムコールの返り値 \fIr\fP が負でない場合、その値
146 をそのまま返す。一方、\fIr\fP が負の場合には、変数
147 .I errno
148 に \-\fIr\fP を設定し、\-1 を返す。
149 エラーコードについては
150 .BR errno (3)
151 を参照。
152
153 .\"O When defining a system call, the argument types \fImust\fP be
154 .\"O passed by-value or by-pointer (for aggregates like structs).
155 システムコールを定義する際、引き数の型は値渡し (by-value) か、
156 (構造体のように集合的なデータの場合は) ポインタ渡し (by-pointer)
157 でなければならない。
158 .\" The preferred way to invoke system calls that glibc does not know
159 .\" about yet is via
160 .\" .BR syscall (2).
161 .\" However, this mechanism can only be used if using a libc
162 .\" (such as glibc) that supports
163 .\" .BR syscall (2),
164 .\" and if the
165 .\" .I <sys/syscall.h>
166 .\" header file contains the required SYS_foo definition.
167 .\" Otherwise, the use of a _syscall macro is required.
168 .\"
169 .\"O .SH EXAMPLE
170 .SH 例
171 .nf
172 #include <stdio.h>
173 #include <stdlib.h>
174 #include <errno.h>
175 #include <linux/unistd.h>       /* for _syscallX macros/related stuff */
176 #include <linux/kernel.h>       /* for struct sysinfo */
177
178 _syscall1(int, sysinfo, struct sysinfo *, info);
179
180 .\"O /* Note: if you copy directly from the nroff source, remember to
181 .\"O REMOVE the extra backslashes in the printf statement. */
182 /* Note: nroff のソースファイルから直接コピーする際には、
183 printf 文内の余分なバックスラッシュを忘れずに削除するように。 */
184
185 int
186 main(void)
187 {
188     struct sysinfo s_info;
189     int error;
190
191     error = sysinfo(&s_info);
192     printf("code error = %d\\n", error);
193     printf("Uptime = %lds\\nLoad: 1 min %lu / 5 min %lu / 15 min %lu\\n"
194            "RAM: total %lu / free %lu / shared %lu\\n"
195            "Memory in buffers = %lu\\nSwap: total %lu / free %lu\\n"
196            "Number of processes = %d\\n",
197            s_info.uptime, s_info.loads[0],
198            s_info.loads[1], s_info.loads[2],
199            s_info.totalram, s_info.freeram,
200            s_info.sharedram, s_info.bufferram,
201            s_info.totalswap, s_info.freeswap,
202            s_info.procs);
203     exit(EXIT_SUCCESS);
204 }
205 .fi
206 .SS "Sample Output"
207 .nf
208 code error = 0
209 uptime = 502034s
210 Load: 1 min 13376 / 5 min 5504 / 15 min 1152
211 RAM: total 15343616 / free 827392 / shared 8237056
212 Memory in buffers = 5066752
213 Swap: total 27881472 / free 24698880
214 Number of processes = 40
215 .fi
216 .\"O .SH "SEE ALSO"
217 .SH 関連項目
218 .BR intro (2),
219 .BR syscall (2),
220 .BR errno (3)