xref: /netbsd-src/include/unistd.h (revision d710132b4b8ce7f7cccaaf660cb16aa16b4077a0)
1 /*	$NetBSD: unistd.h,v 1.92 2003/04/28 23:16:15 bjh21 Exp $	*/
2 
3 /*-
4  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Klaus Klein.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * Copyright (c) 1991, 1993, 1994
41  *	The Regents of the University of California.  All rights reserved.
42  *
43  * Redistribution and use in source and binary forms, with or without
44  * modification, are permitted provided that the following conditions
45  * are met:
46  * 1. Redistributions of source code must retain the above copyright
47  *    notice, this list of conditions and the following disclaimer.
48  * 2. Redistributions in binary form must reproduce the above copyright
49  *    notice, this list of conditions and the following disclaimer in the
50  *    documentation and/or other materials provided with the distribution.
51  * 3. All advertising materials mentioning features or use of this software
52  *    must display the following acknowledgement:
53  *	This product includes software developed by the University of
54  *	California, Berkeley and its contributors.
55  * 4. Neither the name of the University nor the names of its contributors
56  *    may be used to endorse or promote products derived from this software
57  *    without specific prior written permission.
58  *
59  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69  * SUCH DAMAGE.
70  *
71  *	@(#)unistd.h	8.12 (Berkeley) 4/27/95
72  */
73 
74 #ifndef _UNISTD_H_
75 #define	_UNISTD_H_
76 
77 #include <machine/ansi.h>
78 #include <machine/int_types.h>
79 #include <sys/cdefs.h>
80 #include <sys/featuretest.h>
81 #include <sys/types.h>
82 #include <sys/unistd.h>
83 
84 
85 /*
86  * IEEE Std 1003.1-90
87  */
88 #define	STDIN_FILENO	0	/* standard input file descriptor */
89 #define	STDOUT_FILENO	1	/* standard output file descriptor */
90 #define	STDERR_FILENO	2	/* standard error file descriptor */
91 
92 #include <sys/null.h>
93 
94 __BEGIN_DECLS
95 __dead	 void _exit __P((int)) __attribute__((__noreturn__));
96 int	 access __P((const char *, int));
97 unsigned int alarm __P((unsigned int));
98 int	 chdir __P((const char *));
99 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
100 int	chown __P((const char *, uid_t, gid_t)) __RENAME(__posix_chown);
101 #else
102 int	chown __P((const char *, uid_t, gid_t));
103 #endif /* defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */
104 int	 close __P((int));
105 size_t	 confstr __P((int, char *, size_t));
106 #ifndef __CUSERID_DECLARED
107 #define __CUSERID_DECLARED
108 /* also declared in stdio.h */
109 char	*cuserid __P((char *));	/* obsolete */
110 #endif /* __CUSERID_DECLARED */
111 int	 dup __P((int));
112 int	 dup2 __P((int, int));
113 int	 execl __P((const char *, const char *, ...));
114 int	 execle __P((const char *, const char *, ...));
115 int	 execlp __P((const char *, const char *, ...));
116 int	 execv __P((const char *, char * const *));
117 int	 execve __P((const char *, char * const *, char * const *));
118 int	 execvp __P((const char *, char * const *));
119 pid_t	 fork __P((void));
120 long	 fpathconf __P((int, int));
121 char	*getcwd __P((char *, size_t));
122 gid_t	 getegid __P((void));
123 uid_t	 geteuid __P((void));
124 gid_t	 getgid __P((void));
125 int	 getgroups __P((int, gid_t []));
126 __aconst char *getlogin __P((void));
127 pid_t	 getpgrp __P((void));
128 pid_t	 getpid __P((void));
129 pid_t	 getppid __P((void));
130 uid_t	 getuid __P((void));
131 int	 isatty __P((int));
132 int	 link __P((const char *, const char *));
133 long	 pathconf __P((const char *, int));
134 int	 pause __P((void));
135 int	 pipe __P((int *));
136 ssize_t	 read __P((int, void *, size_t));
137 int	 rmdir __P((const char *));
138 int	 setgid __P((gid_t));
139 int	 setpgid __P((pid_t, pid_t));
140 pid_t	 setsid __P((void));
141 int	 setuid __P((uid_t));
142 unsigned int	 sleep __P((unsigned int));
143 long	 sysconf __P((int));
144 pid_t	 tcgetpgrp __P((int));
145 int	 tcsetpgrp __P((int, pid_t));
146 __aconst char *ttyname __P((int));
147 int	 unlink __P((const char *));
148 ssize_t	 write __P((int, const void *, size_t));
149 
150 
151 /*
152  * IEEE Std 1003.2-92, adopted in X/Open Portability Guide Issue 4 and later
153  */
154 #if (_POSIX_C_SOURCE - 0) >= 2 || (_XOPEN_SOURCE - 0) >= 4 || \
155     defined(_NETBSD_SOURCE)
156 int	 getopt __P((int, char * const [], const char *));
157 
158 extern	 char *optarg;			/* getopt(3) external variables */
159 extern	 int opterr;
160 extern	 int optind;
161 extern	 int optopt;
162 #endif
163 
164 /*
165  * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX)
166  */
167 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \
168     defined(_NETBSD_SOURCE)
169 int	 setegid __P((gid_t));
170 int	 seteuid __P((uid_t));
171 #endif
172 
173 /*
174  * The following three syscalls are also defined in <sys/types.h>
175  * We protect them against double declarations.
176  */
177 #ifndef __OFF_T_SYSCALLS_DECLARED
178 #define __OFF_T_SYSCALLS_DECLARED
179 off_t	 lseek __P((int, off_t, int));
180 int	 truncate __P((const char *, off_t));
181 /*
182  * IEEE Std 1003.1b-93,
183  * also found in X/Open Portability Guide >= Issue 4 Verion 2
184  */
185 #if (_POSIX_C_SOURCE - 0) >= 199309L || \
186     (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
187     (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
188 int	 ftruncate __P((int, off_t));
189 #endif
190 #endif /* __OFF_T_SYSCALLS_DECLARED */
191 
192 
193 /*
194  * IEEE Std 1003.1b-93, adopted in X/Open CAE Specification Issue 5 Version 2
195  */
196 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
197     defined(_NETBSD_SOURCE)
198 int	 fdatasync __P((int));
199 int	 fsync __P((int));
200 #endif
201 
202 
203 /*
204  * X/Open Portability Guide, all issues
205  */
206 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
207 int	 chroot __P((const char *));
208 int	 nice __P((int));
209 #endif
210 
211 
212 /*
213  * X/Open Portability Guide <= Issue 3
214  */
215 #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0) <= 3
216 int	 rename __P((const char *, const char *)) __RENAME(__posix_rename);
217 #endif
218 
219 
220 /*
221  * X/Open Portability Guide >= Issue 4
222  */
223 #if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE)
224 __aconst char *crypt __P((const char *, const char *));
225 int	 encrypt __P((char *, int));
226 char	*getpass __P((const char *));
227 pid_t	 getsid __P((pid_t));
228 #endif
229 
230 
231 /*
232  * X/Open Portability Guide >= Issue 4 Version 2
233  */
234 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
235     (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
236 #ifndef	intptr_t
237 typedef	__intptr_t	intptr_t;
238 #define	intptr_t	__intptr_t
239 #endif
240 
241 #define F_ULOCK		0
242 #define F_LOCK		1
243 #define F_TLOCK		2
244 #define F_TEST		3
245 
246 int	 brk __P((void *));
247 int	 fchdir __P((int));
248 #if defined(_XOPEN_SOURCE)
249 int	 fchown __P((int, uid_t, gid_t)) __RENAME(__posix_fchown);
250 #else
251 int	 fchown __P((int, uid_t, gid_t));
252 #endif
253 int	 getdtablesize __P((void));
254 long	 gethostid __P((void));
255 int	 gethostname __P((char *, size_t));
256 __pure int
257 	 getpagesize __P((void));		/* legacy */
258 pid_t	 getpgid __P((pid_t));
259 #if defined(_XOPEN_SOURCE)
260 int	 lchown __P((const char *, uid_t, gid_t)) __RENAME(__posix_lchown);
261 #else
262 int	 lchown __P((const char *, uid_t, gid_t));
263 #endif
264 int	 lockf __P((int, int, off_t));
265 int	 readlink __P((const char *, char *, size_t));
266 void	*sbrk __P((intptr_t));
267 /* XXX prototype wrong! */
268 int	 setpgrp __P((pid_t pid, pid_t pgrp));	/* obsoleted by setpgid() */
269 int	 setregid __P((gid_t, gid_t));
270 int	 setreuid __P((uid_t, uid_t));
271 void	 swab __P((const void *, void *, size_t));
272 int	 symlink __P((const char *, const char *));
273 void	 sync __P((void));
274 useconds_t ualarm __P((useconds_t, useconds_t));
275 int	 usleep __P((useconds_t));
276 #ifdef __LIBC12_SOURCE__
277 pid_t	 vfork __P((void));
278 pid_t	 __vfork14 __P((void));
279 #else
280 pid_t	 vfork __P((void))			__RENAME(__vfork14);
281 #endif
282 
283 #ifndef __AUDIT__
284 char	*getwd __P((char *));			/* obsoleted by getcwd() */
285 #endif
286 
287 /* FIXME: this should go to <sys/time.h>! */
288 #if __STDC__
289 struct timeval;				/* select(2) XXX */
290 #endif
291 int	 select __P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
292 #endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
293 
294 
295 /*
296  * X/Open CAE Specification Issue 5 Version 2
297  */
298 #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
299 ssize_t	 pread __P((int, void *, size_t, off_t));
300 ssize_t	 pwrite __P((int, const void *, size_t, off_t));
301 #endif
302 
303 
304 /*
305  * Implementation-defined extensions
306  */
307 #if defined(_NETBSD_SOURCE)
308 int	 acct __P((const char *));
309 int	 des_cipher __P((const char *, char *, long, int));
310 int	 des_setkey __P((const char *));
311 void	 endusershell __P((void));
312 int	 exect __P((const char *, char * const *, char * const *));
313 int	 fchroot __P((int));
314 int	 getdomainname __P((char *, size_t));
315 int	 getgrouplist __P((const char *, gid_t, gid_t *, int *));
316 mode_t	 getmode __P((const void *, mode_t));
317 int	 getsubopt __P((char **, char * const *, char **));
318 __aconst char *getusershell __P((void));
319 int	 initgroups __P((const char *, gid_t));
320 int	 iruserok __P((u_int32_t, int, const char *, const char *));
321 int      issetugid __P((void));
322 int	 nfssvc __P((int, void *));
323 int	 profil __P((char *, size_t, u_long, u_int));
324 #ifndef __PSIGNAL_DECLARED
325 #define __PSIGNAL_DECLARED
326 /* also in signal.h */
327 void	psignal __P((unsigned int, const char *));
328 #endif /* __PSIGNAL_DECLARED */
329 int	 rcmd __P((char **, int, const char *,
330 	    const char *, const char *, int *));
331 int	 reboot __P((int, char *));
332 int	 revoke __P((const char *));
333 int	 rresvport __P((int *));
334 int	 ruserok __P((const char *, int, const char *, const char *));
335 int	 setdomainname __P((const char *, size_t));
336 int	 setgroups __P((int, const gid_t *));
337 int	 sethostid __P((long));
338 int	 sethostname __P((const char *, size_t));
339 int	 setlogin __P((const char *));
340 void	*setmode __P((const char *));
341 int	 setrgid __P((gid_t));
342 int	 setruid __P((uid_t));
343 void	 setusershell __P((void));
344 void	 strmode __P((mode_t, char *));
345 __aconst char *strsignal __P((int));
346 int	 swapctl __P((int, const void *, int));
347 int	 swapon __P((const char *));		/* obsoleted by swapctl() */
348 int	 syscall __P((int, ...));
349 quad_t	 __syscall __P((quad_t, ...));
350 int	 undelete __P((const char *));
351 
352 #if 1 /*INET6*/
353 int	 rcmd_af __P((char **, int, const char *,
354 	    const char *, const char *, int *, int));
355 int	 rresvport_af __P((int *, int));
356 int	 iruserok_sa __P((const void *, int, int, const char *, const char *));
357 #endif
358 
359 #ifndef __SYS_SIGLIST_DECLARED
360 #define __SYS_SIGLIST_DECLARED
361 /* also in signal.h */
362 extern __const char *__const *sys_siglist __RENAME(__sys_siglist14);
363 #endif /* __SYS_SIGLIST_DECLARED */
364 extern	 int optreset;		/* getopt(3) external variable */
365 extern	 char *suboptarg;	/* getsubopt(3) external variable */
366 #endif
367 
368 __END_DECLS
369 
370 #endif /* !_UNISTD_H_ */
371