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