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.
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.
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]
23 * Copyright 2014 PALO, Richard.
24 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25 * Copyright (c) 2013 Gary Mills
27 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
30 /* Copyright (c) 1988 AT&T */
31 /* All Rights Reserved */
33 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
38 #include <sys/feature_tests.h>
41 #include <sys/types.h>
42 #include <sys/unistd.h>
48 /* Symbolic constants for the "access" routine: */
49 #define R_OK 4 /* Test for Read permission */
50 #define W_OK 2 /* Test for Write permission */
51 #define X_OK 1 /* Test for eXecute permission */
52 #define F_OK 0 /* Test for existence of File */
54 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
55 #define F_ULOCK 0 /* Unlock a previously locked region */
56 #define F_LOCK 1 /* Lock a region for exclusive use */
57 #define F_TLOCK 2 /* Test and lock a region for exclusive use */
58 #define F_TEST 3 /* Test a region for other processes locks */
59 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
61 /* Symbolic constants for the "lseek" routine: */
64 #define SEEK_SET 0 /* Set file pointer to "offset" */
68 #define SEEK_CUR 1 /* Set file pointer to current plus "offset" */
72 #define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
75 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
77 #define SEEK_DATA 3 /* Set file pointer to next data past offset */
81 #define SEEK_HOLE 4 /* Set file pointer to next hole past offset */
83 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
85 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
87 #define GF_PATH "/etc/group" /* Path name of the "group" file */
88 #define PF_PATH "/etc/passwd" /* Path name of the "passwd" file */
89 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
92 * compile-time symbolic constants,
93 * Support does not mean the feature is enabled.
94 * Use pathconf/sysconf to obtain actual configuration value.
97 /* Values unchanged in UNIX 03 */
98 #define _POSIX_ASYNC_IO 1
99 #define _POSIX_JOB_CONTROL 1
100 #define _POSIX_SAVED_IDS 1
101 #define _POSIX_SYNC_IO 1
104 * POSIX.1b compile-time symbolic constants.
107 #define _POSIX_ASYNCHRONOUS_IO 200112L
108 #define _POSIX_FSYNC 200112L
109 #define _POSIX_MAPPED_FILES 200112L
110 #define _POSIX_MEMLOCK 200112L
111 #define _POSIX_MEMLOCK_RANGE 200112L
112 #define _POSIX_MEMORY_PROTECTION 200112L
113 #define _POSIX_MESSAGE_PASSING 200112L
114 #define _POSIX_PRIORITY_SCHEDULING 200112L
115 #define _POSIX_REALTIME_SIGNALS 200112L
116 #define _POSIX_SEMAPHORES 200112L
117 #define _POSIX_SHARED_MEMORY_OBJECTS 200112L
118 #define _POSIX_SYNCHRONIZED_IO 200112L
120 #define _POSIX_ASYNCHRONOUS_IO 1
121 #define _POSIX_FSYNC 1
122 #define _POSIX_MAPPED_FILES 1
123 #define _POSIX_MEMLOCK 1
124 #define _POSIX_MEMLOCK_RANGE 1
125 #define _POSIX_MEMORY_PROTECTION 1
126 #define _POSIX_MESSAGE_PASSING 1
127 #define _POSIX_PRIORITY_SCHEDULING 1
128 #define _POSIX_REALTIME_SIGNALS 1
129 #define _POSIX_SEMAPHORES 1
130 #define _POSIX_SHARED_MEMORY_OBJECTS 1
131 #define _POSIX_SYNCHRONIZED_IO 1
135 * POSIX.1c compile-time symbolic constants.
138 #define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
139 #define _POSIX_THREADS 200112L
140 #define _POSIX_THREAD_ATTR_STACKADDR 200112L
141 #define _POSIX_THREAD_ATTR_STACKSIZE 200112L
142 #define _POSIX_THREAD_PROCESS_SHARED 200112L
143 #define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L
144 #define _POSIX_TIMERS 200112L
146 #define _POSIX_THREAD_SAFE_FUNCTIONS 1
147 #define _POSIX_THREADS 1
148 #define _POSIX_THREAD_ATTR_STACKADDR 1
149 #define _POSIX_THREAD_ATTR_STACKSIZE 1
150 #define _POSIX_THREAD_PROCESS_SHARED 1
151 #define _POSIX_THREAD_PRIORITY_SCHEDULING 1
152 #define _POSIX_TIMERS 1
156 #define _POSIX_ADVISORY_INFO 200112L
157 #define _POSIX_BARRIERS 200112L
158 #define _POSIX_CLOCK_SELECTION 200112L
159 #define _POSIX_IPV6 200112L
160 #define _POSIX_MONOTONIC_CLOCK 200112L
161 #define _POSIX_RAW_SOCKETS 200112L
162 #define _POSIX_READER_WRITER_LOCKS 200112L
163 #define _POSIX_SPAWN 200112L
164 #define _POSIX_SPIN_LOCKS 200112L
165 #define _POSIX_TIMEOUTS 200112L
168 * Support for the POSIX.1 mutex protocol attribute. For realtime applications
169 * which need mutexes to support priority inheritance/ceiling.
172 #define _POSIX_THREAD_PRIO_INHERIT 200112L
173 #define _POSIX_THREAD_PRIO_PROTECT 200112L
175 #define _POSIX_THREAD_PRIO_INHERIT 1
176 #define _POSIX_THREAD_PRIO_PROTECT 1
179 #ifndef _POSIX_VDISABLE
180 #define _POSIX_VDISABLE 0
183 #define STDIN_FILENO 0
184 #define STDOUT_FILENO 1
185 #define STDERR_FILENO 2
188 * Large File Summit-related announcement macros. The system supports both
189 * the additional and transitional Large File Summit interfaces. (The final
190 * two macros provide a finer granularity breakdown of _LFS64_LARGEFILE.)
192 #define _LFS_LARGEFILE 1
193 #define _LFS64_LARGEFILE 1
194 #define _LFS64_STDIO 1
195 #define _LFS64_ASYNCHRONOUS_IO 1
197 /* large file compilation environment setup */
198 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
199 #ifdef __PRAGMA_REDEFINE_EXTNAME
200 #pragma redefine_extname ftruncate ftruncate64
201 #pragma redefine_extname lseek lseek64
202 #pragma redefine_extname pread pread64
203 #pragma redefine_extname pwrite pwrite64
204 #pragma redefine_extname truncate truncate64
205 #pragma redefine_extname lockf lockf64
206 #pragma redefine_extname tell tell64
207 #else /* __PRAGMA_REDEFINE_EXTNAME */
208 #define ftruncate ftruncate64
209 #define lseek lseek64
210 #define pread pread64
211 #define pwrite pwrite64
212 #define truncate truncate64
213 #define lockf lockf64
215 #endif /* __PRAGMA_REDEFINE_EXTNAME */
216 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
218 /* In the LP64 compilation environment, the APIs are already large file */
219 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
220 #ifdef __PRAGMA_REDEFINE_EXTNAME
221 #pragma redefine_extname ftruncate64 ftruncate
222 #pragma redefine_extname lseek64 lseek
223 #pragma redefine_extname pread64 pread
224 #pragma redefine_extname pwrite64 pwrite
225 #pragma redefine_extname truncate64 truncate
226 #pragma redefine_extname lockf64 lockf
227 #pragma redefine_extname tell64 tell
228 #else /* __PRAGMA_REDEFINE_EXTNAME */
229 #define ftruncate64 ftruncate
230 #define lseek64 lseek
231 #define pread64 pread
232 #define pwrite64 pwrite
233 #define truncate64 truncate
234 #define lockf64 lockf
236 #endif /* __PRAGMA_REDEFINE_EXTNAME */
237 #endif /* _LP64 && _LARGEFILE64_SOURCE */
239 extern int access(const char *, int);
240 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
241 extern int acct(const char *);
242 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
243 extern unsigned alarm(unsigned);
244 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
245 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
246 defined(__EXTENSIONS__)
247 extern int brk(void *);
248 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */
249 extern int chdir(const char *);
250 extern int chown(const char *, uid_t
, gid_t
);
251 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
252 #if !defined(_POSIX_C_SOURCE) || (defined(_XOPEN_SOURCE) && \
253 !defined(_XPG6)) || defined(__EXTENSIONS__)
254 extern int chroot(const char *);
255 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE))... */
256 extern int close(int);
257 #if defined(_XPG4) || defined(__EXTENSIONS__)
258 extern size_t confstr(int, char *, size_t);
259 extern char *crypt(const char *, const char *);
260 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
261 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
262 defined(__EXTENSIONS__)
263 extern char *ctermid(char *);
264 #endif /* (!defined(_POSIX_C_SOURCE) ... */
265 extern char *ctermid_r(char *);
266 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
267 #if !defined(_XPG6) || defined(__EXTENSIONS__)
268 extern char *cuserid(char *);
271 extern int dup2(int, int);
272 extern int dup3(int, int, int);
273 #if defined(_XPG4) || defined(__EXTENSIONS__)
274 extern void encrypt(char *, int);
275 #endif /* defined(XPG4) || defined(__EXTENSIONS__) */
276 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
277 extern void endusershell(void);
278 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
279 extern int execl(const char *, const char *, ...);
280 extern int execle(const char *, const char *, ...);
281 extern int execlp(const char *, const char *, ...);
282 extern int execv(const char *, char *const *);
283 extern int execve(const char *, char *const *, char *const *);
284 extern int execvp(const char *, char *const *);
285 #if defined(_GNU_SOURCE) || defined(__EXTENSIONS__)
286 extern int execvpe(const char *, char *const *, char *const *);
288 extern void _exit(int)
291 * The following fattach prototype is duplicated in <stropts.h>. The
292 * duplication is necessitated by XPG4.2 which requires the prototype
293 * be defined in <stropts.h>.
295 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
296 extern int fattach(int, const char *);
297 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
298 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
299 extern int fchdir(int);
300 extern int fchown(int, uid_t
, gid_t
);
301 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
302 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
303 extern int fchroot(int);
304 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
305 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \
306 defined(__EXTENSIONS__)
307 extern int fdatasync(int);
308 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
310 * The following fdetach prototype is duplicated in <stropts.h>. The
311 * duplication is necessitated by XPG4.2 which requires the prototype
312 * be defined in <stropts.h>.
314 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
315 extern int fdetach(const char *);
316 #endif /* !defined(__XOPEN_OR_POSIX)... */
317 extern pid_t
fork(void);
318 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
319 extern pid_t
fork1(void);
320 extern pid_t
forkall(void);
321 #endif /* !defined(__XOPEN_OR_POSIX)... */
322 extern long fpathconf(int, int);
323 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \
324 defined(__EXTENSIONS__)
325 extern int fsync(int);
326 #endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */
327 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \
328 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
329 defined(__EXTENSIONS__)
330 extern int ftruncate(int, off_t
);
331 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */
332 extern char *getcwd(char *, size_t);
333 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
334 defined(__EXTENSIONS__)
335 extern int getdtablesize(void);
337 extern gid_t
getegid(void);
338 extern uid_t
geteuid(void);
339 extern gid_t
getgid(void);
340 extern int getgroups(int, gid_t
*);
341 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
342 extern long gethostid(void);
345 extern int gethostname(char *, size_t);
346 #elif !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
347 extern int gethostname(char *, int);
350 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in stdlib.h */
351 #define __GETLOGIN_DEFINED
352 #ifndef __USE_LEGACY_LOGNAME__
353 #ifdef __PRAGMA_REDEFINE_EXTNAME
354 #pragma redefine_extname getlogin getloginx
355 #else /* __PRAGMA_REDEFINE_EXTNAME */
356 extern char *getloginx(void);
357 #define getlogin getloginx
358 #endif /* __PRAGMA_REDEFINE_EXTNAME */
359 #endif /* __USE_LEGACY_LOGNAME__ */
360 extern char *getlogin(void);
361 #endif /* __GETLOGIN_DEFINED */
363 #if defined(_XPG4) || defined(__EXTENSIONS__)
364 extern int getopt(int, char *const *, const char *);
366 extern int opterr
, optind
, optopt
;
367 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
368 #if !defined(_XPG6) || defined(__EXTENSIONS__)
369 extern char *getpass(const char *);
371 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */
372 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
373 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */
374 #if !defined(_XPG6) || defined(__EXTENSIONS__)
375 extern int getpagesize(void);
377 extern pid_t
getpgid(pid_t
);
378 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
379 extern pid_t
getpid(void);
380 extern pid_t
getppid(void);
381 extern pid_t
getpgrp(void);
383 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
384 char *gettxt(const char *, const char *);
385 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
386 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
387 extern pid_t
getsid(pid_t
);
388 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
389 extern uid_t
getuid(void);
390 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
391 extern char *getusershell(void);
392 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
394 * The following ioctl prototype is duplicated in <stropts.h>. The
395 * duplication is necessitated by XPG4.2 which requires the prototype
396 * be defined in <stropts.h>.
398 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
399 extern int ioctl(int, int, ...);
400 extern int isaexec(const char *, char *const *, char *const *);
401 extern int issetugid(void);
403 extern int isatty(int);
404 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
405 extern int lchown(const char *, uid_t
, gid_t
);
407 extern int link(const char *, const char *);
408 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
409 extern offset_t
llseek(int, offset_t
, int);
411 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
412 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
413 defined(__EXTENSIONS__)
414 extern int lockf(int, int, off_t
);
416 extern off_t
lseek(int, off_t
, int);
417 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
418 defined(__EXTENSIONS__)
419 extern int nice(int);
420 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */
421 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
422 extern int mincore(caddr_t
, size_t, char *);
424 extern long pathconf(const char *, int);
425 extern int pause(void);
426 extern int pipe(int *);
427 extern int pipe2(int *, int);
428 #if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \
429 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
430 defined(__EXTENSIONS__)
431 extern ssize_t
pread(int, void *, size_t, off_t
);
433 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
434 extern void profil(unsigned short *, size_t, unsigned long, unsigned int);
437 * pthread_atfork() is also declared in <pthread.h> as per SUSv3. The
438 * declarations are identical. A change to either one may also require
439 * appropriate namespace updates in order to avoid redeclaration
440 * warnings in the case where both prototypes are exposed via inclusion
441 * of both <pthread.h> and <unistd.h>.
443 #if !defined(__XOPEN_OR_POSIX) || \
444 ((_POSIX_C_SOURCE > 2) && !defined(_XPG6)) || \
445 defined(__EXTENSIONS__)
446 extern int pthread_atfork(void (*) (void), void (*) (void), void (*) (void));
447 #endif /* !defined(__XOPEN_OR_POSIX) || ((_POSIX_C_SOURCE > 2) ... */
448 #if !defined(_LP64) && \
449 (!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__))
450 extern int ptrace(int, pid_t
, int, int);
452 #if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \
453 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
454 defined(__EXTENSIONS__)
455 extern ssize_t
pwrite(int, const void *, size_t, off_t
);
457 extern ssize_t
read(int, void *, size_t);
458 #if !defined(__XOPEN_OR_POSIX) || \
459 defined(_XPG4_2) || defined(__EXTENSIONS__)
460 extern ssize_t
readlink(const char *_RESTRICT_KYWD
, char *_RESTRICT_KYWD
,
463 #if (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3) && !defined(_XPG4))) || \
464 defined(__EXTENSIONS__)
465 #if __cplusplus >= 199711L
468 extern int rename(const char *, const char *);
469 #if __cplusplus >= 199711L
470 } /* end of namespace std */
473 #endif /* __cplusplus >= 199711L */
474 #endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */
475 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
476 extern int resolvepath(const char *, char *, size_t);
477 #endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */
478 extern int rmdir(const char *);
480 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \
481 defined(__EXTENSIONS__)
482 extern void *sbrk(intptr_t);
483 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */
484 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__)
485 extern int setegid(gid_t
);
486 extern int seteuid(uid_t
);
487 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */
488 extern int setgid(gid_t
);
489 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
490 extern int setgroups(int, const gid_t
*);
491 extern int sethostname(char *, int);
492 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
493 extern int setpgid(pid_t
, pid_t
);
494 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
495 extern pid_t
setpgrp(void);
496 extern int setregid(gid_t
, gid_t
);
497 extern int setreuid(uid_t
, uid_t
);
498 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
499 extern pid_t
setsid(void);
500 extern int setuid(uid_t
);
501 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
502 extern void setusershell(void);
503 #endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */
504 extern unsigned sleep(unsigned);
505 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
506 extern int stime(const time_t *);
507 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
509 /* __EXTENSIONS__ makes the SVID Third Edition prototype in stdlib.h visible */
510 extern void swab(const void *_RESTRICT_KYWD
, void *_RESTRICT_KYWD
, ssize_t
);
511 #endif /* defined(_XPG4) */
512 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
513 extern int symlink(const char *, const char *);
514 extern void sync(void);
515 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) */
516 #if defined(_XPG5) && !defined(_XPG6)
517 #ifdef __PRAGMA_REDEFINE_EXTNAME
518 #pragma redefine_extname sysconf __sysconf_xpg5
519 #else /* __PRAGMA_REDEFINE_EXTNAME */
520 #define sysconf __sysconf_xpg5
521 #endif /* __PRAGMA_REDEFINE_EXTNAME */
522 #endif /* defined(_XPG5) && !defined(_XPG6) */
523 extern long sysconf(int);
524 extern pid_t
tcgetpgrp(int);
525 extern int tcsetpgrp(int, pid_t
);
526 #if !defined(__XOPEN_OR_POSIX) || \
527 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
528 defined(__EXTENSIONS__)
529 extern off_t
tell(int);
530 #endif /* !defined(__XOPEN_OR_POSIX)... */
531 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
532 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \
533 defined(__EXTENSIONS__)
534 extern int truncate(const char *, off_t
);
535 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
536 extern char *ttyname(int);
537 #if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS)
538 extern useconds_t
ualarm(useconds_t
, useconds_t
);
540 extern int unlink(const char *);
541 #if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS)
542 extern char *getwd(char *);
543 extern int usleep(useconds_t
);
544 extern pid_t
vfork(void) __RETURNS_TWICE
;
545 #pragma unknown_control_flow(vfork)
547 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
548 extern void vhangup(void);
549 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
550 extern ssize_t
write(int, const void *, size_t);
551 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
552 extern void yield(void);
553 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
555 #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \
556 defined(__EXTENSIONS__)
557 /* || defined(_XPG7) */
558 extern int faccessat(int, const char *, int, int);
559 extern int fchownat(int, const char *, uid_t
, gid_t
, int);
560 extern int linkat(int, const char *, int, const char *, int);
561 extern ssize_t
readlinkat(int, const char *_RESTRICT_KYWD
,
562 char *_RESTRICT_KYWD
, size_t);
563 extern int renameat(int, const char *, int, const char *);
564 extern int symlinkat(const char *, int, const char *);
565 extern int unlinkat(int, const char *, int);
566 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */
567 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
568 extern int get_nprocs(void);
569 extern int get_nprocs_conf(void);
570 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
572 /* transitional large file interface versions */
573 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
574 !defined(__PRAGMA_REDEFINE_EXTNAME))
575 extern int ftruncate64(int, off64_t
);
576 extern off64_t
lseek64(int, off64_t
, int);
577 extern ssize_t
pread64(int, void *, size_t, off64_t
);
578 extern ssize_t
pwrite64(int, const void *, size_t, off64_t
);
579 extern off64_t
tell64(int);
580 extern int truncate64(const char *, off64_t
);
581 extern int lockf64(int, int, off64_t
);
582 #endif /* _LARGEFILE64_SOURCE */
585 * getlogin_r() & ttyname_r() prototypes are defined here.
589 * Previous releases of Solaris, starting at 2.3, provided definitions of
590 * various functions as specified in POSIX.1c, Draft 6. For some of these
591 * functions, the final POSIX 1003.1c standard had a different number of
592 * arguments and return values.
594 * The following segment of this header provides support for the standard
595 * interfaces while supporting applications written under earlier
596 * releases. The application defines appropriate values of the feature
597 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate
598 * whether it was written to expect the Draft 6 or standard versions of
599 * these interfaces, before including this header. This header then
600 * provides a mapping from the source version of the interface to an
601 * appropriate binary interface. Such mappings permit an application
602 * to be built from libraries and objects which have mixed expectations
603 * of the definitions of these functions.
605 * For applications using the Draft 6 definitions, the binary symbol is the
606 * same as the source symbol, and no explicit mapping is needed. For the
607 * standard interface, the function func() is mapped to the binary symbol
608 * _posix_func(). The preferred mechanism for the remapping is a compiler
609 * #pragma. If the compiler does not provide such a #pragma, the header file
610 * defines a static function func() which calls the _posix_func() version;
611 * this has to be done instead of #define since POSIX specifies that an
612 * application can #undef the symbol and still be bound to the correct
613 * implementation. Unfortunately, the statics confuse lint so we fallback to
614 * #define in that case.
616 * NOTE: Support for the Draft 6 definitions is provided for compatibility
617 * only. New applications/libraries should use the standard definitions.
620 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS)
622 #ifndef __USE_LEGACY_LOGNAME__
623 #ifdef __PRAGMA_REDEFINE_EXTNAME
624 #pragma redefine_extname getlogin_r __posix_getloginx_r
625 extern int getlogin_r(char *, int);
626 #else /* __PRAGMA_REDEFINE_EXTNAME */
627 extern int __posix_getloginx_r(char *, int);
628 #define getlogin_r __posix_getloginx_r
629 #endif /* __PRAGMA_REDEFINE_EXTNAME */
630 #else /* __USE_LEGACY_LOGNAME__ */
631 #ifdef __PRAGMA_REDEFINE_EXTNAME
632 #pragma redefine_extname getlogin_r __posix_getlogin_r
633 extern int getlogin_r(char *, int);
634 #else /* __PRAGMA_REDEFINE_EXTNAME */
635 extern int __posix_getlogin_r(char *, int);
638 getlogin_r(char *__name
, int __len
)
640 return (__posix_getlogin_r(__name
, __len
));
643 #endif /* __PRAGMA_REDEFINE_EXTNAME */
644 #endif /* __USE_LEGACY_LOGNAME__ */
646 #ifdef __PRAGMA_REDEFINE_EXTNAME
647 #pragma redefine_extname ttyname_r __posix_ttyname_r
648 extern int ttyname_r(int, char *, size_t);
649 #else /* __PRAGMA_REDEFINE_EXTNAME */
650 extern int __posix_ttyname_r(int, char *, size_t);
653 ttyname_r(int __fildes
, char *__buf
, size_t __size
)
655 return (__posix_ttyname_r(__fildes
, __buf
, __size
));
658 #endif /* __PRAGMA_REDEFINE_EXTNAME */
660 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
662 #ifndef __USE_LEGACY_LOGNAME__
663 #ifdef __PRAGMA_REDEFINE_EXTNAME
664 #pragma redefine_extname getlogin_r getloginx_r
665 #else /* __PRAGMA_REDEFINE_EXTNAME */
666 extern char *getloginx_r(char *, int);
667 #define getlogin_r getloginx_r
668 #endif /* __PRAGMA_REDEFINE_EXTNAME */
669 #endif /* __USE_LEGACY_LOGNAME__ */
670 extern char *getlogin_r(char *, int);
672 extern char *ttyname_r(int, char *, int);
674 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */
676 #if !defined(_STRICT_SYMBOLS)
677 extern int getentropy(void *, size_t);
678 #endif /* !_STRICT_SYMBOLS */
684 #endif /* _UNISTD_H */