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