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