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 2014 Garrett D'Amore <garrett@damore.org>
  24  *
  25  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  */
  28 
  29 /*      Copyright (c) 1988 AT&T     */
  30 /*        All Rights Reserved   */
  31 
  32 
  33 /*
  34  * An application should not include this header directly.  Instead it
  35  * should be included only through the inclusion of other Sun headers.
  36  *
  37  * The contents of this header is limited to identifiers specified in the
  38  * C Standard.  Any new identifiers specified in future amendments to the
  39  * C Standard must be placed in this header.  If these new identifiers
  40  * are required to also be in the C++ Standard "std" namespace, then for
  41  * anything other than macro definitions, corresponding "using" directives
  42  * must also be added to <locale.h>.
  43  */
  44 
  45 #ifndef _ISO_STDLIB_ISO_H
  46 #define _ISO_STDLIB_ISO_H
  47 
  48 #include <sys/feature_tests.h>
  49 
  50 #ifdef  __cplusplus
  51 extern "C" {
  52 #endif
  53 
  54 unsigned char __mb_cur_max(void);
  55 #ifndef MB_CUR_MAX
  56 #define MB_CUR_MAX      (__mb_cur_max())
  57 #endif
  58 
  59 #if __cplusplus >= 199711L
  60 namespace std {
  61 #endif
  62 
  63 typedef struct {
  64         int     quot;
  65         int     rem;
  66 } div_t;
  67 
  68 typedef struct {
  69         long    quot;
  70         long    rem;
  71 } ldiv_t;
  72 
  73 #if !defined(_SIZE_T) || __cplusplus >= 199711L
  74 #define _SIZE_T
  75 #if defined(_LP64) || defined(_I32LPx)
  76 typedef unsigned long   size_t;         /* size of something in bytes */
  77 #else
  78 typedef unsigned int    size_t;         /* (historical version) */
  79 #endif
  80 #endif  /* !_SIZE_T */
  81 
  82 #ifndef NULL
  83 #if defined(_LP64)
  84 #define NULL    0L
  85 #else
  86 #define NULL    0
  87 #endif
  88 #endif
  89 
  90 #define EXIT_FAILURE    1
  91 #define EXIT_SUCCESS    0
  92 #define RAND_MAX        32767
  93 
  94 /*
  95  * wchar_t is a built-in type in standard C++ and as such is not
  96  * defined here when using standard C++. However, the GNU compiler
  97  * fixincludes utility nonetheless creates its own version of this
  98  * header for use by gcc and g++. In that version it adds a redundant
  99  * guard for __cplusplus. To avoid the creation of a gcc/g++ specific
 100  * header we need to include the following magic comment:
 101  *
 102  * we must use the C++ compiler's type
 103  *
 104  * The above comment should not be removed or changed until GNU
 105  * gcc/fixinc/inclhack.def is updated to bypass this header.
 106  */
 107 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__))
 108 #ifndef _WCHAR_T
 109 #define _WCHAR_T
 110 #if defined(_LP64)
 111 typedef int     wchar_t;
 112 #else
 113 typedef long    wchar_t;
 114 #endif
 115 #endif  /* !_WCHAR_T */
 116 #endif  /* !defined(__cplusplus) ... */
 117 
 118 extern void abort(void) __NORETURN;
 119 extern int abs(int);
 120 extern int atexit(void (*)(void));
 121 extern double atof(const char *);
 122 extern int atoi(const char *);
 123 extern long int atol(const char *);
 124 extern void *bsearch(const void *, const void *, size_t, size_t,
 125         int (*)(const void *, const void *));
 126 #if __cplusplus >= 199711L && defined(__SUNPRO_CC)
 127 extern "C++" {
 128         void *bsearch(const void *, const void *, size_t, size_t,
 129                 int (*)(const void *, const void *));
 130 }
 131 #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
 132 extern void *calloc(size_t, size_t);
 133 extern div_t div(int, int);
 134 extern void exit(int)
 135         __NORETURN;
 136 extern void free(void *);
 137 extern char *getenv(const char *);
 138 extern long int labs(long);
 139 extern ldiv_t ldiv(long, long);
 140 extern void *malloc(size_t);
 141 extern int mblen(const char *, size_t);
 142 extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
 143         size_t);
 144 extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
 145 extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
 146 #if __cplusplus >= 199711L && defined(__SUNPRO_CC)
 147 extern "C++" {
 148         void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
 149 }
 150 #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */
 151 extern int rand(void);
 152 extern void *realloc(void *, size_t);
 153 extern void srand(unsigned int);
 154 extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD);
 155 extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int);
 156 extern unsigned long int strtoul(const char *_RESTRICT_KYWD,
 157         char **_RESTRICT_KYWD, int);
 158 extern int system(const char *);
 159 extern int wctomb(char *, wchar_t);
 160 extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD,
 161         size_t);
 162 
 163 #if __cplusplus >= 199711L
 164 extern "C++" {
 165         inline long   abs(long _l) { return labs(_l); }
 166         inline ldiv_t div(long _l1, long _l2) { return ldiv(_l1, _l2); }
 167 }
 168 #endif /* __cplusplus */
 169 
 170 #if __cplusplus >= 199711L
 171 }
 172 #endif /* end of namespace std */
 173 
 174 #ifdef  __cplusplus
 175 }
 176 #endif
 177 
 178 #endif  /* _ISO_STDLIB_ISO_H */