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