xref: /dragonfly/include/unistd.h (revision 0720b42f)
1 /*-
2  * Copyright (c) 1991, 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by the University of
16  *	California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *	@(#)unistd.h	8.12 (Berkeley) 4/27/95
34  * $FreeBSD: src/include/unistd.h,v 1.93 2009/03/14 19:11:08 das Exp $
35  */
36 
37 #ifndef _UNISTD_H_
38 #define	_UNISTD_H_
39 
40 #include <sys/cdefs.h>
41 #include <sys/types.h>			/* XXX adds too much pollution. */
42 #include <sys/unistd.h>
43 #include <sys/_null.h>
44 
45 #ifndef __returns_twice			/* help with buildworld bootstrap */
46 #define __returns_twice
47 #endif
48 
49 #ifndef _GID_T_DECLARED
50 typedef	__gid_t		gid_t;
51 #define	_GID_T_DECLARED
52 #endif
53 
54 #ifndef _OFF_T_DECLARED
55 typedef	__off_t		off_t;
56 #define	_OFF_T_DECLARED
57 #endif
58 
59 #ifndef _PID_T_DECLARED
60 typedef	__pid_t		pid_t;
61 #define	_PID_T_DECLARED
62 #endif
63 
64 #ifndef _SIZE_T_DECLARED
65 typedef	__size_t	size_t;
66 #define	_SIZE_T_DECLARED
67 #endif
68 
69 #ifndef _SSIZE_T_DECLARED
70 typedef	__ssize_t	ssize_t;
71 #define	_SSIZE_T_DECLARED
72 #endif
73 
74 #ifndef _UID_T_DECLARED
75 typedef	__uid_t		uid_t;
76 #define	_UID_T_DECLARED
77 #endif
78 
79 #define	 STDIN_FILENO	0	/* standard input file descriptor */
80 #define	STDOUT_FILENO	1	/* standard output file descriptor */
81 #define	STDERR_FILENO	2	/* standard error file descriptor */
82 
83 #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
84 #define	F_ULOCK		0	/* unlock locked section */
85 #define	F_LOCK		1	/* lock a section for exclusive use */
86 #define	F_TLOCK		2	/* test and lock a section for exclusive use */
87 #define	F_TEST		3	/* test a section for locks by other procs */
88 #endif
89 
90 /*
91  * POSIX options and option groups we unconditionally do or don't
92  * implement.  This list includes those options which are exclusively
93  * implemented (or not) in user mode.  Please keep this list in
94  * alphabetical order.
95  *
96  * Anything which is defined as zero below **must** have an
97  * implementation for the corresponding sysconf() which is able to
98  * determine conclusively whether or not the feature is supported.
99  * Anything which is defined as other than -1 below **must** have
100  * complete headers, types, and function declarations as specified by
101  * the POSIX standard; however, if the relevant sysconf() function
102  * returns -1, the functions may be stubbed out.
103  */
104 #define	_POSIX_READER_WRITER_LOCKS	200112L
105 #define	_POSIX_REGEXP			1	/* mandatory */
106 #define	_POSIX_SHELL			1	/* mandatory */
107 #define	_POSIX_SPAWN			200112L
108 #define	_POSIX_THREAD_ATTR_STACKADDR	200112L
109 #define	_POSIX_THREAD_ATTR_STACKSIZE	200112L
110 #define	_POSIX_THREAD_CPUTIME		-1
111 #define	_POSIX_THREAD_PRIO_INHERIT	200112L	/* [TPI] */
112 #define	_POSIX_THREAD_PRIO_PROTECT	200112L	/* [TPP] */
113 #define	_POSIX_THREAD_PRIORITY_SCHEDULING 200112L
114 #define	_POSIX_THREAD_PROCESS_SHARED	-1
115 #define	_POSIX_THREAD_ROBUST_PRIO_INHERIT -1	/* [RPI] */
116 #define	_POSIX_THREAD_ROBUST_PRIO_PROTECT -1	/* [RPP] */
117 #define	_POSIX_THREAD_SAFE_FUNCTIONS	-1
118 #define	_POSIX_THREAD_SPORADIC_SERVER	-1
119 #define	_POSIX_THREADS			200112L
120 #define	_POSIX_TRACE			-1	/* [TRC] obsolescent */
121 #define	_POSIX_TRACE_EVENT_FILTER	-1	/* [TEF] obsolescent */
122 #define	_POSIX_TRACE_INHERIT		-1	/* [TRI] obsolescent */
123 #define	_POSIX_TRACE_LOG		-1	/* [TRL] obsolescent */
124 
125 #define	_POSIX2_C_BIND			200809L	/* mandatory */
126 #define	_POSIX2_C_DEV			200809L	/* [CD] */
127 #define	_POSIX2_CHAR_TERM		1
128 #define	_POSIX2_FORT_DEV		-1	/* [FD] need fort77 utility */
129 #define	_POSIX2_FORT_RUN		200809L	/* [FR] */
130 #define	_POSIX2_LOCALEDEF		200809L
131 #define	_POSIX2_PBS			-1	/* [BE] obsolescent */
132 #define	_POSIX2_PBS_ACCOUNTING		-1	/* [BE] obsolescent */
133 #define	_POSIX2_PBS_CHECKPOINT		-1	/* [BE] obsolescent */
134 #define	_POSIX2_PBS_LOCATE		-1	/* [BE] obsolescent */
135 #define	_POSIX2_PBS_MESSAGE		-1	/* [BE] obsolescent */
136 #define	_POSIX2_PBS_TRACK		-1	/* [BE] obsolescent */
137 #define	_POSIX2_SW_DEV			200809L	/* [SD] */
138 #define	_POSIX2_UPE			200809L	/* [UP] */
139 
140 #define	_V6_ILP32_OFF32			-1
141 #define	_V6_ILP32_OFFBIG		0
142 #define	_V6_LP64_OFF64			0
143 #define	_V6_LPBIG_OFFBIG		-1
144 
145 #define	_V7_ILP32_OFF32			-1
146 #define	_V7_ILP32_OFFBIG		0
147 #define	_V7_LP64_OFF64			0
148 #define	_V7_LPBIG_OFFBIG		-1
149 
150 #if __XSI_VISIBLE
151 #define	_XOPEN_CRYPT			-1 /* XXX ??? */
152 #define	_XOPEN_ENH_I18N			-1 /* mandatory in XSI */
153 #define	_XOPEN_LEGACY			-1
154 #define	_XOPEN_REALTIME			-1
155 #define	_XOPEN_REALTIME_THREADS		-1
156 #define	_XOPEN_UNIX			-1
157 #endif
158 
159 /* Define the POSIX.2 version we target for compliance. */
160 #define	_POSIX2_VERSION		199212L
161 
162 /*
163  * POSIX-style system configuration variable accessors (for the
164  * sysconf function).  The kernel does not directly implement the
165  * sysconf() interface; rather, a C library stub translates references
166  * to sysconf() into calls to sysctl() using a giant switch statement.
167  * Those that are marked `user' are implemented entirely in the C
168  * library and never query the kernel.  pathconf() is implemented
169  * directly by the kernel so those are not defined here.
170  */
171 #define	_SC_ARG_MAX		 1
172 #define	_SC_CHILD_MAX		 2
173 #define	_SC_CLK_TCK		 3
174 #define	_SC_NGROUPS_MAX		 4
175 #define	_SC_OPEN_MAX		 5
176 #define	_SC_JOB_CONTROL		 6
177 #define	_SC_SAVED_IDS		 7
178 #define	_SC_VERSION		 8
179 #define	_SC_BC_BASE_MAX		 9 /* user */
180 #define	_SC_BC_DIM_MAX		10 /* user */
181 #define	_SC_BC_SCALE_MAX	11 /* user */
182 #define	_SC_BC_STRING_MAX	12 /* user */
183 #define	_SC_COLL_WEIGHTS_MAX	13 /* user */
184 #define	_SC_EXPR_NEST_MAX	14 /* user */
185 #define	_SC_LINE_MAX		15 /* user */
186 #define	_SC_RE_DUP_MAX		16 /* user */
187 #define	_SC_2_VERSION		17 /* user */
188 #define	_SC_2_C_BIND		18 /* user */
189 #define	_SC_2_C_DEV		19 /* user */
190 #define	_SC_2_CHAR_TERM		20 /* user */
191 #define	_SC_2_FORT_DEV		21 /* user */
192 #define	_SC_2_FORT_RUN		22 /* user */
193 #define	_SC_2_LOCALEDEF		23 /* user */
194 #define	_SC_2_SW_DEV		24 /* user */
195 #define	_SC_2_UPE		25 /* user */
196 #define	_SC_STREAM_MAX		26 /* user */
197 #define	_SC_TZNAME_MAX		27 /* user */
198 
199 #if __POSIX_VISIBLE >= 199309
200 #define	_SC_ASYNCHRONOUS_IO	28
201 #define	_SC_MAPPED_FILES	29
202 #define	_SC_MEMLOCK		30
203 #define	_SC_MEMLOCK_RANGE	31
204 #define	_SC_MEMORY_PROTECTION	32
205 #define	_SC_MESSAGE_PASSING	33
206 #define	_SC_PRIORITIZED_IO	34
207 #define	_SC_PRIORITY_SCHEDULING	35
208 #define	_SC_REALTIME_SIGNALS	36
209 #define	_SC_SEMAPHORES		37
210 #define	_SC_FSYNC		38
211 #define	_SC_SHARED_MEMORY_OBJECTS 39
212 #define	_SC_SYNCHRONIZED_IO	40
213 #define	_SC_TIMERS		41
214 #define	_SC_AIO_LISTIO_MAX	42
215 #define	_SC_AIO_MAX		43
216 #define	_SC_AIO_PRIO_DELTA_MAX	44
217 #define	_SC_DELAYTIMER_MAX	45
218 #define	_SC_MQ_OPEN_MAX		46
219 #define	_SC_PAGESIZE		47
220 #define	_SC_RTSIG_MAX		48
221 #define	_SC_SEM_NSEMS_MAX	49
222 #define	_SC_SEM_VALUE_MAX	50
223 #define	_SC_SIGQUEUE_MAX	51
224 #define	_SC_TIMER_MAX		52
225 #endif
226 
227 #if __POSIX_VISIBLE >= 200112
228 #define	_SC_2_PBS		59 /* user */
229 #define	_SC_2_PBS_ACCOUNTING	60 /* user */
230 #define	_SC_2_PBS_CHECKPOINT	61 /* user */
231 #define	_SC_2_PBS_LOCATE	62 /* user */
232 #define	_SC_2_PBS_MESSAGE	63 /* user */
233 #define	_SC_2_PBS_TRACK		64 /* user */
234 #define	_SC_ADVISORY_INFO	65
235 #define	_SC_BARRIERS		66 /* user */
236 #define	_SC_CLOCK_SELECTION	67
237 #define	_SC_CPUTIME		68
238 #define	_SC_FILE_LOCKING	69
239 #define	_SC_GETGR_R_SIZE_MAX	70 /* user */
240 #define	_SC_GETPW_R_SIZE_MAX	71 /* user */
241 #define	_SC_HOST_NAME_MAX	72
242 #define	_SC_LOGIN_NAME_MAX	73
243 #define	_SC_MONOTONIC_CLOCK	74
244 #define	_SC_MQ_PRIO_MAX		75
245 #define	_SC_READER_WRITER_LOCKS	76 /* user */
246 #define	_SC_REGEXP		77 /* user */
247 #define	_SC_SHELL		78 /* user */
248 #define	_SC_SPAWN		79 /* user */
249 #define	_SC_SPIN_LOCKS		80 /* user */
250 #define	_SC_SPORADIC_SERVER	81
251 #define	_SC_THREAD_ATTR_STACKADDR 82 /* user */
252 #define	_SC_THREAD_ATTR_STACKSIZE 83 /* user */
253 #define	_SC_THREAD_CPUTIME	84 /* user */
254 #define	_SC_THREAD_DESTRUCTOR_ITERATIONS 85 /* user */
255 #define	_SC_THREAD_KEYS_MAX	86 /* user */
256 #define	_SC_THREAD_PRIO_INHERIT	87 /* user */
257 #define	_SC_THREAD_PRIO_PROTECT	88 /* user */
258 #define	_SC_THREAD_PRIORITY_SCHEDULING 89 /* user */
259 #define	_SC_THREAD_PROCESS_SHARED 90 /* user */
260 #define	_SC_THREAD_SAFE_FUNCTIONS 91 /* user */
261 #define	_SC_THREAD_SPORADIC_SERVER 92 /* user */
262 #define	_SC_THREAD_STACK_MIN	93 /* user */
263 #define	_SC_THREAD_THREADS_MAX	94 /* user */
264 #define	_SC_TIMEOUTS		95 /* user */
265 #define	_SC_THREADS		96 /* user */
266 #define	_SC_TRACE		97 /* user */
267 #define	_SC_TRACE_EVENT_FILTER	98 /* user */
268 #define	_SC_TRACE_INHERIT	99 /* user */
269 #define	_SC_TRACE_LOG		100 /* user */
270 #define	_SC_TTY_NAME_MAX	101 /* user */
271 #define	_SC_TYPED_MEMORY_OBJECTS 102
272 #define	_SC_V6_ILP32_OFF32	103 /* user */
273 #define	_SC_V6_ILP32_OFFBIG	104 /* user */
274 #define	_SC_V6_LP64_OFF64	105 /* user */
275 #define	_SC_V6_LPBIG_OFFBIG	106 /* user */
276 #define	_SC_IPV6		118
277 #define	_SC_RAW_SOCKETS		119
278 #define	_SC_SYMLOOP_MAX		120
279 #endif
280 
281 #if __XSI_VISIBLE
282 #define	_SC_ATEXIT_MAX		107 /* user */
283 #define	_SC_IOV_MAX		56
284 #define	_SC_PAGE_SIZE		_SC_PAGESIZE
285 #define	_SC_XOPEN_CRYPT		108 /* user */
286 #define	_SC_XOPEN_ENH_I18N	109 /* user */
287 #define	_SC_XOPEN_LEGACY	110 /* user */
288 #define	_SC_XOPEN_REALTIME	111
289 #define	_SC_XOPEN_REALTIME_THREADS 112
290 #define	_SC_XOPEN_SHM		113
291 #define	_SC_XOPEN_STREAMS	114
292 #define	_SC_XOPEN_UNIX		115
293 #define	_SC_XOPEN_VERSION	116
294 #define	_SC_XOPEN_XCU_VERSION	117 /* user */
295 #endif
296 
297 #if __BSD_VISIBLE
298 #define	_SC_NPROCESSORS_CONF	57
299 #define	_SC_NPROCESSORS_ONLN	58
300 #endif
301 
302 /* Extensions found in Solaris and Linux. */
303 #define	_SC_PHYS_PAGES		121
304 
305 #if __POSIX_VISIBLE >= 200809
306 #define	_SC_V7_ILP32_OFF32	122 /* user */
307 #define	_SC_V7_ILP32_OFFBIG	123 /* user */
308 #define	_SC_V7_LP64_OFF64	124 /* user */
309 #define	_SC_V7_LPBIG_OFFBIG	125 /* user */
310 #define	_SC_THREAD_ROBUST_PRIO_INHERIT 126 /* user */
311 #define	_SC_THREAD_ROBUST_PRIO_PROTECT 127 /* user */
312 #endif
313 
314 /* Keys for the confstr(3) function. */
315 #if __POSIX_VISIBLE >= 199209
316 #define	_CS_PATH		1	/* default value of PATH */
317 #endif
318 
319 #if __POSIX_VISIBLE >= 200112
320 #define	_CS_POSIX_V6_ILP32_OFF32_CFLAGS		2
321 #define	_CS_POSIX_V6_ILP32_OFF32_LDFLAGS	3
322 #define	_CS_POSIX_V6_ILP32_OFF32_LIBS		4
323 #define	_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS	5
324 #define	_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS	6
325 #define	_CS_POSIX_V6_ILP32_OFFBIG_LIBS		7
326 #define	_CS_POSIX_V6_LP64_OFF64_CFLAGS		8
327 #define	_CS_POSIX_V6_LP64_OFF64_LDFLAGS		9
328 #define	_CS_POSIX_V6_LP64_OFF64_LIBS		10
329 #define	_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS	11
330 #define	_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS	12
331 #define	_CS_POSIX_V6_LPBIG_OFFBIG_LIBS		13
332 #define	_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS	14
333 #endif
334 
335 #if __POSIX_VISIBLE >= 200809
336 #define	_CS_POSIX_V7_ILP32_OFF32_CFLAGS		15
337 #define	_CS_POSIX_V7_ILP32_OFF32_LDFLAGS	16
338 #define	_CS_POSIX_V7_ILP32_OFF32_LIBS		17
339 #define	_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS	18
340 #define	_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS	19
341 #define	_CS_POSIX_V7_ILP32_OFFBIG_LIBS		20
342 #define	_CS_POSIX_V7_LP64_OFF64_CFLAGS		21
343 #define	_CS_POSIX_V7_LP64_OFF64_LDFLAGS		22
344 #define	_CS_POSIX_V7_LP64_OFF64_LIBS		23
345 #define	_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS	24
346 #define	_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS	25
347 #define	_CS_POSIX_V7_LPBIG_OFFBIG_LIBS		26
348 #define	_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS	27
349 #endif
350 
351 __BEGIN_DECLS
352 /* 1003.1-1990 */
353 void	 _exit(int) __dead2;
354 int	 access(const char *, int);
355 unsigned int	 alarm(unsigned int);
356 int	 chdir(const char *);
357 int	 chown(const char *, uid_t, gid_t);
358 int	 close(int);
359 int	 dup(int);
360 int	 dup2(int, int);
361 #if __BSD_VISIBLE
362 int	 eaccess(const char *, int);
363 #endif
364 int	 execl(const char *, const char *, ...);
365 int	 execle(const char *, const char *, ...);
366 int	 execlp(const char *, const char *, ...);
367 int	 execv(const char *, char * const *);
368 int	 execve(const char *, char * const *, char * const *);
369 int	 execvp(const char *, char * const *);
370 pid_t	 fork(void);
371 long	 fpathconf(int, int);
372 char	*getcwd(char *, size_t);
373 gid_t	 getegid(void);
374 uid_t	 geteuid(void);
375 gid_t	 getgid(void);
376 int	 getgroups(int, gid_t []);
377 char	*getlogin(void);
378 pid_t	 getpgrp(void);
379 pid_t	 getpid(void);
380 pid_t	 getppid(void);
381 uid_t	 getuid(void);
382 int	 isatty(int);
383 int	 link(const char *, const char *);
384 #ifndef _LSEEK_DECLARED
385 #define	_LSEEK_DECLARED
386 off_t	 lseek(int, off_t, int);
387 #endif
388 long	 pathconf(const char *, int);
389 int	 pause(void);
390 int	 pipe(int *);
391 int	 pipe2(int *, int);
392 ssize_t	 read(int, void *, size_t);
393 int	 rmdir(const char *);
394 int	 setgid(gid_t);
395 int	 setpgid(pid_t, pid_t);
396 pid_t	 setsid(void);
397 int	 setuid(uid_t);
398 unsigned int	 sleep(unsigned int);
399 long	 sysconf(int);
400 pid_t	 tcgetpgrp(int);
401 int	 tcsetpgrp(int, pid_t);
402 char	*ttyname(int);
403 int	 ttyname_r(int, char *, size_t);
404 int	 unlink(const char *);
405 ssize_t	 write(int, const void *, size_t);
406 
407 /* 1003.2-1992 */
408 #if __POSIX_VISIBLE >= 199209 || __XSI_VISIBLE
409 size_t	 confstr(int, char *, size_t);
410 #ifndef _GETOPT_DECLARED
411 #define	_GETOPT_DECLARED
412 int	 getopt(int, char * const [], const char *);
413 
414 extern char *optarg;			/* getopt(3) external variables */
415 extern int optind, opterr, optopt;
416 #endif /* _GETOPT_DECLARED */
417 #endif
418 
419 /* ISO/IEC 9945-1: 1996 */
420 #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
421 int	 fsync(int);
422 
423 /*
424  * ftruncate() was in the POSIX Realtime Extension (it's used for shared
425  * memory), but truncate() was not.
426  */
427 #ifndef _FTRUNCATE_DECLARED
428 #define	_FTRUNCATE_DECLARED
429 int	 ftruncate(int, off_t);
430 #endif
431 #endif
432 
433 #if __POSIX_VISIBLE >= 199506
434 int	 getlogin_r(char *, int);
435 #endif
436 
437 /* 1003.1-2001 */
438 #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
439 int	 fchown(int, uid_t, gid_t);
440 ssize_t	 readlink(const char * __restrict, char * __restrict, size_t);
441 #endif
442 #if __POSIX_VISIBLE >= 200112
443 int	 gethostname(char *, size_t);
444 int	 setegid(gid_t);
445 int	 seteuid(uid_t);
446 #endif
447 
448 /* 1003.1-2008 */
449 #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
450 int	 getsid(pid_t _pid);
451 int	 fchdir(int);
452 int	 getpgid(pid_t _pid);
453 int	 lchown(const char *, uid_t, gid_t);
454 #ifndef _MKDTEMP_DECLARED
455 char	*mkdtemp(char *);
456 #define	_MKDTEMP_DECLARED
457 #endif
458 #ifndef _MKSTEMP_DECLARED
459 int	 mkstemp(char *);
460 #define	_MKSTEMP_DECLARED
461 #endif
462 ssize_t	 pread(int, void *, size_t, off_t);
463 ssize_t	 pwrite(int, const void *, size_t, off_t);
464 
465 /* See comment at ftruncate() above. */
466 #ifndef _TRUNCATE_DECLARED
467 #define	_TRUNCATE_DECLARED
468 int	 truncate(const char *, off_t);
469 #endif
470 #endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
471 
472 #if __POSIX_VISIBLE >= 200809
473 int	faccessat(int, const char *, int, int);
474 int	fchownat(int, const char *, uid_t, gid_t, int);
475 #if 0
476 int	fexecve(int, char *const [], char *const []);
477 #endif
478 int	linkat(int, const char *, int, const char *, int);
479 ssize_t	readlinkat(int, const char * __restrict, char * __restrict, size_t);
480 int	symlinkat(const char *, int, const char *);
481 int	unlinkat(int, const char *, int);
482 #endif /* __POSIX_VISIBLE >= 200809 */
483 
484 /*
485  * symlink() was originally in POSIX.1a, which was withdrawn after
486  * being overtaken by events (1003.1-2001).  It was in XPG4.2, and of
487  * course has been in BSD since 4.2.
488  */
489 #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 402
490 int	 symlink(const char * __restrict, const char * __restrict);
491 #endif
492 
493 /* X/Open System Interfaces */
494 #if __XSI_VISIBLE
495 char	*crypt(const char *, const char *);
496 /* char	*ctermid(char *); */		/* XXX ??? */
497 int	 encrypt(char *, int);
498 long	 gethostid(void);
499 int	 lockf(int, int, off_t);
500 int	 nice(int);
501 int	 setpgrp(pid_t _pid, pid_t _pgrp); /* obsoleted by setpgid() */
502 int	 setregid(gid_t, gid_t);
503 int	 setreuid(uid_t, uid_t);
504 
505 #ifndef _SWAB_DECLARED
506 #define _SWAB_DECLARED
507 void	 swab(const void * __restrict, void * __restrict, ssize_t);
508 #endif /* _SWAB_DECLARED */
509 
510 void	 sync(void);
511 
512 #endif /* __XSI_VISIBLE */
513 
514 #if (__XSI_VISIBLE && __XSI_VISIBLE <= 500) || __BSD_VISIBLE
515 int	 brk(const void *);
516 int	 chroot(const char *);
517 int	 chroot_kernel(const char *);
518 int	 getdtablesize(void);
519 int	 getpagesize(void) __pure2;
520 char	*getpass(const char *);
521 void	*sbrk(intptr_t);
522 #endif
523 
524 #if (__XSI_VISIBLE && __XSI_VISIBLE <= 600) || __BSD_VISIBLE
525 char	*getwd(char *);			/* LEGACY (obsoleted by getcwd()) */
526 unsigned int
527 	 ualarm(unsigned int, unsigned int);
528 int	 usleep(unsigned int);
529 pid_t	 vfork(void) __returns_twice;
530 #endif
531 
532 #if __BSD_VISIBLE
533 struct iovec;
534 int	 acct(const char *);
535 int	 async_daemon(void);
536 int	 closefrom(int);
537 const char *
538 	 crypt_get_format(void);
539 int	 crypt_set_format(const char *);
540 void	 endusershell(void);
541 int	 exect(const char *, char * const *, char * const *);
542 int	 execvP(const char *, const char *, char * const *);
543 void	 extexit(int, int, void *);
544 ssize_t	 extpread(int, void *, size_t, int, off_t);
545 ssize_t	 extpreadv(int, const struct iovec *, u_int, int, off_t);
546 ssize_t	 extpwrite(int, const void *, size_t, int, off_t);
547 ssize_t	 extpwritev(int, const struct iovec *, u_int, int, off_t);
548 char	*fflagstostr(u_long);
549 int	 getdomainname(char *, int);
550 int	 getgrouplist(const char *, gid_t, gid_t *, int *);
551 mode_t	 getmode(const void *, mode_t);
552 int	 getosreldate(void);
553 int	 getpeereid(int, uid_t *, gid_t *);
554 int	 getresgid(gid_t *, gid_t *, gid_t *);
555 int	 getresuid(uid_t *, uid_t *, uid_t *);
556 char	*getusershell(void);
557 int	 initgroups(const char *, gid_t);
558 int	 iruserok(unsigned long, int, const char *, const char *);
559 int	 iruserok_sa(const void *, int, int, const char *, const char *);
560 int	 issetugid(void);
561 long	 lpathconf(const char *, int);
562 int	 lwp_create(struct lwp_params *);
563 lwpid_t	 lwp_gettid(void);
564 int	 lwp_setname(lwpid_t, const char *);
565 #ifndef	_MKNOD_DECLARED
566 int	 mknod(const char *, mode_t, dev_t);
567 #define	_MKNOD_DECLARED
568 #endif
569 int	 mkstemps(char *, int);
570 #ifndef _MKTEMP_DECLARED
571 char	*mktemp(char *);
572 #define	_MKTEMP_DECLARED
573 #endif
574 int	 nfssvc(int, void *);
575 int	 profil(char *, size_t, vm_offset_t, int);
576 int	 rcmd(char **, int, const char *, const char *, const char *, int *);
577 int	 rcmd_af(char **, int, const char *, const char *, const char *, int *,
578 		 int);
579 int	 rcmdsh(char **, int, const char *, const char *, const char *,
580 		const char *);
581 char	*re_comp(const char *);
582 int	 re_exec(const char *);
583 int	 reboot(int);
584 int	 revoke(const char *);
585 pid_t	 rfork(int);
586 pid_t	 rfork_thread(int, void *, int (*)(void *), void *);
587 int	 rresvport(int *);
588 int	 rresvport_af(int *, int);
589 int	 ruserok(const char *, int, const char *, const char *);
590 int	 setdomainname(const char *, int);
591 int	 setgroups(int, const gid_t *);
592 void	 sethostid(long);
593 int	 sethostname(const char *, int);
594 int	 setlogin(const char *);
595 void	*setmode(const char *);
596 void	 setproctitle(const char *_fmt, ...) __printf0like(1, 2);
597 int	 setresgid(gid_t, gid_t, gid_t);
598 int	 setresuid(uid_t, uid_t, uid_t);
599 int	 setrgid(gid_t);
600 int	 setruid(uid_t);
601 void	 setusershell(void);
602 int	 strtofflags(char **, u_long *, u_long *);
603 int	 swapoff(const char *);
604 int	 swapon(const char *);
605 int	 syscall(int, ...);
606 off_t	 __syscall(quad_t, ...);
607 int	 ttyslot(void);
608 int	 umtx_sleep(volatile const int *, int , int);
609 int	 umtx_wakeup(volatile const int *, int);
610 int	 undelete(const char *);
611 void	*valloc(size_t);			/* obsoleted by malloc() */
612 int	 varsym_get(int, const char *, char *, int);
613 int	 varsym_list(int, char *, int, int *);
614 int	 varsym_set(int, const char *, const char *);
615 
616 #ifndef _OPTRESET_DECLARED
617 #define	_OPTRESET_DECLARED
618 extern int optreset;			/* getopt(3) external variable */
619 #endif
620 #endif /* __BSD_VISIBLE */
621 __END_DECLS
622 
623 #endif /* !_UNISTD_H_ */
624