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