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