unistd.h revision 102227
11539Srgrimes/*-
21539Srgrimes * Copyright (c) 1991, 1993, 1994
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
131539Srgrimes * 3. All advertising materials mentioning features or use of this software
141539Srgrimes *    must display the following acknowledgement:
151539Srgrimes *	This product includes software developed by the University of
161539Srgrimes *	California, Berkeley and its contributors.
171539Srgrimes * 4. Neither the name of the University nor the names of its contributors
181539Srgrimes *    may be used to endorse or promote products derived from this software
191539Srgrimes *    without specific prior written permission.
201539Srgrimes *
211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311539Srgrimes * SUCH DAMAGE.
321539Srgrimes *
3323657Speter *	@(#)unistd.h	8.12 (Berkeley) 4/27/95
3455033Sbde * $FreeBSD: head/include/unistd.h 102227 2002-08-21 16:20:02Z mike $
351539Srgrimes */
361539Srgrimes
371539Srgrimes#ifndef _UNISTD_H_
381539Srgrimes#define	_UNISTD_H_
391539Srgrimes
401539Srgrimes#include <sys/cdefs.h>
4193514Smike#include <sys/types.h>			/* XXX adds too much pollution. */
421539Srgrimes#include <sys/unistd.h>
4393514Smike#include <sys/_types.h>
441539Srgrimes
45102227Smike#ifndef _GID_T_DECLARED
46102227Smiketypedef	__gid_t		gid_t;
47102227Smike#define	_GID_T_DECLARED
4893514Smike#endif
4993514Smike
50102227Smike#ifndef _SIZE_T_DECLARED
51102227Smiketypedef	__size_t	size_t;
52102227Smike#define	_SIZE_T_DECLARED
5393514Smike#endif
5493514Smike
55102227Smike#ifndef _SSIZE_T_DECLARED
56102227Smiketypedef	__ssize_t	ssize_t;
57102227Smike#define	_SSIZE_T_DECLARED
5893514Smike#endif
5993514Smike
60102227Smike#ifndef _UID_T_DECLARED
61102227Smiketypedef	__uid_t_	uid_t;
62102227Smike#define	_UID_T_DECLARED
6393514Smike#endif
6493514Smike
6593514Smike/*
6693514Smike * XXX missing type definitions for off_t, pid_t and useconds_t.
6793514Smike */
6893514Smike
691539Srgrimes#define	 STDIN_FILENO	0	/* standard input file descriptor */
701539Srgrimes#define	STDOUT_FILENO	1	/* standard output file descriptor */
711539Srgrimes#define	STDERR_FILENO	2	/* standard error file descriptor */
721539Srgrimes
731539Srgrimes#ifndef NULL
741539Srgrimes#define	NULL		0	/* null pointer constant */
751539Srgrimes#endif
761539Srgrimes
7798269Swollman#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
7837566Sbde#define	F_ULOCK		0	/* unlock locked section */
7937566Sbde#define	F_LOCK		1	/* lock a section for exclusive use */
8037566Sbde#define	F_TLOCK		2	/* test and lock a section for exclusive use */
8137566Sbde#define	F_TEST		3	/* test a section for locks by other procs */
8237509Sdt#endif
8337509Sdt
841539Srgrimes__BEGIN_DECLS
8598269Swollman/* 1003.1-1990 */
8693032Simpvoid	 _exit(int) __dead2;
8793032Simpint	 access(const char *, int);
8893032Simpunsigned int	 alarm(unsigned int);
8993032Simpint	 chdir(const char *);
9093032Simpint	 chown(const char *, uid_t, gid_t);
9193032Simpint	 close(int);
9293032Simpint	 dup(int);
9393032Simpint	 dup2(int, int);
9493032Simpint	 eaccess(const char *, int);
9593032Simpint	 execl(const char *, const char *, ...);
9693032Simpint	 execle(const char *, const char *, ...);
9793032Simpint	 execlp(const char *, const char *, ...);
9893032Simpint	 execv(const char *, char * const *);
9993032Simpint	 execve(const char *, char * const *, char * const *);
10093032Simpint	 execvp(const char *, char * const *);
10193032Simppid_t	 fork(void);
10293032Simplong	 fpathconf(int, int);
10393032Simpchar	*getcwd(char *, size_t);
10493032Simpgid_t	 getegid(void);
10593032Simpuid_t	 geteuid(void);
10693032Simpgid_t	 getgid(void);
10793032Simpint	 getgroups(int, gid_t []);
10893032Simpchar	*getlogin(void);
10993032Simppid_t	 getpgrp(void);
11093032Simppid_t	 getpid(void);
11193032Simppid_t	 getppid(void);
11293032Simpuid_t	 getuid(void);
11393032Simpint	 isatty(int);
11493032Simpint	 link(const char *, const char *);
11524896Sbde#ifndef _LSEEK_DECLARED
11624896Sbde#define	_LSEEK_DECLARED
11793032Simpoff_t	 lseek(int, off_t, int);
11824896Sbde#endif
11993032Simplong	 pathconf(const char *, int);
12093032Simpint	 pause(void);
12193032Simpint	 pipe(int *);
12293032Simpssize_t	 read(int, void *, size_t);
12393032Simpint	 rmdir(const char *);
12493032Simpint	 setgid(gid_t);
12593032Simpint	 setpgid(pid_t, pid_t);
12693032Simpvoid	 setproctitle(const char *_fmt, ...) __printf0like(1, 2);
12793032Simppid_t	 setsid(void);
12893032Simpint	 setuid(uid_t);
12993032Simpunsigned int	 sleep(unsigned int);
13093032Simplong	 sysconf(int);
13193032Simppid_t	 tcgetpgrp(int);
13293032Simpint	 tcsetpgrp(int, pid_t);
13393032Simpchar	*ttyname(int);
13493032Simpint	 unlink(const char *);
13593032Simpssize_t	 write(int, const void *, size_t);
1361539Srgrimes
137100140Swollman/* 1003.2-1992 */
138100140Swollman#if __POSIX_VISIBLE >= 199209
13998269Swollmansize_t	 confstr(int, char *, size_t);
140100145Swollmanint	 getopt(int, char * const [], const char *);
141100145Swollman
142100145Swollmanextern char *optarg;			/* getopt(3) external variables */
143100145Swollmanextern int optind, opterr, optopt;
144100147Swollman
145100147Swollman#define	_CS_PATH		1	/* default value of PATH */
14698269Swollman#endif
14798269Swollman
14898269Swollman/* ISO/IEC 9945-1: 1996 */
14998269Swollman#if __POSIX_VISIBLE >= 199506
150100140Swollmanint	 fsync(int);
151100140Swollman
15298269Swollman/*
15398269Swollman * ftruncate() was in the POSIX Realtime Extension (it's used for shared
15498269Swollman * memory), but truncate() was not.
15598269Swollman */
15698269Swollman#ifndef _FTRUNCATE_DECLARED
15798269Swollman#define	_FTRUNCATE_DECLARED
15898269Swollmanint	 ftruncate(int, off_t);
15998269Swollman#endif
16098269Swollman
16198269Swollmanint	 getlogin_r(char *, int);
16298269Swollman#endif
16398269Swollman
16498269Swollman/* 1003.1-2001 */
16598269Swollman#if __POSIX_VISIBLE >= 200112
166100140Swollmanint	 fchown(int, uid_t, gid_t);
16798269Swollmanint	 gethostname(char *, int /* socklen_t */);
16898269Swollmanint	 setegid(gid_t);
16998269Swollmanint	 seteuid(uid_t);
170100149Swollman
171100149Swollman/* X/Open mistake copied by POSIX */
172100149Swollman#define	_CS_POSIX_V6_ILP32_OFF32_CFLAGS		2
173100149Swollman#define	_CS_POSIX_V6_ILP32_OFF32_LDFLAGS	3
174100149Swollman#define	_CS_POSIX_V6_ILP32_OFF32_LIBS		4
175100149Swollman#define	_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS	5
176100149Swollman#define	_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS	6
177100149Swollman#define	_CS_POSIX_V6_ILP32_OFFBIG_LIBS		7
178100149Swollman#define	_CS_POSIX_V6_LP64_OFF64_CFLAGS		8
179100149Swollman#define	_CS_POSIX_V6_LP64_OFF64_LDFLAGS		9
180100149Swollman#define	_CS_POSIX_V6_LP64_OFF64_LIBS		10
181100149Swollman#define	_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS	11
182100149Swollman#define	_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS	12
183100149Swollman#define	_CS_POSIX_V6_LPBIG_OFFBIG_LIBS		13
184100149Swollman#define	_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS	14
18598269Swollman#endif
18698269Swollman
187100140Swollman/*
188100140Swollman * symlink() was originally in POSIX.1a, which was withdrawn after
189100140Swollman * being overtaken by events (1003.1-2001).  It was in XPG4.2, and of
190100140Swollman * course has been in BSD practically forever.
191100140Swollman */
192100140Swollman#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 402 || __BSD_VISIBLE
193100140Swollmanint	 symlink(const char *__restrict, const char *__restrict);
194100140Swollman#endif
195100140Swollman
19698269Swollman/* X/Open System Interfaces */
19798269Swollman#if __XSI_VISIBLE
19898269Swollmanchar	*crypt(const char *, const char *);
19998269Swollman/* char	*ctermid(char *); */		/* XXX ??? */
20098269Swollmanint	 encrypt(char *, int);
20198269Swollmanint	 fchdir(int);
20298269Swollmanint	 getpgid(pid_t _pid);
20398269Swollmanint	 getsid(pid_t _pid);
20498269Swollmanchar	*getwd(char *);			/* LEGACY: obsoleted by getcwd() */
20598269Swollmanint	 lchown(const char *, uid_t, gid_t);
20698269Swollmanint	 lockf(int, int, off_t);
20798269Swollmanint	 nice(int);
20898269Swollmanssize_t	 pread(int, void *, size_t, off_t);
20998269Swollmanssize_t	 pwrite(int, const void *, size_t, off_t);
21098269Swollmanint	 setpgrp(pid_t _pid, pid_t _pgrp); /* obsoleted by setpgid() */
21198269Swollmanint	 setregid(gid_t, gid_t);
21298269Swollmanint	 setreuid(uid_t, uid_t);
21398269Swollman/* void	 swab(const void *__restrict, void *__restrict, ssize_t); */
21498269Swollmanvoid	 sync(void);
21598269Swollmanunsigned int	 ualarm(unsigned int, unsigned int);
21698269Swollmanint	 usleep(unsigned int);
21798269Swollmanpid_t	 vfork(void);
21898269Swollman
21998269Swollman/* See comment at ftruncate() above. */
22098269Swollman#ifndef _TRUNCATE_DECLARED
22198269Swollman#define	_TRUNCATE_DECLARED
22298269Swollmanint	 truncate(const char *, off_t);
22398269Swollman#endif
22498269Swollman#endif /* __XSI_VISIBLE */
22598269Swollman
22698269Swollman#if __BSD_VISIBLE
2271539Srgrimesstruct timeval;				/* select(2) */
22893032Simpint	 acct(const char *);
22993032Simpint	 async_daemon(void);
23093032Simpint	 brk(const void *);
23193032Simpint	 chroot(const char *);
23298269Swollmanconst char *
23393032Simp	 crypt_get_format(void);
23493032Simpint	 crypt_set_format(const char *);
23593032Simpint	 des_cipher(const char *, char *, long, int);
23693032Simpint	 des_setkey(const char *key);
23793032Simpvoid	 endusershell(void);
23893032Simpint	 exect(const char *, char * const *, char * const *);
23993032Simpchar	*fflagstostr(u_long);
24093032Simpint	 getdomainname(char *, int);
24193032Simpint	 getdtablesize(void);
24293032Simpint	 getgrouplist(const char *, gid_t, gid_t *, int *);
24393032Simplong	 gethostid(void);
24493032Simpmode_t	 getmode(const void *, mode_t);
24593032Simpint	 getpagesize(void) __pure2;
24693032Simpchar	*getpass(const char *);
24793032Simpint	 getpeereid(int, uid_t *, gid_t *);
24893032Simpint	 getresgid(gid_t *, gid_t *, gid_t *);
24993032Simpint	 getresuid(uid_t *, uid_t *, uid_t *);
25093032Simpchar	*getusershell(void);
25193032Simpint	 initgroups(const char *, gid_t);
25293032Simpint	 iruserok(unsigned long, int, const char *, const char *);
25393032Simpint	 iruserok_sa(const void *, int, int, const char *, const char *);
25493032Simpint	 issetugid(void);
25593032Simpchar	*mkdtemp(char *);
25693032Simpint	 mknod(const char *, mode_t, dev_t);
25793032Simpint	 mkstemp(char *);
25893032Simpint	 mkstemps(char *, int);
25993032Simpchar	*mktemp(char *);
26093032Simpint	 nfsclnt(int, void *);
26193032Simpint	 nfssvc(int, void *);
26293032Simpint	 profil(char *, size_t, vm_offset_t, int);
26393032Simpint	 rcmd(char **, int, const char *, const char *, const char *, int *);
26493032Simpint	 rcmd_af(char **, int, const char *,
26593032Simp		const char *, const char *, int *, int);
26693032Simpint	 rcmdsh(char **, int, const char *,
26793032Simp		const char *, const char *, const char *);
26893032Simpchar	*re_comp(const char *);
26993032Simpint	 re_exec(const char *);
27093032Simpint	 readlink(const char *, char *, int);
27193032Simpint	 reboot(int);
27293032Simpint	 revoke(const char *);
27393032Simppid_t	 rfork(int);
27493032Simppid_t	 rfork_thread(int, void *, int (*)(void *), void *);
27593032Simpint	 rresvport(int *);
27693032Simpint	 rresvport_af(int *, int);
27793032Simpint	 ruserok(const char *, int, const char *, const char *);
27893032Simpvoid	*sbrk(intptr_t);
27993032Simpint	 select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
28093032Simpint	 setdomainname(const char *, int);
28193032Simpint	 setgroups(int, const gid_t *);
28293032Simpvoid	 sethostid(long);
28393032Simpint	 sethostname(const char *, int);
28493032Simpint	 setkey(const char *);
28593032Simpint	 setlogin(const char *);
28693032Simpvoid	*setmode(const char *);
28793032Simpint	 setresgid(gid_t, gid_t, gid_t);
28893032Simpint	 setresuid(uid_t, uid_t, uid_t);
28993032Simpint	 setrgid(gid_t);
29093032Simpint	 setruid(uid_t);
29193032Simpvoid	 setusershell(void);
29293032Simpint	 strtofflags(char **, u_long *, u_long *);
29393032Simpint	 swapon(const char *);
29493032Simpint	 syscall(int, ...);
29593032Simpoff_t	 __syscall(quad_t, ...);
29693032Simpint	 ttyslot(void);
29793032Simpint	 undelete(const char *);
29893032Simpint	 unwhiteout(const char *);
29993032Simpvoid	*valloc(size_t);			/* obsoleted by malloc() */
30023657Speter
30123657Speterextern char *suboptarg;			/* getsubopt(3) external variable */
30293032Simpint	 getsubopt(char **, char * const *, char **);
30342518Smsmithextern int optreset;			/* getopt(3) external variable */
30498269Swollman#endif /* __BSD_VISIBLE */
3051539Srgrimes__END_DECLS
3061539Srgrimes
3071539Srgrimes#endif /* !_UNISTD_H_ */
308