unistd.h revision 1.128
1/* $NetBSD: unistd.h,v 1.128 2011/11/05 09:27:06 joerg Exp $ */ 2 3/*- 4 * Copyright (c) 1998, 1999, 2008 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#if _FORTIFY_SOURCE > 0 74#include <ssp/unistd.h> 75#endif 76 77/* 78 * IEEE Std 1003.1-90 79 */ 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 */ 83 84#include <sys/null.h> 85 86__BEGIN_DECLS 87__dead void _exit(int); 88int access(const char *, int); 89unsigned int alarm(unsigned int); 90int chdir(const char *); 91#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) 92int chown(const char *, uid_t, gid_t) __RENAME(__posix_chown); 93#else 94int chown(const char *, uid_t, gid_t); 95#endif /* defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */ 96int close(int); 97size_t confstr(int, char *, size_t); 98#ifndef __CUSERID_DECLARED 99#define __CUSERID_DECLARED 100/* also declared in stdio.h */ 101char *cuserid(char *); /* obsolete */ 102#endif /* __CUSERID_DECLARED */ 103int dup(int); 104int dup2(int, int); 105int execl(const char *, const char *, ...); 106int execle(const char *, const char *, ...); 107int execlp(const char *, const char *, ...); 108int execv(const char *, char * const *); 109int execve(const char *, char * const *, char * const *); 110int execvp(const char *, char * const *); 111pid_t fork(void); 112long fpathconf(int, int); 113#if __SSP_FORTIFY_LEVEL == 0 114char *getcwd(char *, size_t); 115#endif 116gid_t getegid(void); 117uid_t geteuid(void); 118gid_t getgid(void); 119int getgroups(int, gid_t []); 120__aconst char *getlogin(void); 121int getlogin_r(char *, size_t); 122pid_t getpgrp(void); 123pid_t getpid(void); 124pid_t getppid(void); 125uid_t getuid(void); 126int isatty(int); 127int link(const char *, const char *); 128long pathconf(const char *, int); 129int pause(void); 130int pipe(int *); 131#if __SSP_FORTIFY_LEVEL == 0 132ssize_t read(int, void *, size_t); 133#endif 134int rmdir(const char *); 135int setgid(gid_t); 136int setpgid(pid_t, pid_t); 137pid_t setsid(void); 138int setuid(uid_t); 139unsigned int sleep(unsigned int); 140long sysconf(int); 141pid_t tcgetpgrp(int); 142int tcsetpgrp(int, pid_t); 143__aconst char *ttyname(int); 144int unlink(const char *); 145ssize_t write(int, const void *, size_t); 146 147 148/* 149 * IEEE Std 1003.2-92, adopted in X/Open Portability Guide Issue 4 and later 150 */ 151#if (_POSIX_C_SOURCE - 0) >= 2 || defined(_XOPEN_SOURCE) || \ 152 defined(_NETBSD_SOURCE) 153int getopt(int, char * const [], const char *); 154 155extern char *optarg; /* getopt(3) external variables */ 156extern int opterr; 157extern int optind; 158extern int optopt; 159#endif 160 161/* 162 * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX) 163 */ 164#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \ 165 defined(_NETBSD_SOURCE) 166int setegid(gid_t); 167int seteuid(uid_t); 168#endif 169 170/* 171 * The following three syscalls are also defined in <sys/types.h> 172 * We protect them against double declarations. 173 */ 174#ifndef __OFF_T_SYSCALLS_DECLARED 175#define __OFF_T_SYSCALLS_DECLARED 176off_t lseek(int, off_t, int); 177int truncate(const char *, off_t); 178/* 179 * IEEE Std 1003.1b-93, 180 * also found in X/Open Portability Guide >= Issue 4 Verion 2 181 */ 182#if (_POSIX_C_SOURCE - 0) >= 199309L || \ 183 (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ 184 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) 185int ftruncate(int, off_t); 186#endif 187#endif /* __OFF_T_SYSCALLS_DECLARED */ 188 189 190/* 191 * IEEE Std 1003.1b-93, adopted in X/Open CAE Specification Issue 5 Version 2 192 */ 193#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ 194 defined(_NETBSD_SOURCE) 195int fdatasync(int); 196int fsync(int); 197#endif 198 199 200/* 201 * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 202 */ 203#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ 204 defined(_REENTRANT) || defined(_NETBSD_SOURCE) 205int ttyname_r(int, char *, size_t); 206int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)); 207#endif 208 209/* 210 * X/Open Portability Guide, all issues 211 */ 212#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 213int chroot(const char *); 214int nice(int); 215#endif 216 217 218/* 219 * X/Open Portability Guide >= Issue 4 220 */ 221#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 222__aconst char *crypt(const char *, const char *); 223int encrypt(char *, int); 224char *getpass(const char *); 225pid_t getsid(pid_t); 226#endif 227 228 229/* 230 * X/Open Portability Guide >= Issue 4 Version 2 231 */ 232#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ 233 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) 234#ifndef intptr_t 235typedef __intptr_t intptr_t; 236#define intptr_t __intptr_t 237#endif 238 239#define F_ULOCK 0 240#define F_LOCK 1 241#define F_TLOCK 2 242#define F_TEST 3 243 244int brk(void *); 245int fchdir(int); 246#if defined(_XOPEN_SOURCE) 247int fchown(int, uid_t, gid_t) __RENAME(__posix_fchown); 248#else 249int fchown(int, uid_t, gid_t); 250#endif 251int getdtablesize(void); 252long gethostid(void); 253int gethostname(char *, size_t); 254__pure int 255 getpagesize(void); /* legacy */ 256pid_t getpgid(pid_t); 257#if defined(_XOPEN_SOURCE) 258int lchown(const char *, uid_t, gid_t) __RENAME(__posix_lchown); 259#else 260int lchown(const char *, uid_t, gid_t); 261#endif 262int lockf(int, int, off_t); 263#if __SSP_FORTIFY_LEVEL == 0 264ssize_t readlink(const char * __restrict, char * __restrict, size_t); 265#endif 266void *sbrk(intptr_t); 267/* XXX prototype wrong! */ 268int setpgrp(pid_t, pid_t); /* obsoleted by setpgid() */ 269int setregid(gid_t, gid_t); 270int setreuid(uid_t, uid_t); 271void swab(const void * __restrict, void * __restrict, ssize_t); 272int symlink(const char *, const char *); 273void sync(void); 274useconds_t ualarm(useconds_t, useconds_t); 275int usleep(useconds_t); 276#ifndef __LIBC12_SOURCE__ 277pid_t vfork(void) __RENAME(__vfork14) __returns_twice; 278#endif 279 280#ifndef __AUDIT__ 281char *getwd(char *); /* obsoleted by getcwd() */ 282#endif 283#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ 284 285 286/* 287 * X/Open CAE Specification Issue 5 Version 2 288 */ 289#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) 290ssize_t pread(int, void *, size_t, off_t); 291ssize_t pwrite(int, const void *, size_t, off_t); 292#endif 293 294/* 295 * X/Open Extended API set 2 (a.k.a. C063) 296 */ 297#if defined(_INCOMPLETE_XOPEN_C063) 298int linkat(int, const char *, int, const char *, int); 299int renameat(int, const char *, int, const char *); 300int mkfifoat(int, const char *, mode_t); 301int mknodat(int, const char *, mode_t, uint32_t); 302int mkdirat(int, const char *, mode_t); 303int faccessat(int, const char *, int, int); 304int fchmodat(int, const char *, mode_t, int); 305int fchownat(int, const char *, uid_t, gid_t, int); 306int fexecve(int, char * const *, char * const *); 307int readlinkat(int, const char *, char *, size_t); 308int symlinkat(const char *, int, const char *); 309int unlinkat(int, const char *, int); 310#endif 311 312 313/* 314 * Implementation-defined extensions 315 */ 316#if defined(_NETBSD_SOURCE) 317int acct(const char *); 318int closefrom(int); 319int des_cipher(const char *, char *, long, int); 320int des_setkey(const char *); 321int dup3(int, int, int); 322void endusershell(void); 323int exect(const char *, char * const *, char * const *); 324int fchroot(int); 325int fsync_range(int, int, off_t, off_t); 326int getdomainname(char *, size_t); 327int getgrouplist(const char *, gid_t, gid_t *, int *); 328int getgroupmembership(const char *, gid_t, gid_t *, int, int *); 329mode_t getmode(const void *, mode_t); 330int getpeereid(int, uid_t *, gid_t *); 331int getsubopt(char **, char * const *, char **); 332__aconst char *getusershell(void); 333int initgroups(const char *, gid_t); 334int iruserok(uint32_t, int, const char *, const char *); 335int issetugid(void); 336int nfssvc(int, void *); 337int pipe2(int *, int); 338int profil(char *, size_t, u_long, u_int); 339#ifndef __PSIGNAL_DECLARED 340#define __PSIGNAL_DECLARED 341/* also in signal.h */ 342void psignal(int, const char *); 343#endif /* __PSIGNAL_DECLARED */ 344int rcmd(char **, int, const char *, const char *, const char *, int *); 345int reboot(int, char *); 346int revoke(const char *); 347int rresvport(int *); 348int ruserok(const char *, int, const char *, const char *); 349int setdomainname(const char *, size_t); 350int setgroups(int, const gid_t *); 351int sethostid(long); 352int sethostname(const char *, size_t); 353int setlogin(const char *); 354void *setmode(const char *); 355int setrgid(gid_t); 356int setruid(uid_t); 357void setusershell(void); 358void strmode(mode_t, char *); 359#ifndef __STRSIGNAL_DECLARED 360#define __STRSIGNAL_DECLARED 361/* backwards-compatibility; also in string.h */ 362__aconst char *strsignal(int); 363#endif /* __STRSIGNAL_DECLARED */ 364int swapctl(int, void *, int); 365int swapon(const char *); /* obsoleted by swapctl() */ 366int syscall(int, ...); 367quad_t __syscall(quad_t, ...); 368int undelete(const char *); 369 370#if 1 /*INET6*/ 371int rcmd_af(char **, int, const char *, 372 const char *, const char *, int *, int); 373int rresvport_af(int *, int); 374int iruserok_sa(const void *, int, int, const char *, const char *); 375#endif 376 377#ifndef __SYS_SIGLIST_DECLARED 378#define __SYS_SIGLIST_DECLARED 379/* also in signal.h */ 380extern const char *const *sys_siglist __RENAME(__sys_siglist14); 381#endif /* __SYS_SIGLIST_DECLARED */ 382extern int optreset; /* getopt(3) external variable */ 383extern char *suboptarg; /* getsubopt(3) external variable */ 384#endif 385 386__END_DECLS 387#endif /* !_UNISTD_H_ */ 388