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 2014 PALO, Richard. 24 * Copyright 2014 Garrett D'Amore <garrett@damore.org> 25 * Copyright (c) 2013 Gary Mills 26 * 27 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. 28 */ 29 30 /* Copyright (c) 1988 AT&T */ 31 /* All Rights Reserved */ 32 33 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */ 34 35 #ifndef _UNISTD_H 36 #define _UNISTD_H 37 38 #include <sys/feature_tests.h> 39 40 #include <sys/null.h> 41 #include <sys/types.h> 42 #include <sys/unistd.h> 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 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 */ 53 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)... */ 60 61 /* Symbolic constants for the "lseek" routine: */ 62 63 #ifndef SEEK_SET 64 #define SEEK_SET 0 /* Set file pointer to "offset" */ 65 #endif 66 67 #ifndef SEEK_CUR 68 #define SEEK_CUR 1 /* Set file pointer to current plus "offset" */ 69 #endif 70 71 #ifndef SEEK_END 72 #define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ 73 #endif 74 75 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 76 #ifndef SEEK_DATA 77 #define SEEK_DATA 3 /* Set file pointer to next data past offset */ 78 #endif 79 80 #ifndef SEEK_HOLE 81 #define SEEK_HOLE 4 /* Set file pointer to next hole past offset */ 82 #endif 83 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 84 85 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 86 /* Path names: */ 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__) */ 90 91 /* 92 * compile-time symbolic constants, 93 * Support does not mean the feature is enabled. 94 * Use pathconf/sysconf to obtain actual configuration value. 95 */ 96 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 102 103 /* 104 * POSIX.1b compile-time symbolic constants. 105 */ 106 #if defined(_XPG6) 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 119 #else 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 132 #endif 133 134 /* 135 * POSIX.1c compile-time symbolic constants. 136 */ 137 #if defined(_XPG6) 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 145 #else 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 153 #endif 154 155 /* New in UNIX 03 */ 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 166 167 /* 168 * Support for the POSIX.1 mutex protocol attribute. For realtime applications 169 * which need mutexes to support priority inheritance/ceiling. 170 */ 171 #if defined(_XPG6) 172 #define _POSIX_THREAD_PRIO_INHERIT 200112L 173 #define _POSIX_THREAD_PRIO_PROTECT 200112L 174 #else 175 #define _POSIX_THREAD_PRIO_INHERIT 1 176 #define _POSIX_THREAD_PRIO_PROTECT 1 177 #endif 178 179 #ifndef _POSIX_VDISABLE 180 #define _POSIX_VDISABLE 0 181 #endif 182 183 #define STDIN_FILENO 0 184 #define STDOUT_FILENO 1 185 #define STDERR_FILENO 2 186 187 /* 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.) 191 */ 192 #define _LFS_LARGEFILE 1 193 #define _LFS64_LARGEFILE 1 194 #define _LFS64_STDIO 1 195 #define _LFS64_ASYNCHRONOUS_IO 1 196 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 214 #define tell tell64 215 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 216 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ 217 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 235 #define tell64 tell 236 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 237 #endif /* _LP64 && _LARGEFILE64_SOURCE */ 238 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 #if !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) || defined(__EXTENSIONS__) 266 extern char *ctermid_r(char *); 267 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_REENTRANT) ... */ 268 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */ 269 #if !defined(_XPG6) || defined(__EXTENSIONS__) 270 extern char *cuserid(char *); 271 #endif 272 extern int dup(int); 273 extern int dup2(int, int); 274 extern int dup3(int, int, int); 275 #if defined(_XPG4) || defined(__EXTENSIONS__) 276 extern void encrypt(char *, int); 277 #endif /* defined(XPG4) || defined(__EXTENSIONS__) */ 278 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 279 extern void endusershell(void); 280 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 281 extern int execl(const char *, const char *, ...); 282 extern int execle(const char *, const char *, ...); 283 extern int execlp(const char *, const char *, ...); 284 extern int execv(const char *, char *const *); 285 extern int execve(const char *, char *const *, char *const *); 286 extern int execvp(const char *, char *const *); 287 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS) 288 extern int fexecve(int, char *const[], char *const[]); 289 #endif 290 #if !defined(_STRICT_SYMBOLS) 291 extern int execvpe(const char *, char *const [], char *const []); 292 extern int syncfs(int); 293 #endif /* !_STRICT_SYMBOLS */ 294 extern void _exit(int) 295 __NORETURN; 296 /* 297 * The following fattach prototype is duplicated in <stropts.h>. The 298 * duplication is necessitated by XPG4.2 which requires the prototype 299 * be defined in <stropts.h>. 300 */ 301 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 302 extern int fattach(int, const char *); 303 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 304 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 305 extern int fchdir(int); 306 extern int fchown(int, uid_t, gid_t); 307 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ 308 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 309 extern int fchroot(int); 310 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 311 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || \ 312 defined(__EXTENSIONS__) 313 extern int fdatasync(int); 314 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */ 315 /* 316 * The following fdetach prototype is duplicated in <stropts.h>. The 317 * duplication is necessitated by XPG4.2 which requires the prototype 318 * be defined in <stropts.h>. 319 */ 320 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 321 extern int fdetach(const char *); 322 #endif /* !defined(__XOPEN_OR_POSIX)... */ 323 extern pid_t fork(void); 324 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 325 extern pid_t fork1(void); 326 extern pid_t forkall(void); 327 #endif /* !defined(__XOPEN_OR_POSIX)... */ 328 extern long fpathconf(int, int); 329 #if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2) || \ 330 defined(__EXTENSIONS__) 331 extern int fsync(int); 332 #endif /* !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE > 2)... */ 333 #if !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2) || defined(_XPG4_2) || \ 334 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ 335 defined(__EXTENSIONS__) 336 extern int ftruncate(int, off_t); 337 #endif /* !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE > 2)... */ 338 extern char *getcwd(char *, size_t); 339 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \ 340 defined(__EXTENSIONS__) 341 extern int getdtablesize(void); 342 #endif 343 extern gid_t getegid(void); 344 extern uid_t geteuid(void); 345 extern gid_t getgid(void); 346 extern int getgroups(int, gid_t *); 347 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 348 extern long gethostid(void); 349 #endif 350 #if defined(_XPG4_2) 351 extern int gethostname(char *, size_t); 352 #elif !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 353 extern int gethostname(char *, int); 354 #endif 355 356 #ifndef __GETLOGIN_DEFINED /* Avoid duplicate in stdlib.h */ 357 #define __GETLOGIN_DEFINED 358 #ifndef __USE_LEGACY_LOGNAME__ 359 #ifdef __PRAGMA_REDEFINE_EXTNAME 360 #pragma redefine_extname getlogin getloginx 361 #else /* __PRAGMA_REDEFINE_EXTNAME */ 362 extern char *getloginx(void); 363 #define getlogin getloginx 364 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 365 #endif /* __USE_LEGACY_LOGNAME__ */ 366 extern char *getlogin(void); 367 #endif /* __GETLOGIN_DEFINED */ 368 369 #if defined(_XPG4) || defined(__EXTENSIONS__) 370 extern int getopt(int, char *const *, const char *); 371 extern char *optarg; 372 extern int opterr, optind, optopt; 373 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */ 374 #if !defined(_XPG6) || defined(__EXTENSIONS__) 375 extern char *getpass(const char *); 376 #endif 377 #endif /* defined(_XPG4) || defined(__EXTENSIONS__) */ 378 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 379 /* Marked as LEGACY in SUSv2 and removed in SUSv3 */ 380 #if !defined(_XPG6) || defined(__EXTENSIONS__) 381 extern int getpagesize(void); 382 #endif 383 extern pid_t getpgid(pid_t); 384 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ 385 extern pid_t getpid(void); 386 extern pid_t getppid(void); 387 extern pid_t getpgrp(void); 388 389 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 390 char *gettxt(const char *, const char *); 391 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 392 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 393 extern pid_t getsid(pid_t); 394 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ 395 extern uid_t getuid(void); 396 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 397 extern char *getusershell(void); 398 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 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>. ioctl() is also duplicated in <sys/ioctl.h> 403 * for broader portability aid. 404 */ 405 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 406 extern int ioctl(int, int, ...); 407 extern int isaexec(const char *, char *const *, char *const *); 408 extern int issetugid(void); 409 #endif 410 extern int isatty(int); 411 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 412 extern int lchown(const char *, uid_t, gid_t); 413 #endif 414 extern int link(const char *, const char *); 415 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 416 extern offset_t llseek(int, offset_t, int); 417 #endif 418 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ 419 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ 420 defined(__EXTENSIONS__) 421 extern int lockf(int, int, off_t); 422 #endif 423 extern off_t lseek(int, off_t, int); 424 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ 425 defined(__EXTENSIONS__) 426 extern int nice(int); 427 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)... */ 428 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 429 extern int mincore(caddr_t, size_t, char *); 430 #endif 431 extern long pathconf(const char *, int); 432 extern int pause(void); 433 extern int pipe(int *); 434 extern int pipe2(int *, int); 435 #if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \ 436 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ 437 defined(__EXTENSIONS__) 438 extern ssize_t pread(int, void *, size_t, off_t); 439 #endif 440 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 441 extern void profil(unsigned short *, size_t, unsigned long, unsigned int); 442 #endif 443 /* 444 * pthread_atfork() is also declared in <pthread.h> as per SUSv3. The 445 * declarations are identical. A change to either one may also require 446 * appropriate namespace updates in order to avoid redeclaration 447 * warnings in the case where both prototypes are exposed via inclusion 448 * of both <pthread.h> and <unistd.h>. 449 */ 450 #if !defined(__XOPEN_OR_POSIX) || \ 451 ((_POSIX_C_SOURCE > 2) && !defined(_XPG6)) || \ 452 defined(__EXTENSIONS__) 453 extern int pthread_atfork(void (*) (void), void (*) (void), void (*) (void)); 454 #endif /* !defined(__XOPEN_OR_POSIX) || ((_POSIX_C_SOURCE > 2) ... */ 455 #if !defined(_LP64) && \ 456 (!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)) 457 extern int ptrace(int, pid_t, int, int); 458 #endif 459 #if !defined(_POSIX_C_SOURCE) || defined(_XPG5) || \ 460 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ 461 defined(__EXTENSIONS__) 462 extern ssize_t pwrite(int, const void *, size_t, off_t); 463 #endif 464 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 465 /* per RFC 3542; This is also defined in netdb.h */ 466 extern int rcmd_af(char **, unsigned short, const char *, const char *, 467 const char *, int *, int); 468 #endif 469 extern ssize_t read(int, void *, size_t); 470 #if !defined(__XOPEN_OR_POSIX) || \ 471 defined(_XPG4_2) || defined(__EXTENSIONS__) 472 extern ssize_t readlink(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD, 473 size_t); 474 #endif 475 #if (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3) && !defined(_XPG4))) || \ 476 defined(__EXTENSIONS__) 477 #if __cplusplus >= 199711L 478 namespace std { 479 #endif 480 extern int rename(const char *, const char *); 481 #if __cplusplus >= 199711L 482 } /* end of namespace std */ 483 484 using std::rename; 485 #endif /* __cplusplus >= 199711L */ 486 #endif /* (!defined(__XOPEN_OR_POSIX) || (defined(_XPG3)... */ 487 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 488 extern int resolvepath(const char *, char *, size_t); 489 /* per RFC 3542; This is also defined in netdb.h */ 490 extern int rexec_af(char **, unsigned short, const char *, const char *, 491 const char *, int *, int); 492 #endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */ 493 extern int rmdir(const char *); 494 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 495 /* per RFC 3542; This is also defined in netdb.h */ 496 extern int rresvport_af(int *, int); 497 #endif 498 499 #if !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2) && !defined(_XPG6)) || \ 500 defined(__EXTENSIONS__) 501 extern void *sbrk(intptr_t); 502 #endif /* !defined(__XOPEN_OR_POSIX) || (defined(_XPG4_2)... */ 503 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG6) || defined(__EXTENSIONS__) 504 extern int setegid(gid_t); 505 extern int seteuid(uid_t); 506 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG6) ... */ 507 extern int setgid(gid_t); 508 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 509 extern int setgroups(int, const gid_t *); 510 extern int sethostname(char *, int); 511 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 512 extern int setpgid(pid_t, pid_t); 513 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 514 extern pid_t setpgrp(void); 515 extern int setregid(gid_t, gid_t); 516 extern int setreuid(uid_t, uid_t); 517 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ 518 extern pid_t setsid(void); 519 extern int setuid(uid_t); 520 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 521 extern void setusershell(void); 522 #endif /* !defined(__XOPEN_OR_POSIX)|| defined(__EXTENSIONS__) */ 523 extern unsigned sleep(unsigned); 524 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 525 extern int stime(const time_t *); 526 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 527 #if defined(_XPG4) 528 /* __EXTENSIONS__ makes the SVID Third Edition prototype in stdlib.h visible */ 529 extern void swab(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, ssize_t); 530 #endif /* defined(_XPG4) */ 531 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__) 532 extern int symlink(const char *, const char *); 533 extern void sync(void); 534 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) */ 535 #if defined(_XPG5) && !defined(_XPG6) 536 #ifdef __PRAGMA_REDEFINE_EXTNAME 537 #pragma redefine_extname sysconf __sysconf_xpg5 538 #else /* __PRAGMA_REDEFINE_EXTNAME */ 539 #define sysconf __sysconf_xpg5 540 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 541 #endif /* defined(_XPG5) && !defined(_XPG6) */ 542 extern long sysconf(int); 543 extern pid_t tcgetpgrp(int); 544 extern int tcsetpgrp(int, pid_t); 545 #if !defined(__XOPEN_OR_POSIX) || \ 546 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ 547 defined(__EXTENSIONS__) 548 extern off_t tell(int); 549 #endif /* !defined(__XOPEN_OR_POSIX)... */ 550 #if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \ 551 (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64) || \ 552 defined(__EXTENSIONS__) 553 extern int truncate(const char *, off_t); 554 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */ 555 extern char *ttyname(int); 556 #if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS) 557 extern useconds_t ualarm(useconds_t, useconds_t); 558 #endif 559 extern int unlink(const char *); 560 #if (defined(_XPG4_2) && !defined(_XPG7)) || !defined(_STRICT_SYMBOLS) 561 extern char *getwd(char *); 562 extern int usleep(useconds_t); 563 extern pid_t vfork(void) __RETURNS_TWICE; 564 #pragma unknown_control_flow(vfork) 565 #endif 566 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 567 extern void vhangup(void); 568 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 569 extern ssize_t write(int, const void *, size_t); 570 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 571 extern void yield(void); 572 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 573 574 #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \ 575 defined(__EXTENSIONS__) 576 /* || defined(_XPG7) */ 577 extern int faccessat(int, const char *, int, int); 578 extern int fchownat(int, const char *, uid_t, gid_t, int); 579 extern int linkat(int, const char *, int, const char *, int); 580 extern ssize_t readlinkat(int, const char *_RESTRICT_KYWD, 581 char *_RESTRICT_KYWD, size_t); 582 extern int renameat(int, const char *, int, const char *); 583 extern int symlinkat(const char *, int, const char *); 584 extern int unlinkat(int, const char *, int); 585 #endif /* !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE)... */ 586 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 587 extern int get_nprocs(void); 588 extern int get_nprocs_conf(void); 589 #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 590 591 /* transitional large file interface versions */ 592 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 593 !defined(__PRAGMA_REDEFINE_EXTNAME)) 594 extern int ftruncate64(int, off64_t); 595 extern off64_t lseek64(int, off64_t, int); 596 extern ssize_t pread64(int, void *, size_t, off64_t); 597 extern ssize_t pwrite64(int, const void *, size_t, off64_t); 598 extern off64_t tell64(int); 599 extern int truncate64(const char *, off64_t); 600 extern int lockf64(int, int, off64_t); 601 #endif /* _LARGEFILE64_SOURCE */ 602 603 /* 604 * getlogin_r() & ttyname_r() prototypes are defined here. 605 */ 606 607 /* 608 * Previous releases of Solaris, starting at 2.3, provided definitions of 609 * various functions as specified in POSIX.1c, Draft 6. For some of these 610 * functions, the final POSIX 1003.1c standard had a different number of 611 * arguments and return values. 612 * 613 * The following segment of this header provides support for the standard 614 * interfaces while supporting applications written under earlier 615 * releases. The application defines appropriate values of the feature 616 * test macros _POSIX_C_SOURCE and _POSIX_PTHREAD_SEMANTICS to indicate 617 * whether it was written to expect the Draft 6 or standard versions of 618 * these interfaces, before including this header. This header then 619 * provides a mapping from the source version of the interface to an 620 * appropriate binary interface. Such mappings permit an application 621 * to be built from libraries and objects which have mixed expectations 622 * of the definitions of these functions. 623 * 624 * For applications using the Draft 6 definitions, the binary symbol is the 625 * same as the source symbol, and no explicit mapping is needed. For the 626 * standard interface, the function func() is mapped to the binary symbol 627 * _posix_func(). The preferred mechanism for the remapping is a compiler 628 * #pragma. If the compiler does not provide such a #pragma, the header file 629 * defines a static function func() which calls the _posix_func() version; 630 * this has to be done instead of #define since POSIX specifies that an 631 * application can #undef the symbol and still be bound to the correct 632 * implementation. Unfortunately, the statics confuse lint so we fallback to 633 * #define in that case. 634 * 635 * NOTE: Support for the Draft 6 definitions is provided for compatibility 636 * only. New applications/libraries should use the standard definitions. 637 */ 638 639 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \ 640 !defined(__XOPEN_OR_POSIX) || (_POSIX_C_SOURCE - 0 >= 199506L) || \ 641 defined(_POSIX_PTHREAD_SEMANTICS) 642 643 #if (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_POSIX_PTHREAD_SEMANTICS) 644 645 #ifndef __USE_LEGACY_LOGNAME__ 646 #ifdef __PRAGMA_REDEFINE_EXTNAME 647 #pragma redefine_extname getlogin_r __posix_getloginx_r 648 extern int getlogin_r(char *, int); 649 #else /* __PRAGMA_REDEFINE_EXTNAME */ 650 extern int __posix_getloginx_r(char *, int); 651 #define getlogin_r __posix_getloginx_r 652 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 653 #else /* __USE_LEGACY_LOGNAME__ */ 654 #ifdef __PRAGMA_REDEFINE_EXTNAME 655 #pragma redefine_extname getlogin_r __posix_getlogin_r 656 extern int getlogin_r(char *, int); 657 #else /* __PRAGMA_REDEFINE_EXTNAME */ 658 extern int __posix_getlogin_r(char *, int); 659 660 #ifdef __lint 661 662 #define getlogin_r __posix_getlogin_r 663 664 #else /* !__lint */ 665 666 static int 667 getlogin_r(char *__name, int __len) 668 { 669 return (__posix_getlogin_r(__name, __len)); 670 } 671 672 #endif /* !__lint */ 673 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 674 #endif /* __USE_LEGACY_LOGNAME__ */ 675 676 #ifdef __PRAGMA_REDEFINE_EXTNAME 677 #pragma redefine_extname ttyname_r __posix_ttyname_r 678 extern int ttyname_r(int, char *, size_t); 679 #else /* __PRAGMA_REDEFINE_EXTNAME */ 680 extern int __posix_ttyname_r(int, char *, size_t); 681 682 #ifdef __lint 683 684 #define ttyname_r __posix_ttyname_r 685 686 #else /* !__lint */ 687 688 static int 689 ttyname_r(int __fildes, char *__buf, size_t __size) 690 { 691 return (__posix_ttyname_r(__fildes, __buf, __size)); 692 } 693 694 #endif /* !__lint */ 695 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 696 697 #else /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ 698 699 #ifndef __USE_LEGACY_LOGNAME__ 700 #ifdef __PRAGMA_REDEFINE_EXTNAME 701 #pragma redefine_extname getlogin_r getloginx_r 702 #else /* __PRAGMA_REDEFINE_EXTNAME */ 703 extern char *getloginx_r(char *, int); 704 #define getlogin_r getloginx_r 705 #endif /* __PRAGMA_REDEFINE_EXTNAME */ 706 #endif /* __USE_LEGACY_LOGNAME__ */ 707 extern char *getlogin_r(char *, int); 708 709 extern char *ttyname_r(int, char *, int); 710 711 #endif /* (_POSIX_C_SOURCE - 0 >= 199506L) || ... */ 712 713 #endif /* defined(__EXTENSIONS__) || defined(_REENTRANT)... */ 714 715 #if !defined(_STRICT_SYMBOLS) 716 extern int getentropy(void *, size_t); 717 #endif /* !_STRICT_SYMBOLS */ 718 719 #ifdef __cplusplus 720 } 721 #endif 722 723 #endif /* _UNISTD_H */ 724