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