1 /* $NetBSD: unistd.h,v 1.125 2011/01/19 19:21:29 christos 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(__minix) && (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 *);
137 int setpgid(pid_t
, pid_t
);
138 #endif /* !__minix */
141 unsigned int sleep(unsigned int);
143 pid_t
tcgetpgrp(int);
144 int tcsetpgrp(int, pid_t
);
145 __aconst
char *ttyname(int);
146 int unlink(const char *);
147 ssize_t
write(int, const void *, size_t);
151 * IEEE Std 1003.2-92, adopted in X/Open Portability Guide Issue 4 and later
153 #if (_POSIX_C_SOURCE - 0) >= 2 || defined(_XOPEN_SOURCE) || \
154 defined(_NETBSD_SOURCE)
155 int getopt(int, char * const [], const char *);
157 extern char *optarg
; /* getopt(3) external variables */
164 * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX)
166 #if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 600 || \
167 defined(_NETBSD_SOURCE)
173 * The following three syscalls are also defined in <sys/types.h>
174 * We protect them against double declarations.
176 #ifndef __OFF_T_SYSCALLS_DECLARED
177 #define __OFF_T_SYSCALLS_DECLARED
178 off_t
lseek(int, off_t
, int);
179 int truncate(const char *, off_t
);
181 * IEEE Std 1003.1b-93,
182 * also found in X/Open Portability Guide >= Issue 4 Verion 2
184 #if (_POSIX_C_SOURCE - 0) >= 199309L || \
185 (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
186 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
187 int ftruncate(int, off_t
);
189 #endif /* __OFF_T_SYSCALLS_DECLARED */
193 * IEEE Std 1003.1b-93, adopted in X/Open CAE Specification Issue 5 Version 2
195 #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \
196 defined(_NETBSD_SOURCE)
199 #endif /* !__minix */
205 * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
207 #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
208 defined(_REENTRANT) || defined(_NETBSD_SOURCE)
209 int ttyname_r(int, char *, size_t);
210 int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
214 * X/Open Portability Guide, all issues
216 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
217 int chroot(const char *);
223 * X/Open Portability Guide >= Issue 4
225 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
226 __aconst
char *crypt(const char *, const char *);
227 int encrypt(char *, int);
228 char *getpass(const char *);
234 * X/Open Portability Guide >= Issue 4 Version 2
236 #if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
237 (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
239 typedef __intptr_t
intptr_t;
240 #define intptr_t __intptr_t
250 #if !defined(__minix) && defined(_XOPEN_SOURCE)
251 int fchown(int, uid_t
, gid_t
) __RENAME(__posix_fchown
);
253 int fchown(int, uid_t
, gid_t
);
255 int getdtablesize(void);
256 long gethostid(void);
257 int gethostname(char *, size_t);
259 getpagesize(void); /* legacy */
261 pid_t
getpgid(pid_t
);
262 #endif /* !__minix */
264 #if defined(_XOPEN_SOURCE)
265 int lchown(const char *, uid_t
, gid_t
) __RENAME(__posix_lchown
);
267 int lchown(const char *, uid_t
, gid_t
);
269 #endif /* !__minix */
270 int lockf(int, int, off_t
);
271 #if __SSP_FORTIFY_LEVEL == 0
272 ssize_t
readlink(const char * __restrict
, char * __restrict
, size_t);
274 void *sbrk(intptr_t);
276 /* XXX prototype wrong! */
277 int setpgrp(pid_t
, pid_t
); /* obsoleted by setpgid() */
278 int setregid(gid_t
, gid_t
);
279 int setreuid(uid_t
, uid_t
);
280 #endif /* !__minix */
281 void swab(const void * __restrict
, void * __restrict
, ssize_t
);
282 int symlink(const char *, const char *);
284 useconds_t
ualarm(useconds_t
, useconds_t
);
285 int usleep(useconds_t
);
286 #ifndef __LIBC12_SOURCE__
287 pid_t
vfork(void) __RENAME(__vfork14
);
291 char *getwd(char *); /* obsoleted by getcwd() */
293 #endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */
297 * X/Open CAE Specification Issue 5 Version 2
299 #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
300 ssize_t
pread(int, void *, size_t, off_t
);
301 ssize_t
pwrite(int, const void *, size_t, off_t
);
306 * Implementation-defined extensions
309 int lseek64(int fd
, u64_t _offset
, int _whence
, u64_t
*_newpos
);
311 #include <minix/type.h>
314 int getnprocnr(pid_t pid
);
315 int getpprocnr(void);
316 int _pm_findproc(char *proc_name
, int *proc_nr
);
317 int mapdriver(char *label
, int major
, int style
, int flags
);
318 pid_t
getnpid(endpoint_t proc_ep
);
319 uid_t
getnuid(endpoint_t proc_ep
);
320 gid_t
getngid(endpoint_t proc_ep
);
321 int getnucred(endpoint_t proc_ep
, struct ucred
*ucred
);
322 ssize_t
pread64(int fd
, void *buf
, size_t count
, u64_t where
);
323 ssize_t
pwrite64(int fd
, const void *buf
, size_t count
, u64_t where
);
327 #if defined(_NETBSD_SOURCE)
329 int acct(const char *);
330 #endif /* !__minix */
332 int des_cipher(const char *, char *, long, int);
333 int des_setkey(const char *);
334 void endusershell(void);
335 int exect(const char *, char * const *, char * const *);
337 int fsync_range(int, int, off_t
, off_t
);
338 int getdomainname(char *, size_t);
339 int getgrouplist(const char *, gid_t
, gid_t
*, int *);
340 int getgroupmembership(const char *, gid_t
, gid_t
*, int, int *);
341 mode_t
getmode(const void *, mode_t
);
342 int getpeereid(int, uid_t
*, gid_t
*);
343 int getsubopt(char **, char * const *, char **);
344 __aconst
char *getusershell(void);
345 int initgroups(const char *, gid_t
);
346 int iruserok(uint32_t, int, const char *, const char *);
348 int nfssvc(int, void *);
350 int profil(char *, size_t, u_long
, u_int
);
351 #endif /* !__minix */
352 #ifndef __PSIGNAL_DECLARED
353 #define __PSIGNAL_DECLARED
354 /* also in signal.h */
355 void psignal(int, const char *);
356 #endif /* __PSIGNAL_DECLARED */
357 int rcmd(char **, int, const char *, const char *, const char *, int *);
361 int reboot(int, char *);
364 int revoke(const char *);
366 int rresvport(int *);
367 int ruserok(const char *, int, const char *, const char *);
368 int setdomainname(const char *, size_t);
369 int setgroups(int, const gid_t
*);
371 int sethostname(const char *, size_t);
372 int setlogin(const char *);
373 void *setmode(const char *);
376 void setusershell(void);
377 void strmode(mode_t
, char *);
378 #ifndef __STRSIGNAL_DECLARED
379 #define __STRSIGNAL_DECLARED
380 /* backwards-compatibility; also in string.h */
381 __aconst
char *strsignal(int);
382 #endif /* __STRSIGNAL_DECLARED */
384 int swapctl(int, void *, int);
385 int swapon(const char *); /* obsoleted by swapctl() */
386 #endif /* !__minix */
387 int syscall(int, ...);
388 quad_t
__syscall(quad_t
, ...);
389 int undelete(const char *);
392 int rcmd_af(char **, int, const char *,
393 const char *, const char *, int *, int);
394 int rresvport_af(int *, int);
395 int iruserok_sa(const void *, int, int, const char *, const char *);
398 #ifndef __SYS_SIGLIST_DECLARED
399 #define __SYS_SIGLIST_DECLARED
400 /* also in signal.h */
401 extern const char *const *sys_siglist
__RENAME(__sys_siglist14
);
402 #endif /* __SYS_SIGLIST_DECLARED */
403 extern int optreset
; /* getopt(3) external variable */
404 extern char *suboptarg
; /* getsubopt(3) external variable */
410 /* Minix expects RBT_* flags to be included with <unistd.h> */
411 #include <sys/reboot.h>
414 #endif /* !_UNISTD_H_ */