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