| 1 | /* |
| 2 | * Copyright (c) 2023 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * @APPLE_LICENSE_HEADER_START@ |
| 5 | * |
| 6 | * This file contains Original Code and/or Modifications of Original Code |
| 7 | * as defined in and that are subject to the Apple Public Source License |
| 8 | * Version 2.0 (the 'License'). You may not use this file except in |
| 9 | * compliance with the License. Please obtain a copy of the License at |
| 10 | * http://www.opensource.apple.com/apsl/ and read it before using this |
| 11 | * file. |
| 12 | * |
| 13 | * The Original Code and all software distributed under the License are |
| 14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
| 15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
| 16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
| 18 | * Please see the License for the specific language governing rights and |
| 19 | * limitations under the License. |
| 20 | * |
| 21 | * @APPLE_LICENSE_HEADER_END@ |
| 22 | */ |
| 23 | /*- |
| 24 | * Copyright (c) 1990, 1993 |
| 25 | *	The Regents of the University of California. All rights reserved. |
| 26 | * |
| 27 | * Redistribution and use in source and binary forms, with or without |
| 28 | * modification, are permitted provided that the following conditions |
| 29 | * are met: |
| 30 | * 1. Redistributions of source code must retain the above copyright |
| 31 | * notice, this list of conditions and the following disclaimer. |
| 32 | * 2. Redistributions in binary form must reproduce the above copyright |
| 33 | * notice, this list of conditions and the following disclaimer in the |
| 34 | * documentation and/or other materials provided with the distribution. |
| 35 | * 3. All advertising materials mentioning features or use of this software |
| 36 | * must display the following acknowledgement: |
| 37 | *	This product includes software developed by the University of |
| 38 | *	California, Berkeley and its contributors. |
| 39 | * 4. Neither the name of the University nor the names of its contributors |
| 40 | * may be used to endorse or promote products derived from this software |
| 41 | * without specific prior written permission. |
| 42 | * |
| 43 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 44 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 46 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 49 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 50 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 51 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 52 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 53 | * SUCH DAMAGE. |
| 54 | * |
| 55 | *	@(#)stdlib.h	8.5 (Berkeley) 5/19/95 |
| 56 | */ |
| 57 | |
| 58 | #ifndef _STDLIB_H_ |
| 59 | #define _STDLIB_H_ |
| 60 | |
| 61 | #define _LIBC_COUNT__MB_LEN_MAX	_LIBC_UNSAFE_INDEXABLE |
| 62 | #define _LIBC_COUNT__PATH_MAX	_LIBC_UNSAFE_INDEXABLE |
| 63 | |
| 64 | #include <Availability.h> |
| 65 | #include <sys/cdefs.h> |
| 66 | |
| 67 | #include <_bounds.h> |
| 68 | #include <_types.h> |
| 69 | #if !defined(_ANSI_SOURCE) |
| 70 | #include <sys/wait.h> |
| 71 | #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
| 72 | #include <alloca.h> |
| 73 | #if defined(__LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES) && __has_ptrcheck |
| 74 | |
| 75 | /* required for bounds annotations, but brings in unexpected names and may |
| 76 | * need adoption work from clients */ |
| 77 | #include <limits.h> /* for MB_LEN_MAX */ |
| 78 | #include <sys/syslimits.h> /* for PATH_MAX */ |
| 79 | |
| 80 | #undef _LIBC_COUNT__MB_LEN_MAX |
| 81 | #undef _LIBC_COUNT__PATH_MAX |
| 82 | #define _LIBC_COUNT__MB_LEN_MAX	_LIBC_COUNT(MB_LEN_MAX) |
| 83 | #define _LIBC_COUNT__PATH_MAX	_LIBC_COUNT_OR_NULL(PATH_MAX) |
| 84 | |
| 85 | #endif /* defined(__LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTES) && __has_ptrcheck */ |
| 86 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
| 87 | #endif /* !_ANSI_SOURCE */ |
| 88 | |
| 89 | /* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: |
| 90 | * _GCC_SIZE_T */ |
| 91 | #include <sys/_types/_size_t.h> |
| 92 | |
| 93 | #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
| 94 | #include <sys/_types/_ct_rune_t.h> |
| 95 | #include <sys/_types/_rune_t.h> |
| 96 | #endif	/* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
| 97 | |
| 98 | #include <sys/_types/_wchar_t.h> |
| 99 | |
| 100 | _LIBC_SINGLE_BY_DEFAULT() |
| 101 | |
| 102 | typedef struct { |
| 103 | 	int quot;		/* quotient */ |
| 104 | 	int rem;		/* remainder */ |
| 105 | } div_t; |
| 106 | |
| 107 | typedef struct { |
| 108 | 	long quot;		/* quotient */ |
| 109 | 	long rem;		/* remainder */ |
| 110 | } ldiv_t; |
| 111 | |
| 112 | #if !__DARWIN_NO_LONG_LONG |
| 113 | typedef struct { |
| 114 | 	long long quot; |
| 115 | 	long long rem; |
| 116 | } lldiv_t; |
| 117 | #endif /* !__DARWIN_NO_LONG_LONG */ |
| 118 | |
| 119 | #include <sys/_types/_null.h> |
| 120 | |
| 121 | #define	EXIT_FAILURE	1 |
| 122 | #define	EXIT_SUCCESS	0 |
| 123 | |
| 124 | #define	RAND_MAX	0x7fffffff |
| 125 | |
| 126 | #if __has_feature(modules) |
| 127 | // When clang modules are enabled, there can only be one definition of |
| 128 | // MB_CUR_MAX, and that needs to be the same one used by xlocale.h. |
| 129 | #include <_mb_cur_max.h> |
| 130 | #else /* !__has_feature(modules) */ |
| 131 | #ifndef MB_CUR_MAX |
| 132 | #ifdef _USE_EXTENDED_LOCALES_ |
| 133 | #define	MB_CUR_MAX	(___mb_cur_max()) |
| 134 | #ifndef MB_CUR_MAX_L |
| 135 | #define	MB_CUR_MAX_L(x)	(___mb_cur_max_l(x)) |
| 136 | #endif /* !MB_CUR_MAX_L */ |
| 137 | #else /* !_USE_EXTENDED_LOCALES_ */ |
| 138 | extern int __mb_cur_max; |
| 139 | #define	MB_CUR_MAX	__mb_cur_max |
| 140 | #endif /* _USE_EXTENDED_LOCALES_ */ |
| 141 | #endif /* MB_CUR_MAX */ |
| 142 | #endif /* __has_feature(modules) */ |
| 143 | |
| 144 | #include <malloc/_malloc.h> |
| 145 | #include <_abort.h> |
| 146 | |
| 147 | __BEGIN_DECLS |
| 148 | int	 abs(int) __pure2; |
| 149 | int	 atexit(void (* _Nonnull)(void)); |
| 150 | #if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \ |
| 151 | 	defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
| 152 | int	at_quick_exit(void (*)(void)); |
| 153 | #endif |
| 154 | double	 atof(const char *); |
| 155 | int	 atoi(const char *); |
| 156 | long	 atol(const char *); |
| 157 | #if !__DARWIN_NO_LONG_LONG |
| 158 | long long |
| 159 | 	 atoll(const char *); |
| 160 | #endif /* !__DARWIN_NO_LONG_LONG */ |
| 161 | void	*bsearch(const void *_LIBC_SIZE(__width) __key, const void *_LIBC_SIZE(__width * __nel) __base, size_t __nel, |
| 162 | 	 size_t __width, int (* _Nonnull __compar)(const void *, const void *)); |
| 163 | /* calloc is now declared in _malloc.h */ |
| 164 | div_t	 div(int, int) __pure2; |
| 165 | void	 exit(int) __dead2; |
| 166 | /* free is now declared in _malloc.h */ |
| 167 | char *_LIBC_CSTR	getenv(const char *); |
| 168 | long	 labs(long) __pure2; |
| 169 | ldiv_t	 ldiv(long, long) __pure2; |
| 170 | #if !__DARWIN_NO_LONG_LONG |
| 171 | long long |
| 172 | 	 llabs(long long); |
| 173 | lldiv_t	 lldiv(long long, long long); |
| 174 | #endif /* !__DARWIN_NO_LONG_LONG */ |
| 175 | /* malloc is now declared in _malloc.h */ |
| 176 | int	 mblen(const char *_LIBC_COUNT(__n) __s, size_t __n); |
| 177 | size_t	 mbstowcs(wchar_t * __restrict _LIBC_COUNT(__n), const char * __restrict, size_t __n); |
| 178 | int	 mbtowc(wchar_t * __restrict, const char * __restrict _LIBC_COUNT(__n), size_t __n); |
| 179 | /* posix_memalign is now declared in _malloc.h */ |
| 180 | void	 qsort(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 181 | 	 int (* _Nonnull __compar)(const void *, const void *)); |
| 182 | #if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \ |
| 183 | 	defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
| 184 | void	quick_exit(int) __dead2; |
| 185 | #endif |
| 186 | int	 rand(void) __swift_unavailable("Use arc4random instead."); |
| 187 | /* realloc is now declared in _malloc.h */ |
| 188 | void	 srand(unsigned) __swift_unavailable("Use arc4random instead."); |
| 189 | double	 strtod(const char *, char *_LIBC_CSTR *) __DARWIN_ALIAS(strtod); |
| 190 | float	 strtof(const char *, char *_LIBC_CSTR *) __DARWIN_ALIAS(strtof); |
| 191 | long	 strtol(const char *__str, char *_LIBC_CSTR *__endptr, int __base); |
| 192 | long double |
| 193 | 	 strtold(const char *, char *_LIBC_CSTR *); |
| 194 | #if !__DARWIN_NO_LONG_LONG |
| 195 | long long |
| 196 | 	 strtoll(const char *__str, char *_LIBC_CSTR *__endptr, int __base); |
| 197 | #endif /* !__DARWIN_NO_LONG_LONG */ |
| 198 | unsigned long |
| 199 | 	 strtoul(const char *__str, char *_LIBC_CSTR *__endptr, int __base); |
| 200 | #if !__DARWIN_NO_LONG_LONG |
| 201 | unsigned long long |
| 202 | 	 strtoull(const char *__str, char *_LIBC_CSTR *__endptr, int __base); |
| 203 | #endif /* !__DARWIN_NO_LONG_LONG */ |
| 204 | |
| 205 | __swift_unavailable("Use posix_spawn APIs or NSTask instead. (On iOS, process spawning is unavailable.)") |
| 206 | __API_AVAILABLE(macos(10.0)) __IOS_PROHIBITED |
| 207 | __WATCHOS_PROHIBITED __TVOS_PROHIBITED |
| 208 | int	 system(const char *) __DARWIN_ALIAS_C(system); |
| 209 | |
| 210 | |
| 211 | size_t	 wcstombs(char * __restrict _LIBC_COUNT(__n), const wchar_t * __restrict, size_t __n); |
| 212 | int	 wctomb(char *_LIBC_COUNT__MB_LEN_MAX, wchar_t); |
| 213 | |
| 214 | #ifndef _ANSI_SOURCE |
| 215 | void	_Exit(int) __dead2; |
| 216 | long	 a64l(const char *); |
| 217 | double	 drand48(void); |
| 218 | char *_LIBC_CSTR	ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ |
| 219 | double	 erand48(unsigned short[3]); |
| 220 | char *_LIBC_CSTR	fcvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ |
| 221 | char *_LIBC_CSTR	gcvt(double, int, char *_LIBC_UNSAFE_INDEXABLE) _LIBC_PTRCHECK_REPLACED(snprintf); /* LEGACY */ |
| 222 | int	 getsubopt(char *_LIBC_CSTR *, char *_LIBC_CSTR const *_LIBC_NULL_TERMINATED, char *_LIBC_CSTR *); |
| 223 | int	 grantpt(int); |
| 224 | #if __DARWIN_UNIX03 |
| 225 | char *_LIBC_UNSAFE_INDEXABLE |
| 226 | 		initstate(unsigned, char *_LIBC_COUNT(__size), size_t __size); /* no __DARWIN_ALIAS needed */ |
| 227 | #else /* !__DARWIN_UNIX03 */ |
| 228 | char *_LIBC_UNSAFE_INDEXABLE |
| 229 | 		initstate(unsigned long, char *_LIBC_COUNT(__size), long __size); |
| 230 | #endif /* __DARWIN_UNIX03 */ |
| 231 | long	 jrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead."); |
| 232 | char	*l64a(long); |
| 233 | void	 lcong48(unsigned short[7]); |
| 234 | long	 lrand48(void) __swift_unavailable("Use arc4random instead."); |
| 235 | #if !defined(_POSIX_C_SOURCE) |
| 236 | __deprecated_msg("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of mktemp(3), it is highly recommended that you use mkstemp(3) instead.") |
| 237 | #endif |
| 238 | char *_LIBC_CSTR	mktemp(char *_LIBC_CSTR); |
| 239 | int	 mkstemp(char *_LIBC_CSTR); |
| 240 | long	 mrand48(void) __swift_unavailable("Use arc4random instead."); |
| 241 | long	 nrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead."); |
| 242 | int	 posix_openpt(int); |
| 243 | char *_LIBC_CSTR	ptsname(int); |
| 244 | |
| 245 | #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
| 246 | int ptsname_r(int fildes, char *_LIBC_COUNT(buflen) buffer, size_t buflen) __API_AVAILABLE(macos(10.13.4), ios(11.3), tvos(11.3), watchos(4.3)); |
| 247 | #endif |
| 248 | |
| 249 | int	 putenv(char *_LIBC_CSTR) __DARWIN_ALIAS(putenv); |
| 250 | long	 random(void) __swift_unavailable("Use arc4random instead."); |
| 251 | int	 rand_r(unsigned *) __swift_unavailable("Use arc4random instead."); |
| 252 | #if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH) |
| 253 | char *_LIBC_CSTR	realpath(const char * __restrict, char * __restrict _LIBC_COUNT__PATH_MAX) __DARWIN_EXTSN(realpath); |
| 254 | #else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */ |
| 255 | char *_LIBC_CSTR	realpath(const char * __restrict, char * __restrict _LIBC_COUNT__PATH_MAX) __DARWIN_ALIAS(realpath); |
| 256 | #endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */ |
| 257 | unsigned short *_LIBC_COUNT(3) seed48(unsigned short[3]); |
| 258 | int	 setenv(const char * __name, const char * __value, int __overwrite) __DARWIN_ALIAS(setenv); |
| 259 | #if __DARWIN_UNIX03 |
| 260 | void	 setkey(const char *) __DARWIN_ALIAS(setkey); |
| 261 | #else /* !__DARWIN_UNIX03 */ |
| 262 | int	 setkey(const char *); |
| 263 | #endif /* __DARWIN_UNIX03 */ |
| 264 | char *_LIBC_UNSAFE_INDEXABLE	setstate(const char *_LIBC_UNSAFE_INDEXABLE); |
| 265 | void	 srand48(long); |
| 266 | #if __DARWIN_UNIX03 |
| 267 | void	 srandom(unsigned); |
| 268 | #else /* !__DARWIN_UNIX03 */ |
| 269 | void	 srandom(unsigned long); |
| 270 | #endif /* __DARWIN_UNIX03 */ |
| 271 | int	 unlockpt(int); |
| 272 | #if __DARWIN_UNIX03 |
| 273 | int	 unsetenv(const char *) __DARWIN_ALIAS(unsetenv); |
| 274 | #else /* !__DARWIN_UNIX03 */ |
| 275 | void	 unsetenv(const char *); |
| 276 | #endif /* __DARWIN_UNIX03 */ |
| 277 | #endif	/* !_ANSI_SOURCE */ |
| 278 | __END_DECLS |
| 279 | |
| 280 | #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
| 281 | #include <machine/types.h> |
| 282 | #include <sys/_types/_dev_t.h> |
| 283 | #include <sys/_types/_mode_t.h> |
| 284 | #include <_types/_uint32_t.h> |
| 285 | |
| 286 | __BEGIN_DECLS |
| 287 | uint32_t arc4random(void); |
| 288 | void	 arc4random_addrandom(unsigned char *_LIBC_COUNT(__datlen) /*dat*/, int __datlen) |
| 289 | __OSX_DEPRECATED(10.0, 10.12, "use arc4random_stir") |
| 290 | __IOS_DEPRECATED(2.0, 10.0, "use arc4random_stir") |
| 291 | __TVOS_DEPRECATED(2.0, 10.0, "use arc4random_stir") |
| 292 | __WATCHOS_DEPRECATED(1.0, 3.0, "use arc4random_stir"); |
| 293 | void	 arc4random_buf(void *_LIBC_SIZE(__nbytes) __buf, size_t __nbytes) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); |
| 294 | void	 arc4random_stir(void); |
| 295 | uint32_t |
| 296 | 	 arc4random_uniform(uint32_t __upper_bound) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); |
| 297 | #ifdef __BLOCKS__ |
| 298 | int	 atexit_b(void (^ _Nonnull)(void)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 299 | |
| 300 | #ifdef __BLOCKS__ |
| 301 | #if __has_attribute(noescape) |
| 302 | #define __bsearch_noescape __attribute__((__noescape__)) |
| 303 | #else |
| 304 | #define __bsearch_noescape |
| 305 | #endif |
| 306 | #endif /* __BLOCKS__ */ |
| 307 | void	*bsearch_b(const void *_LIBC_SIZE(__width) __key, const void *_LIBC_SIZE(__width * __nel) __base, size_t __nel, |
| 308 | 	 size_t __width, int (^ _Nonnull __compar)(const void *, const void *) __bsearch_noescape) |
| 309 | 	 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 310 | #endif /* __BLOCKS__ */ |
| 311 | |
| 312 | 	 /* getcap(3) functions */ |
| 313 | char *_LIBC_CSTR	cgetcap(char *_LIBC_CSTR, const char *, int); |
| 314 | int	 cgetclose(void); |
| 315 | int	 cgetent(char *_LIBC_CSTR *, char *_LIBC_CSTR *_LIBC_NULL_TERMINATED, const char *); |
| 316 | int	 cgetfirst(char *_LIBC_CSTR *, char *_LIBC_CSTR *_LIBC_NULL_TERMINATED); |
| 317 | int	 cgetmatch(const char *, const char *); |
| 318 | int	 cgetnext(char *_LIBC_CSTR *, char *_LIBC_CSTR *_LIBC_NULL_TERMINATED); |
| 319 | int	 cgetnum(char *_LIBC_CSTR, const char *, long *); |
| 320 | int	 cgetset(const char *); |
| 321 | int	 cgetstr(char *_LIBC_CSTR, const char *, char *_LIBC_CSTR *); |
| 322 | int	 cgetustr(char *_LIBC_CSTR, const char *, char *_LIBC_CSTR *); |
| 323 | |
| 324 | int	 daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_5, __IPHONE_2_0, __IPHONE_2_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED; |
| 325 | char *_LIBC_CSTR	devname(dev_t, mode_t); |
| 326 | char *_LIBC_CSTR	devname_r(dev_t, mode_t, char *_LIBC_COUNT(len) buf, int len); |
| 327 | char *_LIBC_CSTR	getbsize(int *, long *); |
| 328 | int	 getloadavg(double [_LIBC_COUNT(__nelem)], int __nelem); |
| 329 | const char |
| 330 | 	*getprogname(void); |
| 331 | void	 setprogname(const char *); |
| 332 | |
| 333 | #ifdef __BLOCKS__ |
| 334 | #if __has_attribute(noescape) |
| 335 | #define __sort_noescape __attribute__((__noescape__)) |
| 336 | #else |
| 337 | #define __sort_noescape |
| 338 | #endif |
| 339 | #endif /* __BLOCKS__ */ |
| 340 | |
| 341 | int	 heapsort(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 342 | 	 int (* _Nonnull __compar)(const void *, const void *)); |
| 343 | #ifdef __BLOCKS__ |
| 344 | int	 heapsort_b(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 345 | 	 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) |
| 346 | 	 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 347 | #endif /* __BLOCKS__ */ |
| 348 | int	 mergesort(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 349 | 	 int (* _Nonnull __compar)(const void *, const void *)); |
| 350 | #ifdef __BLOCKS__ |
| 351 | int	 mergesort_b(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 352 | 	 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) |
| 353 | 	 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 354 | #endif /* __BLOCKS__ */ |
| 355 | void	 psort(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 356 | 	 int (* _Nonnull __compar)(const void *, const void *)) |
| 357 | 	 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 358 | #ifdef __BLOCKS__ |
| 359 | void	 psort_b(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 360 | 	 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) |
| 361 | 	 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 362 | #endif /* __BLOCKS__ */ |
| 363 | void	 psort_r(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, void *, |
| 364 | 	 int (* _Nonnull __compar)(void *, const void *, const void *)) |
| 365 | 	 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 366 | #ifdef __BLOCKS__ |
| 367 | void	 qsort_b(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, |
| 368 | 	 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) |
| 369 | 	 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); |
| 370 | #endif /* __BLOCKS__ */ |
| 371 | void	 qsort_r(void *_LIBC_SIZE(__nel * __width) __base, size_t __nel, size_t __width, void *, |
| 372 | 	 int (* _Nonnull __compar)(void *, const void *, const void *)); |
| 373 | int	 radixsort(const unsigned char *_LIBC_UNSAFE_INDEXABLE *_LIBC_COUNT(__nel) __base, int __nel, const unsigned char *_LIBC_COUNT_OR_NULL(256) __table, |
| 374 | 	 unsigned __endbyte); |
| 375 | int	rpmatch(const char *) |
| 376 | 	__API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0), watchos(6.0)); |
| 377 | int	 sradixsort(const unsigned char *_LIBC_UNSAFE_INDEXABLE *_LIBC_COUNT(__nel) __base, int __nel, const unsigned char *_LIBC_COUNT_OR_NULL(256) __table, |
| 378 | 	 unsigned __endbyte); |
| 379 | void	 sranddev(void); |
| 380 | void	 srandomdev(void); |
| 381 | /* reallocf is now declared in _malloc.h */ |
| 382 | long long |
| 383 | 	strtonum(const char *__numstr, long long __minval, long long __maxval, const char *_LIBC_CSTR *__errstrp) |
| 384 | 	__API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)); |
| 385 | #if !__DARWIN_NO_LONG_LONG |
| 386 | long long |
| 387 | 	 strtoq(const char *__str, char *_LIBC_CSTR *__endptr, int __base); |
| 388 | unsigned long long |
| 389 | 	 strtouq(const char *__str, char *_LIBC_CSTR *__endptr, int __base); |
| 390 | #endif /* !__DARWIN_NO_LONG_LONG */ |
| 391 | extern char *_LIBC_CSTR suboptarg;		/* getsubopt(3) external variable */ |
| 392 | /* valloc is now declared in _malloc.h */ |
| 393 | __END_DECLS |
| 394 | #endif	/* !_ANSI_SOURCE && !_POSIX_SOURCE */ |
| 395 | |
| 396 | __BEGIN_DECLS |
| 397 | /* Poison the following routines if -fshort-wchar is set */ |
| 398 | #if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU |
| 399 | #pragma GCC poison mbstowcs mbtowc wcstombs wctomb |
| 400 | #endif |
| 401 | __END_DECLS |
| 402 | |
| 403 | #endif /* _STDLIB_H_ */ |