1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright 2013 Garrett D'Amore <garrett@damore.org>
  28  */
  29 
  30 /*      Copyright (c) 1988 AT&T     */
  31 /*        All Rights Reserved   */
  32 
  33 
  34 /*
  35  * An application should not include this header directly.  Instead it
  36  * should be included only through the inclusion of other Sun headers.
  37  *
  38  * The contents of this header is limited to identifiers specified in the
  39  * C Standard.  Any new identifiers specified in future amendments to the
  40  * C Standard must be placed in this header.  If these new identifiers
  41  * are required to also be in the C++ Standard "std" namespace, then for
  42  * anything other than macro definitions, corresponding "using" directives
  43  * must also be added to <locale.h>.
  44  */
  45 
  46 #ifndef _ISO_STDLIB_ISO_H
  47 #define _ISO_STDLIB_ISO_H
  48 
  49 #include <sys/feature_tests.h>
  50 
  51 #ifdef  __cplusplus
  52 extern "C" {
  53 #endif
  54 
  55 #if defined(__STDC__)
  56 unsigned char __mb_cur_max(void);
  57 #else
  58 unsigned char __mb_cur_max();
  59 #endif
  60 #ifndef MB_CUR_MAX
  61 #define MB_CUR_MAX      (__mb_cur_max())
  62 #endif
  63 
  64 #if __cplusplus >= 199711L
  65 namespace std {
  66 #endif
  67 
  68 typedef struct {
  69         int     quot;
  70         int     rem;
  71 } div_t;
  72 
  73 typedef struct {
  74         long    quot;
  75         long    rem;
  76 } ldiv_t;
  77 
  78 #if !defined(_SIZE_T) || __cplusplus >= 199711L
  79 #define _SIZE_T
  80 #if defined(_LP64) || defined(_I32LPx)
  81 typedef unsigned long   size_t;         /* size of something in bytes */
  82 #else
  83 typedef unsigned int    size_t;         /* (historical version) */
  84 #endif
  85 #endif  /* !_SIZE_T */
  86 
  87 #ifndef NULL
  88 #if defined(_LP64)
  89 #define NULL    0L
  90 #else
  91 #define NULL    0
  92 #endif
  93 #endif
  94 
  95 #define EXIT_FAILURE    1
  96 #define EXIT_SUCCESS    0
  97 #define RAND_MAX        32767
  98 
  99 /*
 100  * wchar_t is a built-in type in standard C++ and as such is not
 101  * defined here when using standard C++. However, the GNU compiler
 102  * fixincludes utility nonetheless creates its own version of this
 103  * header for use by gcc and g++. In that version it adds a redundant
 104  * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 105  * header we need to include the following magic comment:
 106  *
 107  * we must use the C++ compiler's type
 108  *
 109  * The above comment should not be removed or changed until GNU
 110  * gcc/fixinc/inclhack.def is updated to bypass this header.
 111  */
 112 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
 113 #ifndef _WCHAR_T
 114 #define _WCHAR_T
 115 #if defined(_LP64)
 116 typedef int     wchar_t;
 117 #else
 118 typedef long    wchar_t;
 119 #endif
 120 #endif  /* !_WCHAR_T */
 121 #endif  /* !defined(__cplusplus) ... */
 122 
 123 #if defined(__STDC__)
 124 
 125 extern void abort(void) __NORETURN;
 126 extern int abs(int);
 127 extern int atexit(void (*)(void));
 128 extern double atof(const char *);
 129 extern int atoi(const char *);
 130 extern long int atol(const char *);
 131 extern void *bsearch(const void *, const void *, size_t, size_t,
 132         int (*)(const void *, const void *));
 133 #if __cplusplus >= 199711L && defined(__SUNPRO_CC)
 134 extern "C++" {
 135         void *bsearch(const void *, const void *, size_t, size_t,
 136                 int (*)(const void *, const void *));
 137 }
 138 #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
 139 extern void *calloc(size_t, size_t);
 140 extern div_t div(int, int);
 141 extern void exit(int)
 142         __NORETURN;
 143 extern void free(void *);
 144 extern char *getenv(const char *);
 145 extern long int labs(long);
 146 extern ldiv_t ldiv(long, long);
 147 extern void *malloc(size_t);
 148 extern int mblen(const char *, size_t);
 149 extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
 150         size_t);
 151 extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
 152 extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
 153 #if __cplusplus >= 199711L && defined(__SUNPRO_CC)
 154 extern "C++" {
 155         void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
 156 }
 157 #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
 158 extern int rand(void);
 159 extern void *realloc(void *, size_t);
 160 extern void srand(unsigned int);
 161 extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
 162 extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int);
 163 extern unsigned long int strtoul(const char *_RESTRICT_KYWD,
 164         char **_RESTRICT_KYWD, int);
 165 extern int system(const char *);
 166 extern int wctomb(char *, wchar_t);
 167 extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
 168         size_t);
 169 
 170 #if __cplusplus >= 199711L
 171 extern "C++" {
 172         inline long   abs(long _l) { return labs(_l); }
 173         inline ldiv_t div(long _l1, long _l2) { return ldiv(_l1, _l2); }
 174 }
 175 #endif /* __cplusplus */
 176 
 177 #else /* not __STDC__ */
 178 
 179 extern void abort();
 180 extern int abs();
 181 extern int atexit();
 182 extern double atof();
 183 extern int atoi();
 184 extern long int atol();
 185 extern void *bsearch();
 186 extern void *calloc();
 187 extern div_t div();
 188 extern void exit();
 189 extern void free();
 190 extern char *getenv();
 191 extern long int labs();
 192 extern ldiv_t ldiv();
 193 extern void *malloc();
 194 extern int mblen();
 195 extern size_t mbstowcs();
 196 extern int mbtowc();
 197 extern void qsort();
 198 extern int rand();
 199 extern void *realloc();
 200 extern void srand();
 201 extern double strtod();
 202 extern long int strtol();
 203 extern unsigned long strtoul();
 204 extern int system();
 205 extern int wctomb();
 206 extern size_t wcstombs();
 207 
 208 #endif  /* __STDC__ */
 209 
 210 #if __cplusplus >= 199711L
 211 }
 212 #endif /* end of namespace std */
 213 
 214 #ifdef  __cplusplus
 215 }
 216 #endif
 217 
 218 #endif  /* _ISO_STDLIB_ISO_H */