1 /* $NetBSD: unistd.h,v 1.139 2013/10/09 09:38:21 njoly Exp $ */
4 * Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
33 * Copyright (c) 1991, 1993, 1994
34 * The Regents of the University of California. All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
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.
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
60 * @(#)unistd.h 8.12 (Berkeley) 4/27/95
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>
73 #if _FORTIFY_SOURCE > 0
74 #include <ssp/unistd.h>
80 #define STDIN_FILENO 0 /* standard input file descriptor */
81 #define STDOUT_FILENO 1 /* standard output file descriptor */
82 #define STDERR_FILENO 2 /* standard error file descriptor */
87 __dead
void _exit(int);
88 int access(const char *, int);
89 unsigned int alarm(unsigned int);
90 int chdir(const char *);
91 #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
92 int chown(const char *, uid_t
, gid_t
) __RENAME(__posix_chown
);
94 int chown(const char *, uid_t
, gid_t
);
95 #endif /* defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */
97 size_t confstr(int, char *, size_t);
98 #ifndef __CUSERID_DECLARED
99 #define __CUSERID_DECLARED
100 /* also declared in stdio.h */
101 char *cuserid(char *); /* obsolete */
102 #endif /* __CUSERID_DECLARED */
105 int execl(const char *, const char *, ...);
106 int execle(const char *, const char *, ...);
107 int execlp(const char *, const char *, ...);
108 int execv(const char *, char * const *);
109 int execve(const char *, char * const *, char * const *);
110 int execvp(const char *, char * const *);
112 long fpathconf(int, int);
113 #if __SSP_FORTIFY_LEVEL == 0
114 char *getcwd(char *, size_t);
119 int getgroups(int, gid_t
[]);
120 __aconst
char *getlogin(void);
121 int getlogin_r(char *, size_t);
127 int link(const char *, const char *);
128 long pathconf(const char *, int);
131 #if __SSP_FORTIFY_LEVEL == 0
132 ssize_t
read(int, void *, size_t);
134 int rmdir(const char *);
136 int setpgid(pid_t
, pid_t
);
139 unsigned int sleep(unsigned int);
141 pid_t
tcgetpgrp(int);
142 int tcsetpgrp(int, pid_t
);
143 __aconst
char *ttyname(int);
144 int unlink(const char *);
145 ssize_t
write(int, const void *, size_t);
149 * IEEE Std 1003.2-92, adopted in X/Open Portability Guide Issue 4 and later
151 #if (_POSIX_C_SOURCE - 0) >= 2 || defined(_XOPEN_SOURCE) || \
152 defined(_NETBSD_SOURCE)
153 int getopt(int, char * const [], const char *);
155 extern char *optarg
; /* getopt(3) external variables */
162 * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX)
164 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \
165 defined(_NETBSD_SOURCE)
171 * The following three syscalls are also defined in <sys/types.h>
172 * We protect them against double declarations.
174 #ifndef __OFF_T_SYSCALLS_DECLARED
175 #define __OFF_T_SYSCALLS_DECLARED
176 off_t
lseek(int, off_t
, int);
177 int truncate(const char *, off_t
);
179 * IEEE Std 1003.1b-93,
180 * also found in X/Open Portability Guide >= Issue 4 Verion 2
182 #if (_POSIX_C_SOURCE - 0) >= 199309L || \
183 (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
184 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
185 int ftruncate(int, off_t
);
187 #endif /* __OFF_T_SYSCALLS_DECLARED */
191 * IEEE Std 1003.1b-93, adopted in X/Open CAE Specification Issue 5 Version 2
193 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
194 defined(_NETBSD_SOURCE)
195 #if !defined(__minix)
197 #endif /* !defined(__minix) */
203 * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
205 #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
206 defined(_REENTRANT) || defined(_NETBSD_SOURCE)
207 int ttyname_r(int, char *, size_t);
208 int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
212 * X/Open Portability Guide, all issues
214 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
215 int chroot(const char *);
221 * X/Open Portability Guide >= Issue 4
223 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
224 __aconst
char *crypt(const char *, const char *);
225 int encrypt(char *, int);
226 char *getpass(const char *);
232 * X/Open Portability Guide >= Issue 4 Version 2
234 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
235 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
237 typedef __intptr_t
intptr_t;
238 #define intptr_t __intptr_t
248 #if defined(_XOPEN_SOURCE)
249 int fchown(int, uid_t
, gid_t
) __RENAME(__posix_fchown
);
251 int fchown(int, uid_t
, gid_t
);
253 int getdtablesize(void);
254 long gethostid(void);
255 int gethostname(char *, size_t);
257 getpagesize(void); /* legacy */
258 #if !defined(__minix)
259 pid_t
getpgid(pid_t
);
260 #endif /* !defined(__minix) */
261 #if defined(_XOPEN_SOURCE)
262 int lchown(const char *, uid_t
, gid_t
) __RENAME(__posix_lchown
);
264 int lchown(const char *, uid_t
, gid_t
);
266 int lockf(int, int, off_t
);
267 #if __SSP_FORTIFY_LEVEL == 0
268 ssize_t
readlink(const char * __restrict
, char * __restrict
, size_t);
270 void *sbrk(intptr_t);
271 /* XXX prototype wrong! */
272 int setpgrp(pid_t
, pid_t
); /* obsoleted by setpgid() */
273 #if !defined(__minix)
274 int setregid(gid_t
, gid_t
);
275 int setreuid(uid_t
, uid_t
);
276 #endif /* !defined(__minix) */
277 void swab(const void * __restrict
, void * __restrict
, ssize_t
);
278 int symlink(const char *, const char *);
280 useconds_t
ualarm(useconds_t
, useconds_t
);
281 int usleep(useconds_t
);
282 #ifndef __LIBC12_SOURCE__
283 pid_t
vfork(void) __RENAME(__vfork14
) __returns_twice
;
287 char *getwd(char *); /* obsoleted by getcwd() */
289 #endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
293 * X/Open CAE Specification Issue 5 Version 2
295 #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
296 ssize_t
pread(int, void *, size_t, off_t
);
297 ssize_t
pwrite(int, const void *, size_t, off_t
);
301 * X/Open Extended API set 2 (a.k.a. C063)
303 #if (_POSIX_C_SOURCE - 0) >= 200809L || (_XOPEN_SOURCE - 0 >= 700) || \
304 defined(_INCOMPLETE_XOPEN_C063) || defined(_NETBSD_SOURCE)
305 int linkat(int, const char *, int, const char *, int);
306 int renameat(int, const char *, int, const char *);
307 int faccessat(int, const char *, int, int);
308 int fchownat(int, const char *, uid_t
, gid_t
, int);
309 int readlinkat(int, const char *, char *, size_t);
310 int symlinkat(const char *, int, const char *);
311 int unlinkat(int, const char *, int);
313 #if defined(_INCOMPLETE_XOPEN_C063)
314 int fexecve(int, char * const *, char * const *);
319 * Implementation-defined extensions
321 #if defined(_NETBSD_SOURCE)
322 #if !defined(__minix)
323 int acct(const char *);
324 #endif /* !defined(__minix) */
326 int des_cipher(const char *, char *, long, int);
327 int des_setkey(const char *);
328 int dup3(int, int, int);
329 void endusershell(void);
330 int exect(const char *, char * const *, char * const *);
332 int fsync_range(int, int, off_t
, off_t
);
333 int getdomainname(char *, size_t);
334 int getgrouplist(const char *, gid_t
, gid_t
*, int *);
335 int getgroupmembership(const char *, gid_t
, gid_t
*, int, int *);
336 mode_t
getmode(const void *, mode_t
);
337 char *getpassfd(const char *, char *, size_t, int *, int, int);
338 #define GETPASS_NEED_TTY 0x001 /* Fail if we cannot set tty */
339 #define GETPASS_FAIL_EOF 0x002 /* Fail on EOF */
340 #define GETPASS_BUF_LIMIT 0x004 /* beep on buffer limit */
341 #define GETPASS_NO_SIGNAL 0x008 /* don't make ttychars send signals */
342 #define GETPASS_NO_BEEP 0x010 /* don't beep */
343 #define GETPASS_ECHO 0x020 /* echo characters as they are typed */
344 #define GETPASS_ECHO_STAR 0x040 /* echo '*' for each character */
345 #define GETPASS_7BIT 0x080 /* mask the high bit each char */
346 #define GETPASS_FORCE_LOWER 0x100 /* lowercase each char */
347 #define GETPASS_FORCE_UPPER 0x200 /* uppercase each char */
348 #define GETPASS_ECHO_NL 0x400 /* echo a newline if successful */
350 char *getpass_r(const char *, char *, size_t);
351 int getpeereid(int, uid_t
*, gid_t
*);
352 int getsubopt(char **, char * const *, char **);
353 __aconst
char *getusershell(void);
354 int initgroups(const char *, gid_t
);
355 int iruserok(uint32_t, int, const char *, const char *);
357 int nfssvc(int, void *);
358 int pipe2(int *, int);
359 #if !defined(__minix)
360 int profil(char *, size_t, u_long
, u_int
);
361 #endif /* !defined(__minix) */
362 #ifndef __PSIGNAL_DECLARED
363 #define __PSIGNAL_DECLARED
364 /* also in signal.h */
365 void psignal(int, const char *);
366 #endif /* __PSIGNAL_DECLARED */
367 int rcmd(char **, int, const char *, const char *, const char *, int *);
368 int reboot(int, char *);
369 #if !defined(__minix)
370 int revoke(const char *);
371 #endif /* !defined(__minix) */
372 int rresvport(int *);
373 int ruserok(const char *, int, const char *, const char *);
374 int setdomainname(const char *, size_t);
375 int setgroups(int, const gid_t
*);
377 int sethostname(const char *, size_t);
378 int setlogin(const char *);
379 void *setmode(const char *);
382 void setusershell(void);
383 void strmode(mode_t
, char *);
384 #ifndef __STRSIGNAL_DECLARED
385 #define __STRSIGNAL_DECLARED
386 /* backwards-compatibility; also in string.h */
387 __aconst
char *strsignal(int);
388 #endif /* __STRSIGNAL_DECLARED */
389 #if !defined(__minix)
390 int swapctl(int, void *, int);
391 int swapon(const char *); /* obsoleted by swapctl() */
392 #endif /* !defined(__minix) */
393 int syscall(int, ...);
394 quad_t
__syscall(quad_t
, ...);
395 int undelete(const char *);
398 int rcmd_af(char **, int, const char *,
399 const char *, const char *, int *, int);
400 int rresvport_af(int *, int);
401 int rresvport_af_addr(int *, int, void *);
402 int iruserok_sa(const void *, int, int, const char *, const char *);
405 #ifndef __SYS_SIGLIST_DECLARED
406 #define __SYS_SIGLIST_DECLARED
407 /* also in signal.h */
408 extern const char *const *sys_siglist
__RENAME(__sys_siglist14
);
409 #endif /* __SYS_SIGLIST_DECLARED */
410 extern int optreset
; /* getopt(3) external variable */
411 extern char *suboptarg
; /* getsubopt(3) external variable */
415 #endif /* !_UNISTD_H_ */