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 * Copyright 2014 PALO, Richard. 25 * 26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 27 * Use is subject to license terms. 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 #include <sys/null.h> 51 52 #ifdef __cplusplus 53 extern "C" { 54 #endif 55 56 unsigned char __mb_cur_max(void); 57 #ifndef MB_CUR_MAX 58 #define MB_CUR_MAX (__mb_cur_max()) 59 #endif 60 61 #if __cplusplus >= 199711L 62 namespace std { 63 #endif 64 65 typedef struct { 66 int quot; 67 int rem; 68 } div_t; 69 70 typedef struct { 71 long quot; 72 long rem; 73 } ldiv_t; 74 75 #if !defined(_SIZE_T) || __cplusplus >= 199711L 76 #define _SIZE_T 77 #if defined(_LP64) 78 typedef unsigned long size_t; /* size of something in bytes */ 79 #else 80 typedef unsigned int size_t; /* (historical version) */ 81 #endif 82 #endif /* !_SIZE_T */ 83 84 #define EXIT_FAILURE 1 85 #define EXIT_SUCCESS 0 86 #define RAND_MAX 32767 87 88 /* 89 * wchar_t is a built-in type in standard C++ and as such is not 90 * defined here when using standard C++. However, the GNU compiler 91 * fixincludes utility nonetheless creates its own version of this 92 * header for use by gcc and g++. In that version it adds a redundant 93 * guard for __cplusplus. To avoid the creation of a gcc/g++ specific 94 * header we need to include the following magic comment: 95 * 96 * we must use the C++ compiler's type 97 * 98 * The above comment should not be removed or changed until GNU 99 * gcc/fixinc/inclhack.def is updated to bypass this header. 100 */ 101 #if !defined(__cplusplus) || (__cplusplus < 199711L && !defined(__GNUG__)) 102 #ifndef _WCHAR_T 103 #define _WCHAR_T 104 #if defined(_LP64) 105 typedef int wchar_t; 106 #else 107 typedef long wchar_t; 108 #endif 109 #endif /* !_WCHAR_T */ 110 #endif /* !defined(__cplusplus) ... */ 111 112 #if !defined(_NORETURN_KYWD) 113 #if __STDC_VERSION__ - 0 >= 201112L 114 #define _NORETURN_KYWD _Noreturn 115 #else 116 #define _NORETURN_KYWD 117 #endif /* __STDC_VERSION__ - 0 >= 201112L */ 118 #endif /* !defined(_NORETURN_KYWD) */ 119 120 extern _NORETURN_KYWD void abort(void) __NORETURN; 121 extern int abs(int); 122 extern int atexit(void (*)(void)); 123 extern double atof(const char *); 124 extern int atoi(const char *); 125 extern long int atol(const char *); 126 extern void *bsearch(const void *, const void *, size_t, size_t, 127 int (*)(const void *, const void *)); 128 #if __cplusplus >= 199711L && defined(__SUNPRO_CC) 129 extern "C++" { 130 void *bsearch(const void *, const void *, size_t, size_t, 131 int (*)(const void *, const void *)); 132 } 133 #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */ 134 extern void *calloc(size_t, size_t); 135 extern div_t div(int, int); 136 extern _NORETURN_KYWD void exit(int) 137 __NORETURN; 138 extern void free(void *); 139 extern char *getenv(const char *); 140 /* 141 * Duplicated from math_iso.h for C++ abs() inlines below. 142 */ 143 #if __cplusplus >= 199711L 144 extern double fabs(double); 145 extern float fabsf(float); 146 extern long double fabsl(long double); 147 #endif 148 extern long int labs(long); 149 extern ldiv_t ldiv(long, long); 150 extern void *malloc(size_t); 151 extern int mblen(const char *, size_t); 152 extern size_t mbstowcs(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, 153 size_t); 154 extern int mbtowc(wchar_t *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t); 155 extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); 156 #if __cplusplus >= 199711L && defined(__SUNPRO_CC) 157 extern "C++" { 158 void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); 159 } 160 #endif /* __cplusplus >= 199711L && defined(__SUNPRO_CC) */ 161 extern int rand(void); 162 extern void *realloc(void *, size_t); 163 extern void srand(unsigned int); 164 extern double strtod(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD); 165 extern long int strtol(const char *_RESTRICT_KYWD, char **_RESTRICT_KYWD, int); 166 extern unsigned long int strtoul(const char *_RESTRICT_KYWD, 167 char **_RESTRICT_KYWD, int); 168 extern int system(const char *); 169 extern int wctomb(char *, wchar_t); 170 extern size_t wcstombs(char *_RESTRICT_KYWD, const wchar_t *_RESTRICT_KYWD, 171 size_t); 172 173 #if __cplusplus >= 199711L 174 extern "C++" { 175 #undef __X 176 #undef __Y 177 inline long abs(long __X) { return labs(__X); } 178 inline ldiv_t div(long __X, long __Y) { return ldiv(__X, __Y); } 179 /* 180 * For compatibility with GCC and GLIBCXX, let either stdlib.h or math.h 181 * provide both the integer and floating point abs() variants, regardless 182 * which is included first. 183 */ 184 #ifndef _CXX_ABS_FLOAT_DEFINED 185 #define _CXX_ABS_FLOAT_DEFINED 186 inline double abs(double __X) { return fabs(__X); } 187 inline float abs(float __X) { return fabsf(__X); } 188 inline long double abs(long double __X) { return fabsl(__X); } 189 #endif /* !_CXX_ABS_FLOAT_DEFINED */ 190 } /* extern C++ */ 191 #endif /* __cplusplus */ 192 193 #if __cplusplus >= 199711L 194 } 195 #endif /* end of namespace std */ 196 197 #ifdef __cplusplus 198 } 199 #endif 200 201 #endif /* _ISO_STDLIB_ISO_H */ 202