xref: /titanic_41/usr/src/head/unistd.h (revision ba7866cd2cbdf574f47d4e38a1301b90744dd677)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 /*	Copyright (c) 1988 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 #ifndef _UNISTD_H
30 #define	_UNISTD_H
31 
32 #include <sys/feature_tests.h>
33 
34 #include <sys/types.h>
35 #include <sys/unistd.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /* Symbolic constants for the "access" routine: */
42 #define	R_OK	4	/* Test for Read permission */
43 #define	W_OK	2	/* Test for Write permission */
44 #define	X_OK	1	/* Test for eXecute permission */
45 #define	F_OK	0	/* Test for existence of File */
46 
47 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
48 #define	F_ULOCK	0	/* Unlock a previously locked region */
49 #define	F_LOCK	1	/* Lock a region for exclusive use */
50 #define	F_TLOCK	2	/* Test and lock a region for exclusive use */
51 #define	F_TEST	3	/* Test a region for other processes locks */
52 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
53 
54 /* Symbolic constants for the "lseek" routine: */
55 
56 #ifndef	SEEK_SET
57 #define	SEEK_SET	0	/* Set file pointer to "offset" */
58 #endif
59 
60 #ifndef	SEEK_CUR
61 #define	SEEK_CUR	1	/* Set file pointer to current plus "offset" */
62 #endif
63 
64 #ifndef	SEEK_END
65 #define	SEEK_END	2	/* Set file pointer to EOF plus "offset" */
66 #endif
67 
68 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
69 #ifndef	SEEK_DATA
70 #define	SEEK_DATA	3	/* Set file pointer to next data past offset */
71 #endif
72 
73 #ifndef	SEEK_HOLE
74 #define	SEEK_HOLE	4	/* Set file pointer to next hole past offset */
75 #endif
76 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
77 
78 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
79 /* Path names: */
80 #define	GF_PATH	"/etc/group"	/* Path name of the "group" file */
81 #define	PF_PATH	"/etc/passwd"	/* Path name of the "passwd" file */
82 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
83 
84 /*
85  * compile-time symbolic constants,
86  * Support does not mean the feature is enabled.
87  * Use pathconf/sysconf to obtain actual configuration value.
88  */
89 
90 /* Values unchanged in UNIX 03 */
91 #define	_POSIX_ASYNC_IO			1
92 #define	_POSIX_JOB_CONTROL		1
93 #define	_POSIX_SAVED_IDS		1
94 #define	_POSIX_SYNC_IO			1
95 
96 /*
97  * POSIX.1b compile-time symbolic constants.
98  */
99 #if defined(_XPG6)
100 #define	_POSIX_ASYNCHRONOUS_IO		200112L
101 #define	_POSIX_FSYNC			200112L
102 #define	_POSIX_MAPPED_FILES		200112L
103 #define	_POSIX_MEMLOCK			200112L
104 #define	_POSIX_MEMLOCK_RANGE		200112L
105 #define	_POSIX_MEMORY_PROTECTION	200112L
106 #define	_POSIX_MESSAGE_PASSING		200112L
107 #define	_POSIX_PRIORITY_SCHEDULING	200112L
108 #define	_POSIX_REALTIME_SIGNALS		200112L
109 #define	_POSIX_SEMAPHORES		200112L
110 #define	_POSIX_SHARED_MEMORY_OBJECTS	200112L
111 #define	_POSIX_SYNCHRONIZED_IO		200112L
112 #else
113 #define	_POSIX_ASYNCHRONOUS_IO		1
114 #define	_POSIX_FSYNC			1
115 #define	_POSIX_MAPPED_FILES		1
116 #define	_POSIX_MEMLOCK			1
117 #define	_POSIX_MEMLOCK_RANGE		1
118 #define	_POSIX_MEMORY_PROTECTION	1
119 #define	_POSIX_MESSAGE_PASSING		1
120 #define	_POSIX_PRIORITY_SCHEDULING	1
121 #define	_POSIX_REALTIME_SIGNALS		1
122 #define	_POSIX_SEMAPHORES		1
123 #define	_POSIX_SHARED_MEMORY_OBJECTS	1
124 #define	_POSIX_SYNCHRONIZED_IO		1
125 #endif
126 
127 /*
128  * POSIX.1c compile-time symbolic constants.
129  */
130 #if defined(_XPG6)
131 #define	_POSIX_THREAD_SAFE_FUNCTIONS		200112L
132 #define	_POSIX_THREADS				200112L
133 #define	_POSIX_THREAD_ATTR_STACKADDR		200112L
134 #define	_POSIX_THREAD_ATTR_STACKSIZE		200112L
135 #define	_POSIX_THREAD_PROCESS_SHARED		200112L
136 #define	_POSIX_THREAD_PRIORITY_SCHEDULING	200112L
137 #define	_POSIX_TIMERS				200112L
138 #else
139 #define	_POSIX_THREAD_SAFE_FUNCTIONS		1
140 #define	_POSIX_THREADS				1
141 #define	_POSIX_THREAD_ATTR_STACKADDR		1
142 #define	_POSIX_THREAD_ATTR_STACKSIZE		1
143 #define	_POSIX_THREAD_PROCESS_SHARED		1
144 #define	_POSIX_THREAD_PRIORITY_SCHEDULING	1
145 #define	_POSIX_TIMERS				1
146 #endif
147 
148 /* New in UNIX 03 */
149 #define	_POSIX_ADVISORY_INFO			200112L
150 #define	_POSIX_BARRIERS				200112L
151 #define	_POSIX_CLOCK_SELECTION			200112L
152 #define	_POSIX_IPV6				200112L
153 #define	_POSIX_MONOTONIC_CLOCK			200112L
154 #define	_POSIX_RAW_SOCKETS			200112L
155 #define	_POSIX_READER_WRITER_LOCKS		200112L
156 #define	_POSIX_SPAWN				200112L
157 #define	_POSIX_SPIN_LOCKS			200112L
158 #define	_POSIX_TIMEOUTS				200112L
159 
160 /*
161  * Support for the POSIX.1 mutex protocol attribute. For realtime applications
162  * which need mutexes to support priority inheritance/ceiling.
163  */
164 #if defined(_XPG6)
165 #define	_POSIX_THREAD_PRIO_INHERIT	200112L
166 #define	_POSIX_THREAD_PRIO_PROTECT	200112L
167 #else
168 #define	_POSIX_THREAD_PRIO_INHERIT	1
169 #define	_POSIX_THREAD_PRIO_PROTECT	1
170 #endif
171 
172 #ifndef _POSIX_VDISABLE
173 #define	_POSIX_VDISABLE		0
174 #endif
175 
176 #ifndef NULL
177 #if defined(_LP64)
178 #define	NULL	0L
179 #else
180 #define	NULL	0
181 #endif
182 #endif
183 
184 #define	STDIN_FILENO	0
185 #define	STDOUT_FILENO	1
186 #define	STDERR_FILENO	2
187 
188 /*
189  * Large File Summit-related announcement macros.  The system supports both
190  * the additional and transitional Large File Summit interfaces.  (The final
191  * two macros provide a finer granularity breakdown of _LFS64_LARGEFILE.)
192  */
193 #define	_LFS_LARGEFILE		1
194 #define	_LFS64_LARGEFILE	1
195 #define	_LFS64_STDIO		1
196 #define	_LFS64_ASYNCHRONOUS_IO	1
197 
198 /* large file compilation environment setup */
199 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
200 #ifdef	__PRAGMA_REDEFINE_EXTNAME
201 #pragma redefine_extname	ftruncate	ftruncate64
202 #pragma redefine_extname	lseek		lseek64
203 #pragma redefine_extname	pread		pread64
204 #pragma redefine_extname	pwrite		pwrite64
205 #pragma redefine_extname	truncate	truncate64
206 #pragma redefine_extname	lockf		lockf64
207 #pragma	redefine_extname	tell		tell64
208 #else	/* __PRAGMA_REDEFINE_EXTNAME */
209 #define	ftruncate			ftruncate64
210 #define	lseek				lseek64
211 #define	pread				pread64
212 #define	pwrite				pwrite64
213 #define	truncate			truncate64
214 #define	lockf				lockf64
215 #define	tell				tell64
216 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
217 #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
218 
219 /* In the LP64 compilation environment, the APIs are already large file */
220 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
221 #ifdef	__PRAGMA_REDEFINE_EXTNAME
222 #pragma redefine_extname	ftruncate64	ftruncate
223 #pragma redefine_extname	lseek64		lseek
224 #pragma redefine_extname	pread64		pread
225 #pragma redefine_extname	pwrite64	pwrite
226 #pragma redefine_extname	truncate64	truncate
227 #pragma redefine_extname	lockf64		lockf
228 #pragma redefine_extname	tell64		tell
229 #else	/* __PRAGMA_REDEFINE_EXTNAME */
230 #define	ftruncate64			ftruncate
231 #define	lseek64				lseek
232 #define	pread64				pread
233 #define	pwrite64			pwrite
234 #define	truncate64			truncate
235 #define	lockf64				lockf
236 #define	tell64				tell
237 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
238 #endif	/* _LP64 && _LARGEFILE64_SOURCE */
239 
240 #if defined(__STDC__)
241 
242 extern int access(const char *, int);
243 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
244 extern int acct(const char *);
245 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
246 extern unsigned alarm(unsigned);
247 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
248 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
249 	defined(__EXTENSIONS__)
250 extern int brk(void *);
251 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */
252 extern int chdir(const char *);
253 extern int chown(const char *, uid_t, gid_t);
254 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
255 #if !defined(_POSIX_C_SOURCE) || (defined(_XOPEN_SOURCE) && \
256 	!defined(_XPG6)) || defined(__EXTENSIONS__)
257 extern int chroot(const char *);
258 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE))... */
259 extern int close(int);
260 #if defined(_XPG4) || defined(__EXTENSIONS__)
261 extern size_t confstr(int, char *, size_t);
262 extern char *crypt(const char *, const char *);
263 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
264 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
265 	defined(__EXTENSIONS__)
266 extern char *ctermid(char *);
267 #endif /* (!defined(_POSIX_C_SOURCE) ... */
268 #if !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) || defined(__EXTENSIONS__)
269 extern char *ctermid_r(char *);
270 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) ... */
271 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
272 #if !defined(_XPG6) || defined(__EXTENSIONS__)
273 extern char *cuserid(char *);
274 #endif
275 extern int dup(int);
276 extern int dup2(int, int);
277 #if defined(_XPG4) || defined(__EXTENSIONS__)
278 extern void encrypt(char *, int);
279 #endif /* defined(XPG4) || defined(__EXTENSIONS__) */
280 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
281 extern void endusershell(void);
282 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
283 extern int execl(const char *, const char *, ...);
284 extern int execle(const char *, const char *, ...);
285 extern int execlp(const char *, const char *, ...);
286 extern int execv(const char *, char *const *);
287 extern int execve(const char *, char *const *, char *const *);
288 extern int execvp(const char *, char *const *);
289 extern void _exit(int)
290 	__NORETURN;
291 /*
292  * The following fattach prototype is duplicated in <stropts.h>. The
293  * duplication is necessitated by XPG4.2 which requires the prototype
294  * be defined in <stropts.h>.
295  */
296 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
297 extern int fattach(int, const char *);
298 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
299 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
300 extern int fchdir(int);
301 extern int fchown(int, uid_t, gid_t);
302 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
303 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
304 extern int fchroot(int);
305 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
306 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
307 	defined(__EXTENSIONS__)
308 extern int fdatasync(int);
309 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
310 /*
311  * The following fdetach prototype is duplicated in <stropts.h>. The
312  * duplication is necessitated by XPG4.2 which requires the prototype
313  * be defined in <stropts.h>.
314  */
315 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
316 extern int fdetach(const char *);
317 #endif /* !defined(__XOPEN_OR_POSIX)... */
318 extern pid_t fork(void);
319 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
320 extern pid_t fork1(void);
321 extern pid_t forkall(void);
322 #endif /* !defined(__XOPEN_OR_POSIX)... */
323 extern long fpathconf(int, int);
324 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \
325 	defined(__EXTENSIONS__)
326 extern int fsync(int);
327 #endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */
328 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
329 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
330 	defined(__EXTENSIONS__)
331 extern int ftruncate(int, off_t);
332 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
333 extern char *getcwd(char *, size_t);
334 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
335 	defined(__EXTENSIONS__)
336 extern int getdtablesize(void);
337 #endif
338 extern gid_t getegid(void);
339 extern uid_t geteuid(void);
340 extern gid_t getgid(void);
341 extern int getgroups(int, gid_t *);
342 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
343 extern long gethostid(void);
344 #endif
345 #if defined(_XPG4_2)
346 extern int gethostname(char *, size_t);
347 #elif  !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
348 extern int gethostname(char *, int);
349 #endif
350 extern char *getlogin(void);
351 #if defined(_XPG4) || defined(__EXTENSIONS__)
352 extern int  getopt(int, char *const *, const char *);
353 extern char *optarg;
354 extern int  opterr, optind, optopt;
355 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
356 #if !defined(_XPG6) || defined(__EXTENSIONS__)
357 extern char *getpass(const char *);
358 #endif
359 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
360 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
361 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
362 #if !defined(_XPG6) || defined(__EXTENSIONS__)
363 extern int getpagesize(void);
364 #endif
365 extern pid_t getpgid(pid_t);
366 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
367 extern pid_t getpid(void);
368 extern pid_t getppid(void);
369 extern pid_t getpgrp(void);
370 
371 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
372 char *gettxt(const char *, const char *);
373 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
374 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
375 extern pid_t getsid(pid_t);
376 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
377 extern uid_t getuid(void);
378 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
379 extern char *getusershell(void);
380 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
381 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
382 extern char *getwd(char *);
383 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
384 /*
385  * The following ioctl prototype is duplicated in <stropts.h>. The
386  * duplication is necessitated by XPG4.2 which requires the prototype
387  * be defined in <stropts.h>.
388  */
389 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
390 extern int ioctl(int, int, ...);
391 extern int isaexec(const char *, char *const *, char *const *);
392 extern int issetugid(void);
393 #endif
394 extern int isatty(int);
395 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
396 extern int lchown(const char *, uid_t, gid_t);
397 #endif
398 extern int link(const char *, const char *);
399 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
400 extern offset_t llseek(int, offset_t, int);
401 #endif
402 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
403 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
404 	defined(__EXTENSIONS__)
405 extern int lockf(int, int, off_t);
406 #endif
407 extern off_t lseek(int, off_t, int);
408 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
409 	defined(__EXTENSIONS__)
410 extern int nice(int);
411 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
412 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
413 extern int mincore(caddr_t, size_t, char *);
414 #endif
415 extern long pathconf(const char *, int);
416 extern int pause(void);
417 extern int pipe(int *);
418 #if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \
419 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
420 	defined(__EXTENSIONS__)
421 extern ssize_t pread(int, void *, size_t, off_t);
422 #endif
423 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
424 extern void profil(unsigned short *, size_t, unsigned long, unsigned int);
425 #endif
426 /*
427  * pthread_atfork() is also declared in <pthread.h> as per SUSv3. The
428  * declarations are identical. A change to either one may also require
429  * appropriate namespace updates in order to avoid redeclaration
430  * warnings in the case where both prototypes are exposed via inclusion
431  * of both <pthread.h> and <unistd.h>.
432  */
433 #if !defined(__XOPEN_OR_POSIX) || \
434 	((_POSIX_C_SOURCE > 2) && !defined(_XPG6)) || \
435 	defined(__EXTENSIONS__)
436 extern int pthread_atfork(void (*) (void), void (*) (void), void (*) (void));
437 #endif /* !defined(__XOPEN_OR_POSIX) || ((_POSIX_C_SOURCE > 2) ... */
438 #if !defined(_LP64) && \
439 	(!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__))
440 extern int ptrace(int, pid_t, int, int);
441 #endif
442 #if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \
443 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
444 	defined(__EXTENSIONS__)
445 extern ssize_t pwrite(int, const void *, size_t, off_t);
446 #endif
447 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
448 /* per RFC 3542; This is also defined in netdb.h */
449 extern int rcmd_af(char **, unsigned short, const char *, const char *,
450 	const char *, int *, int);
451 #endif
452 extern ssize_t read(int, void *, size_t);
453 #if !defined(__XOPEN_OR_POSIX) || \
454 	defined(_XPG4_2) || defined(__EXTENSIONS__)
455 extern ssize_t readlink(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD,
456 	size_t);
457 #endif
458 #if (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3) && !defined(_XPG4))) || \
459 	defined(__EXTENSIONS__)
460 extern int rename(const char *, const char *);
461 #endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */
462 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
463 extern int resolvepath(const char *, char *, size_t);
464 /* per RFC 3542; This is also defined in netdb.h */
465 extern int rexec_af(char **, unsigned short, const char *, const char *,
466 	const char *, int *, int);
467 #endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */
468 extern int rmdir(const char *);
469 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
470 /* per RFC 3542; This is also defined in netdb.h */
471 extern int rresvport_af(int *, int);
472 #endif
473 
474 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
475 	defined(__EXTENSIONS__)
476 extern void *sbrk(intptr_t);
477 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */
478 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
479 extern int setegid(gid_t);
480 extern int seteuid(uid_t);
481 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */
482 extern int setgid(gid_t);
483 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
484 extern int setgroups(int, const gid_t *);
485 extern int sethostname(char *, int);
486 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
487 extern int setpgid(pid_t, pid_t);
488 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
489 extern pid_t setpgrp(void);
490 extern int setregid(gid_t, gid_t);
491 extern int setreuid(uid_t, uid_t);
492 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
493 extern pid_t setsid(void);
494 extern int setuid(uid_t);
495 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
496 extern void setusershell(void);
497 #endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */
498 extern unsigned sleep(unsigned);
499 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
500 extern int stime(const time_t *);
501 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
502 #if defined(_XPG4)
503 /* __EXTENSIONS__ makes the SVID Third Edition prototype in stdlib.h visible */
504 extern void swab(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, ssize_t);
505 #endif /* defined(_XPG4) */
506 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
507 extern int symlink(const char *, const char *);
508 extern void sync(void);
509 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) */
510 #if defined(_XPG5) && !defined(_XPG6)
511 #ifdef __PRAGMA_REDEFINE_EXTNAME
512 #pragma redefine_extname sysconf __sysconf_xpg5
513 #else /* __PRAGMA_REDEFINE_EXTNAME */
514 #define	sysconf __sysconf_xpg5
515 #endif  /* __PRAGMA_REDEFINE_EXTNAME */
516 #endif /* defined(_XPG5) && !defined(_XPG6) */
517 extern long sysconf(int);
518 extern pid_t tcgetpgrp(int);
519 extern int tcsetpgrp(int, pid_t);
520 #if !defined(__XOPEN_OR_POSIX) || \
521 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
522 	defined(__EXTENSIONS__)
523 extern off_t tell(int);
524 #endif /* !defined(__XOPEN_OR_POSIX)... */
525 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
526 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
527 	defined(__EXTENSIONS__)
528 extern int truncate(const char *, off_t);
529 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
530 extern char *ttyname(int);
531 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
532 extern useconds_t ualarm(useconds_t, useconds_t);
533 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
534 extern int unlink(const char *);
535 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
536 extern int usleep(useconds_t);
537 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
538 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
539 extern pid_t vfork(void);
540 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
541 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
542 extern void vhangup(void);
543 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
544 extern ssize_t write(int, const void *, size_t);
545 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
546 extern void yield(void);
547 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
548 
549 #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \
550 	defined(__EXTENSIONS__)
551 	/* || defined(_XPG7) */
552 extern int faccessat(int, const char *, int, int);
553 extern int fchownat(int, const char *, uid_t, gid_t, int);
554 extern int linkat(int, const char *, int, const char *, int);
555 extern ssize_t readlinkat(int, const char *_RESTRICT_KYWD,
556 	char *_RESTRICT_KYWD, size_t);
557 extern int renameat(int, const char *, int, const char *);
558 extern int symlinkat(const char *, int, const char *);
559 extern int unlinkat(int, const char *, int);
560 #endif	/* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */
561 
562 /* transitional large file interface versions */
563 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
564 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
565 extern int ftruncate64(int, off64_t);
566 extern off64_t lseek64(int, off64_t, int);
567 extern ssize_t	pread64(int, void *, size_t, off64_t);
568 extern ssize_t	pwrite64(int, const void *, size_t, off64_t);
569 extern off64_t	tell64(int);
570 extern int	truncate64(const char *, off64_t);
571 extern int	lockf64(int, int, off64_t);
572 #endif	/* _LARGEFILE64_SOURCE */
573 
574 #else  /* __STDC__ */
575 
576 extern int access();
577 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
578 extern int acct();
579 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
580 extern unsigned alarm();
581 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
582 	defined(__EXTENSIONS__)
583 extern int brk();
584 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */
585 extern int chdir();
586 extern int chown();
587 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
588 	defined(__EXTENSIONS__)
589 extern int chroot();
590 #endif /* (!defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
591 extern int close();
592 #if defined(_XPG4) || defined(__EXTENSIONS__)
593 extern size_t confstr();
594 extern char *crypt();
595 #endif /* defined(XPG4) || defined(__EXTENSIONS__) */
596 #if !defined(_POSIX_C_SOURCE) || defined(_XPG3) || defined(__EXTENSIONS__)
597 extern char *ctermid();
598 #endif /* (!defined(_POSIX_C_SOURCE) || defined(_XPG3)... */
599 #if !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) || defined(__EXTENSIONS__)
600 extern char *ctermid_r();
601 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) ... */
602 #if !defined(_XPG6) || defined(__EXTENSIONS__)
603 extern char *cuserid();
604 #endif
605 extern int dup();
606 extern int dup2();
607 #if defined(_XPG4) || defined(__EXTENSIONS__)
608 extern void encrypt();
609 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
610 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
611 extern void endusershell();
612 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
613 extern int execl();
614 extern int execle();
615 extern int execlp();
616 extern int execv();
617 extern int execve();
618 extern int execvp();
619 extern void _exit();
620 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
621 extern int fattach();
622 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
623 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
624 extern int fchdir();
625 extern int fchown();
626 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
627 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
628 extern int fchroot();
629 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
630 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
631 	defined(__EXTENSIONS__)
632 extern int fdatasync();
633 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
634 #if !defined(__XOPEN_OR_POSIX)
635 extern int fdetach();
636 #endif /* !defined(__XOPEN_OR_POSIX) */
637 extern pid_t fork();
638 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
639 extern pid_t fork1();
640 extern pid_t forkall();
641 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
642 extern long fpathconf();
643 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \
644 	defined(__EXTENSIONS__)
645 extern int fsync();
646 #endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */
647 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
648 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
649 	defined(__EXTENSIONS__)
650 extern int ftruncate();
651 #endif /* !defined(__XOPEN_OR_POSIX) (_POSIX_C_SOURCE > 2)... */
652 extern char *getcwd();
653 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
654 	defined(__EXTENSIONS__)
655 extern int getdtablesize();
656 #endif
657 extern gid_t getegid();
658 extern uid_t geteuid();
659 extern gid_t getgid();
660 extern int getgroups();
661 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
662 extern long gethostid();
663 #endif
664 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
665 extern int gethostname();
666 #endif
667 extern char *getlogin();
668 #if defined(_XPG4) || defined(__EXTENSIONS__)
669 extern int  getopt();
670 extern char *optarg;
671 extern int  opterr, optind, optopt;
672 #if !defined(_XPG6) || defined(__EXTENSIONS__)
673 extern char *getpass();
674 #endif
675 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
676 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
677 #if !defined(_XPG6) || defined(__EXTENSIONS__)
678 extern int getpagesize();
679 #endif
680 extern pid_t getpgid();
681 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
682 extern pid_t getpid();
683 extern pid_t getppid();
684 extern pid_t getpgrp();
685 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
686 char *gettxt();
687 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
688 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
689 extern pid_t getsid();
690 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) */
691 extern uid_t getuid();
692 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
693 extern char *getusershell();
694 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
695 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
696 extern char *getwd();
697 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
698 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
699 extern int ioctl();
700 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
701 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
702 extern int isaexec();
703 extern int issetugid();
704 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
705 extern int isatty();
706 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
707 extern int lchown();
708 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) */
709 extern int link();
710 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
711 extern offset_t llseek();
712 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
713 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
714 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
715 	defined(__EXTENSIONS__)
716 extern int lockf();
717 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
718 extern off_t lseek();
719 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
720 extern int mincore();
721 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
722 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
723 	defined(__EXTENSIONS__)
724 extern int nice();
725 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
726 extern long pathconf();
727 extern int pause();
728 extern int pipe();
729 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG5) || \
730 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
731 	defined(__EXTENSIONS__)
732 extern ssize_t pread();
733 #endif
734 #if !defined(_LP64) && \
735 	(!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__))
736 extern void profil();
737 extern int ptrace();
738 #endif
739 #if !defined(__XOPEN_OR_POSIX) || \
740 	((_POSIX_C_SOURCE > 2) && !defined(_XPG6)) || \
741 	defined(__EXTENSIONS__)
742 extern int pthread_atfork();
743 #endif /* !defined(__XOPEN_OR_POSIX) || ((_POSIX_C_SOURCE > 2) ...  */
744 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG5) || \
745 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
746 	defined(__EXTENSIONS__)
747 extern ssize_t pwrite();
748 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG5) */
749 extern ssize_t read();
750 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
751 /* per RFC 3542; This is also defined in netdb.h */
752 extern int rcmd_af();
753 #endif
754 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
755 extern ssize_t readlink();
756 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
757 #if (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3) && !defined(_XPG4))) || \
758 	defined(__EXTENSIONS__)
759 extern int rename();
760 #endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */
761 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
762 extern int resolvepath();
763 /* per RFC 3542; This is also defined in netdb.h */
764 extern int rexec_af();
765 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
766 extern int rmdir();
767 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
768 /* per RFC 3542; This is also defined in netdb.h */
769 extern int rresvport_af();
770 #endif
771 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
772 	defined(__EXTENSIONS__)
773 extern void *sbrk();
774 #endif /* !defined(__XOPEN_OR_POSIX)|| (defined(_XPG4_2)... */
775 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
776 extern int setegid();
777 extern int seteuid();
778 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */
779 extern int setgid();
780 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
781 extern int setgroups();
782 extern int sethostname();
783 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
784 extern int setpgid();
785 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
786 extern pid_t setpgrp();
787 extern int setregid();
788 extern int setreuid();
789 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
790 extern pid_t setsid();
791 extern int setuid();
792 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
793 extern void setusershell();
794 #endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */
795 extern unsigned sleep();
796 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
797 extern int stime();
798 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
799 #if defined(_XPG4)
800 /* __EXTENSIONS__ makes the SVID Third Edition prototype in stdlib.h visible */
801 extern void swab();
802 #endif /* defined(_XPG4) */
803 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
804 extern int symlink();
805 extern void sync();
806 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
807 #if defined(_XPG5)
808 #ifdef __PRAGMA_REDEFINE_EXTNAME
809 #pragma redefine_extname sysconf __sysconf_xpg5
810 extern long sysconf();
811 #else /* __PRAGMA_REDEFINE_EXTNAME */
812 extern long __sysconf_xpg5();
813 #define	sysconf __sysconf_xpg5
814 #endif  /* __PRAGMA_REDEFINE_EXTNAME */
815 #endif	/* defined(_XPG5) */
816 extern pid_t tcgetpgrp();
817 extern int tcsetpgrp();
818 #if !defined(__XOPEN_OR_POSIX) || \
819 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
820 	defined(__EXTENSIONS__)
821 extern off_t tell();
822 #endif /* !defined(__XOPEN_OR_POSIX)... */
823 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
824 	(defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
825 	defined(__EXTENSIONS__)
826 extern int truncate();
827 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
828 extern char *ttyname();
829 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
830 extern useconds_t ualarm();
831 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
832 extern int unlink();
833 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
834 extern int usleep();
835 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
836 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
837 extern pid_t vfork();
838 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
839 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
840 extern void vhangup();
841 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
842 extern ssize_t write();
843 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
844 extern void yield();
845 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
846 
847 #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \
848 	defined(__EXTENSIONS__)
849 	/* || defined(_XPG7) */
850 extern int faccessat();
851 extern int fchownat();
852 extern int linkat();
853 extern ssize_t readlinkat();
854 extern int renameat();
855 extern int symlinkat();
856 extern int unlinkat();
857 #endif	/* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */
858 
859 /* transitional large file interface versions */
860 #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
861 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
862 extern int ftruncate64();
863 extern off64_t lseek64();
864 extern ssize_t pread64();
865 extern ssize_t pwrite64();
866 extern off64_t tell64();
867 extern int truncate64();
868 extern int lockf64();
869 #endif	/* _LARGEFILE64_SOURCE */
870 
871 #endif /* __STDC__ */
872 
873 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
874 #pragma unknown_control_flow(vfork)
875 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
876 
877 /*
878  * getlogin_r() & ttyname_r() prototypes are defined here.
879  */
880 
881 /*
882  * Previous releases of Solaris, starting at 2.3, provided definitions of
883  * various functions as specified in POSIX.1c, Draft 6.  For some of these
884  * functions, the final POSIX 1003.1c standard had a different number of
885  * arguments and return values.
886  *
887  * The following segment of this header provides support for the standard
888  * interfaces while supporting applications written under earlier
889  * releases.  The application defines appropriate values of the feature
890  * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
891  * whether it was written to expect the Draft 6 or standard versions of
892  * these interfaces, before including this header.  This header then
893  * provides a mapping from the source version of the interface to an
894  * appropriate binary interface.  Such mappings permit an application
895  * to be built from libraries and objects which have mixed expectations
896  * of the definitions of these functions.
897  *
898  * For applications using the Draft 6 definitions, the binary symbol is the
899  * same as the source symbol, and no explicit mapping is needed.  For the
900  * standard interface, the function func() is mapped to the binary symbol
901  * _posix_func().  The preferred mechanism for the remapping is a compiler
902  * #pragma.  If the compiler does not provide such a #pragma, the header file
903  * defines a static function func() which calls the _posix_func() version;
904  * this has to be done instead of #define since POSIX specifies that an
905  * application can #undef the symbol and still be bound to the correct
906  * implementation.  Unfortunately, the statics confuse lint so we fallback to
907  * #define in that case.
908  *
909  * NOTE: Support for the Draft 6 definitions is provided for compatibility
910  * only.  New applications/libraries should use the standard definitions.
911  */
912 
913 #if	defined(__EXTENSIONS__) || defined(_REENTRANT) || \
914 	!defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \
915 	defined(_POSIX_PTHREAD_SEMANTICS)
916 
917 #if	defined(__STDC__)
918 
919 #if	(_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
920 
921 #ifdef __PRAGMA_REDEFINE_EXTNAME
922 #pragma redefine_extname getlogin_r __posix_getlogin_r
923 #pragma redefine_extname ttyname_r __posix_ttyname_r
924 extern int getlogin_r(char *, int);
925 extern int ttyname_r(int, char *, size_t);
926 #else  /* __PRAGMA_REDEFINE_EXTNAME */
927 
928 extern int __posix_getlogin_r(char *, int);
929 extern int __posix_ttyname_r(int, char *, size_t);
930 
931 #ifdef __lint
932 
933 #define	getlogin_r	__posix_getlogin_r
934 #define	ttyname_r	__posix_ttyname_r
935 
936 #else /* !__lint */
937 
938 static int
939 getlogin_r(char *__name, int __len)
940 {
941 	return (__posix_getlogin_r(__name, __len));
942 }
943 static int
944 ttyname_r(int __fildes, char *__buf, size_t __size)
945 {
946 	return (__posix_ttyname_r(__fildes, __buf, __size));
947 }
948 
949 #endif /* !__lint */
950 #endif /* __PRAGMA_REDEFINE_EXTNAME */
951 
952 #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
953 
954 extern char *getlogin_r(char *, int);
955 extern char *ttyname_r(int, char *, int);
956 
957 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
958 
959 #else  /* __STDC__ */
960 
961 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
962 
963 #ifdef __PRAGMA_REDEFINE_EXTNAME
964 #pragma redefine_extname getlogin_r __posix_getlogin_r
965 #pragma redefine_extname ttyname_r __posix_ttyname_r
966 extern int getlogin_r();
967 extern int ttyname_r();
968 #else  /* __PRAGMA_REDEFINE_EXTNAME */
969 
970 extern int __posix_getlogin_r();
971 extern int __posix_ttyname_r();
972 
973 #ifdef	__lint
974 
975 #define	getlogin_r	__posix_getlogin_r
976 #define	ttyname_r	__posix_ttyname_r
977 
978 #else /* !__lint */
979 
980 static int
981 getlogin_r(__name, __len)
982 	char *__name;
983 	int __len;
984 {
985 	return (__posix_getlogin_r(__name, __len));
986 }
987 static int
988 ttyname_r(__fildes, __buf, __size)
989 	int __fildes;
990 	char *__buf;
991 	size_t __size;
992 {
993 	return (__posix_ttyname_r(__fildes, __buf, __size));
994 }
995 #endif /* !__lint */
996 #endif /* __PRAGMA_REDEFINE_EXTNAME */
997 
998 #else  /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
999 
1000 extern char *getlogin_r();
1001 extern char *ttyname_r();
1002 
1003 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
1004 
1005 #endif /* __STDC__ */
1006 
1007 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */
1008 
1009 #ifdef	__cplusplus
1010 }
1011 #endif
1012 
1013 #endif /* _UNISTD_H */
1014