Print this page
first round of POSIX 2008 stuff


   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) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
  29 
  30 /*      Copyright (c) 1988 AT&T     */
  31 /*        All Rights Reserved   */
  32 
  33 #ifndef _STDLIB_H
  34 #define _STDLIB_H
  35 
  36 #include <iso/stdlib_iso.h>
  37 #include <iso/stdlib_c99.h>
  38 
  39 #if defined(__EXTENSIONS__) || defined(_XPG4)
  40 #include <sys/wait.h>
  41 #endif
  42 


  70 using std::rand;
  71 using std::realloc;
  72 using std::srand;
  73 using std::strtod;
  74 using std::strtol;
  75 using std::strtoul;
  76 using std::system;
  77 using std::wcstombs;
  78 using std::wctomb;
  79 #endif
  80 
  81 #ifdef  __cplusplus
  82 extern "C" {
  83 #endif
  84 
  85 #ifndef _UID_T
  86 #define _UID_T
  87 typedef unsigned int    uid_t;          /* UID type             */
  88 #endif  /* !_UID_T */
  89 
  90 #if defined(__STDC__)
  91 
  92 /* large file compilation environment setup */
  93 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
  94 
  95 #ifdef  __PRAGMA_REDEFINE_EXTNAME
  96 #pragma redefine_extname        mkstemp         mkstemp64
  97 #pragma redefine_extname        mkstemps        mkstemps64
  98 #else   /* __PRAGMA_REDEFINE_EXTNAME */
  99 #define mkstemp                 mkstemp64
 100 #define mkstemps                mkstemps64
 101 #endif  /* __PRAGMA_REDEFINE_EXTNAME */
 102 
 103 #endif  /* _FILE_OFFSET_BITS == 64 */
 104 
 105 /* In the LP64 compilation environment, all APIs are already large file */
 106 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
 107 
 108 #ifdef  __PRAGMA_REDEFINE_EXTNAME
 109 #pragma redefine_extname        mkstemp64       mkstemp
 110 #pragma redefine_extname        mkstemps64      mkstemps
 111 #else   /* __PRAGMA_REDEFINE_EXTNAME */


 162 extern void swab(const char *, char *, ssize_t);
 163 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 164 
 165 #if defined(__EXTENSIONS__) || \
 166         !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
 167         (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
 168 extern int      mkstemp(char *);
 169 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 170 extern int      mkstemps(char *, int);
 171 #endif
 172 #endif /* defined(__EXTENSIONS__) ... */
 173 
 174 #if     defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 175             !defined(__PRAGMA_REDEFINE_EXTNAME))
 176 extern int      mkstemp64(char *);
 177 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 178 extern int      mkstemps64(char *, int);
 179 #endif
 180 #endif  /* _LARGEFILE64_SOURCE... */
 181 







 182 #if defined(__EXTENSIONS__) || \
 183         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
 184         defined(_XPG4_2)
 185 extern long a64l(const char *);
 186 extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 187 extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 188 extern char *gcvt(double, int, char *);
 189 extern int getsubopt(char **, char *const *, char **);
 190 extern int  grantpt(int);
 191 extern char *initstate(unsigned, char *, size_t);
 192 extern char *l64a(long);
 193 extern char *mktemp(char *);
 194 extern char *ptsname(int);
 195 extern long random(void);
 196 extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
 197 extern char *setstate(const char *);
 198 extern void srandom(unsigned);
 199 extern int  unlockpt(int);
 200 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
 201 #if !defined(_XPG6) || defined(__EXTENSIONS__)
 202 extern int ttyslot(void);
 203 extern void *valloc(size_t);
 204 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
 205 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
 206 
 207 #if defined(__EXTENSIONS__) || \
 208         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \


 244 extern int getopt(int, char *const *, const char *);
 245 extern char *optarg;
 246 extern int optind, opterr, optopt;
 247 extern char *getpass(const char *);
 248 extern char *getpassphrase(const char *);
 249 extern int getpw(uid_t, char *);
 250 extern int isatty(int);
 251 extern void *memalign(size_t, size_t);
 252 extern char *ttyname(int);
 253 extern char *mkdtemp(char *);
 254 extern const char *getprogname(void);
 255 extern void setprogname(const char *);
 256 
 257 #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE)
 258 extern char *lltostr(long long, char *);
 259 extern char *ulltostr(unsigned long long, char *);
 260 #endif  /* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */
 261 
 262 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 263 
 264 #else /* not __STDC__ */
 265 
 266 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
 267         (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
 268 extern int rand_r();
 269 #endif  /* defined(__EXTENSIONS__) || defined(_REENTRANT) ... */
 270 
 271 extern void _exithandle();
 272 
 273 #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || defined(_XPG4)
 274 extern double drand48();
 275 extern double erand48();
 276 extern long jrand48();
 277 extern void lcong48();
 278 extern long lrand48();
 279 extern long mrand48();
 280 extern long nrand48();
 281 extern unsigned short *seed48();
 282 extern void srand48();
 283 extern int putenv();
 284 extern void setkey();
 285 #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */
 286 
 287 #if (defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE)) && \
 288         (!defined(_XOPEN_SOURCE) || (defined(_XPG3) && !defined(_XPG4)))
 289 extern void swab();
 290 #endif
 291 
 292 #if defined(__EXTENSIONS__) || \
 293         !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
 294         (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
 295 extern int      mkstemp();
 296 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 297 extern int      mkstemps();
 298 #endif
 299 #endif  /* defined(__EXTENSIONS__) ... */
 300 
 301 #if     defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 302             !defined(__PRAGMA_REDEFINE_EXTNAME))
 303 extern int      mkstemp64();
 304 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 305 extern int      mkstemps64();
 306 #endif
 307 #endif  /* _LARGEFILE64_SOURCE... */
 308 
 309 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)
 310 extern long a64l();
 311 extern char *ecvt();
 312 extern char *fcvt();
 313 extern char *gcvt();
 314 extern int getsubopt();
 315 extern int grantpt();
 316 extern char *initstate();
 317 extern char *l64a();
 318 extern char *mktemp();
 319 extern char *ptsname();
 320 extern long random();
 321 extern char *realpath();
 322 extern char *setstate();
 323 extern void srandom();
 324 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
 325 #if !defined(_XPG6) || defined(__EXTENSIONS__)
 326 extern int ttyslot();
 327 extern void *valloc();
 328 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
 329 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
 330 
 331 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || defined(_XPG6)
 332 extern int posix_memalign();
 333 extern int posix_openpt();
 334 extern int setenv();
 335 extern int unsetenv();
 336 #endif
 337 
 338 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
 339 extern char *canonicalize_file_name();
 340 extern int clearenv();
 341 extern void closefrom();
 342 extern int daemon();
 343 extern int dup2();
 344 extern int dup3();
 345 extern int fdwalk();
 346 extern char *qecvt();
 347 extern char *qfcvt();
 348 extern char *qgcvt();
 349 extern char *getcwd();
 350 extern char *getexecname();
 351 
 352 #ifndef __GETLOGIN_DEFINED      /* Avoid duplicate in unistd.h */
 353 #define __GETLOGIN_DEFINED
 354 #ifndef __USE_LEGACY_LOGNAME__
 355 #ifdef  __PRAGMA_REDEFINE_EXTNAME
 356 #pragma redefine_extname getlogin getloginx
 357 #else   /* __PRAGMA_REDEFINE_EXTNAME */
 358 extern char *getloginx();
 359 #define getlogin        getloginx
 360 #endif  /* __PRAGMA_REDEFINE_EXTNAME */
 361 #endif  /* __USE_LEGACY_LOGNAME__ */
 362 extern char *getlogin();
 363 #endif  /* __GETLOGIN_DEFINED */
 364 
 365 extern int getopt();
 366 extern char *optarg;
 367 extern int optind, opterr, optopt;
 368 extern char *getpass();
 369 extern char *getpassphrase();
 370 extern int getpw();
 371 extern int isatty();
 372 extern void *memalign();
 373 extern char *ttyname();
 374 extern char *mkdtemp();
 375 extern char *getprogname();
 376 extern void setprogname();
 377 
 378 #if defined(_LONGLONG_TYPE)
 379 extern char *lltostr();
 380 extern char *ulltostr();
 381 #endif  /* defined(_LONGLONG_TYPE) */
 382 #endif  /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) ... */
 383 
 384 #endif  /* __STDC__ */
 385 
 386 #ifdef  __cplusplus
 387 }
 388 #endif
 389 
 390 #endif  /* _STDLIB_H */


   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 Garrett D'Amore <garrett@damore.org>
  24  * Copyright (c) 2013 Gary Mills
  25  *
  26  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  27  */
  28 
  29 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
  30 
  31 /*      Copyright (c) 1988 AT&T     */
  32 /*        All Rights Reserved   */
  33 
  34 #ifndef _STDLIB_H
  35 #define _STDLIB_H
  36 
  37 #include <iso/stdlib_iso.h>
  38 #include <iso/stdlib_c99.h>
  39 
  40 #if defined(__EXTENSIONS__) || defined(_XPG4)
  41 #include <sys/wait.h>
  42 #endif
  43 


  71 using std::rand;
  72 using std::realloc;
  73 using std::srand;
  74 using std::strtod;
  75 using std::strtol;
  76 using std::strtoul;
  77 using std::system;
  78 using std::wcstombs;
  79 using std::wctomb;
  80 #endif
  81 
  82 #ifdef  __cplusplus
  83 extern "C" {
  84 #endif
  85 
  86 #ifndef _UID_T
  87 #define _UID_T
  88 typedef unsigned int    uid_t;          /* UID type             */
  89 #endif  /* !_UID_T */
  90 


  91 /* large file compilation environment setup */
  92 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
  93 
  94 #ifdef  __PRAGMA_REDEFINE_EXTNAME
  95 #pragma redefine_extname        mkstemp         mkstemp64
  96 #pragma redefine_extname        mkstemps        mkstemps64
  97 #else   /* __PRAGMA_REDEFINE_EXTNAME */
  98 #define mkstemp                 mkstemp64
  99 #define mkstemps                mkstemps64
 100 #endif  /* __PRAGMA_REDEFINE_EXTNAME */
 101 
 102 #endif  /* _FILE_OFFSET_BITS == 64 */
 103 
 104 /* In the LP64 compilation environment, all APIs are already large file */
 105 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
 106 
 107 #ifdef  __PRAGMA_REDEFINE_EXTNAME
 108 #pragma redefine_extname        mkstemp64       mkstemp
 109 #pragma redefine_extname        mkstemps64      mkstemps
 110 #else   /* __PRAGMA_REDEFINE_EXTNAME */


 161 extern void swab(const char *, char *, ssize_t);
 162 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 163 
 164 #if defined(__EXTENSIONS__) || \
 165         !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
 166         (defined(_LARGEFILE_SOURCE) && _FILE_OFFSET_BITS == 64)
 167 extern int      mkstemp(char *);
 168 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 169 extern int      mkstemps(char *, int);
 170 #endif
 171 #endif /* defined(__EXTENSIONS__) ... */
 172 
 173 #if     defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 174             !defined(__PRAGMA_REDEFINE_EXTNAME))
 175 extern int      mkstemp64(char *);
 176 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 177 extern int      mkstemps64(char *, int);
 178 #endif
 179 #endif  /* _LARGEFILE64_SOURCE... */
 180 
 181 /* Added in XPG4.2, obsoleted in Issue 6, removed in Issue 7 */
 182 #if !defined(_STRICT_SYMBOLS) || (defined(_XPG4_2) && !defined(_XPG7))
 183 extern char *ecvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 184 extern char *fcvt(double, int, int *_RESTRICT_KYWD, int *_RESTRICT_KYWD);
 185 extern char *gcvt(double, int, char *);
 186 #endif
 187 
 188 #if defined(__EXTENSIONS__) || \
 189         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
 190         defined(_XPG4_2)
 191 extern long a64l(const char *);



 192 extern int getsubopt(char **, char *const *, char **);
 193 extern int  grantpt(int);
 194 extern char *initstate(unsigned, char *, size_t);
 195 extern char *l64a(long);
 196 extern char *mktemp(char *);
 197 extern char *ptsname(int);
 198 extern long random(void);
 199 extern char *realpath(const char *_RESTRICT_KYWD, char *_RESTRICT_KYWD);
 200 extern char *setstate(const char *);
 201 extern void srandom(unsigned);
 202 extern int  unlockpt(int);
 203 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
 204 #if !defined(_XPG6) || defined(__EXTENSIONS__)
 205 extern int ttyslot(void);
 206 extern void *valloc(size_t);
 207 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
 208 #endif /* defined(__EXTENSIONS__) || ... || defined(_XPG4_2) */
 209 
 210 #if defined(__EXTENSIONS__) || \
 211         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \


 247 extern int getopt(int, char *const *, const char *);
 248 extern char *optarg;
 249 extern int optind, opterr, optopt;
 250 extern char *getpass(const char *);
 251 extern char *getpassphrase(const char *);
 252 extern int getpw(uid_t, char *);
 253 extern int isatty(int);
 254 extern void *memalign(size_t, size_t);
 255 extern char *ttyname(int);
 256 extern char *mkdtemp(char *);
 257 extern const char *getprogname(void);
 258 extern void setprogname(const char *);
 259 
 260 #if !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE)
 261 extern char *lltostr(long long, char *);
 262 extern char *ulltostr(unsigned long long, char *);
 263 #endif  /* !defined(_STRICT_STDC) && defined(_LONGLONG_TYPE) */
 264 
 265 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 266 


























































































































 267 #ifdef  __cplusplus
 268 }
 269 #endif
 270 
 271 #endif  /* _STDLIB_H */