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