]> git.saurik.com Git - apple/libc.git/blame - include/stdlib.h
Libc-1439.40.11.tar.gz
[apple/libc.git] / include / stdlib.h
CommitLineData
5b2abdfb 1/*
b5d655f7 2 * Copyright (c) 2000, 2002 - 2008 Apple Inc. All rights reserved.
5b2abdfb
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
734aad71
A
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
5b2abdfb
A
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
734aad71
A
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.
5b2abdfb
A
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
b5d655f7 61#include <Availability.h>
70ad1dc8 62#include <sys/cdefs.h>
224c7076 63
3d9156a7
A
64#include <_types.h>
65#if !defined(_ANSI_SOURCE)
507116e3 66#ifndef UNIFDEF_DRIVERKIT
3d9156a7 67#include <sys/wait.h>
507116e3 68#endif /* UNIFDEF_DRIVERKIT */
224c7076 69#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
9385eb3d 70#include <alloca.h>
224c7076 71#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
3d9156a7 72#endif /* !_ANSI_SOURCE */
5b2abdfb 73
3d9156a7
A
74/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
75 * _GCC_SIZE_T */
6465356a 76#include <sys/_types/_size_t.h>
5b2abdfb 77
224c7076 78#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
6465356a
A
79#include <sys/_types/_ct_rune_t.h>
80#include <sys/_types/_rune_t.h>
224c7076 81#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
5b2abdfb 82
6465356a 83#include <sys/_types/_wchar_t.h>
9385eb3d 84
5b2abdfb
A
85typedef struct {
86 int quot; /* quotient */
87 int rem; /* remainder */
88} div_t;
89
90typedef struct {
91 long quot; /* quotient */
92 long rem; /* remainder */
93} ldiv_t;
94
3d9156a7
A
95#if !__DARWIN_NO_LONG_LONG
96typedef struct {
97 long long quot;
98 long long rem;
99} lldiv_t;
100#endif /* !__DARWIN_NO_LONG_LONG */
101
6465356a 102#include <sys/_types/_null.h>
5b2abdfb 103
507116e3 104#ifndef UNIFDEF_DRIVERKIT
5b2abdfb
A
105#define EXIT_FAILURE 1
106#define EXIT_SUCCESS 0
507116e3 107#endif /* UNIFDEF_DRIVERKIT */
5b2abdfb
A
108
109#define RAND_MAX 0x7fffffff
110
3d9156a7
A
111#ifdef _USE_EXTENDED_LOCALES_
112#include <_xlocale.h>
113#endif /* _USE_EXTENDED_LOCALES_ */
114
115#ifndef MB_CUR_MAX
116#ifdef _USE_EXTENDED_LOCALES_
117#define MB_CUR_MAX (___mb_cur_max())
118#ifndef MB_CUR_MAX_L
119#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
120#endif /* !MB_CUR_MAX_L */
121#else /* !_USE_EXTENDED_LOCALES_ */
5b2abdfb
A
122extern int __mb_cur_max;
123#define MB_CUR_MAX __mb_cur_max
3d9156a7
A
124#endif /* _USE_EXTENDED_LOCALES_ */
125#endif /* MB_CUR_MAX */
5b2abdfb 126
224c7076 127#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) \
3d9156a7
A
128 && defined(_USE_EXTENDED_LOCALES_) && !defined(MB_CUR_MAX_L)
129#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
130#endif
34e8f829 131//Begin-Libc
5f125488 132#include "libc_private.h"
34e8f829
A
133/* f must be a literal string */
134#define LIBC_ABORT(f,...) abort_report_np("%s:%s:%u: " f, __FILE__, __func__, __LINE__, ## __VA_ARGS__)
135//End-Libc
5b2abdfb 136
507116e3 137#ifndef UNIFDEF_DRIVERKIT
70ad1dc8 138#include <malloc/_malloc.h>
507116e3 139#endif /* UNIFDEF_DRIVERKIT */
b061a43b 140
5b2abdfb 141__BEGIN_DECLS
507116e3 142void abort(void) __cold __dead2;
9385eb3d 143int abs(int) __pure2;
507116e3 144#ifndef UNIFDEF_DRIVERKIT
974e3884 145int atexit(void (* _Nonnull)(void));
507116e3 146#endif /* UNIFDEF_DRIVERKIT */
9385eb3d
A
147double atof(const char *);
148int atoi(const char *);
149long atol(const char *);
3d9156a7
A
150#if !__DARWIN_NO_LONG_LONG
151long long
152 atoll(const char *);
153#endif /* !__DARWIN_NO_LONG_LONG */
974e3884
A
154void *bsearch(const void *__key, const void *__base, size_t __nel,
155 size_t __width, int (* _Nonnull __compar)(const void *, const void *));
507116e3 156#ifndef UNIFDEF_DRIVERKIT
70ad1dc8 157/* calloc is now declared in _malloc.h */
507116e3 158#endif /* UNIFDEF_DRIVERKIT */
9385eb3d 159div_t div(int, int) __pure2;
507116e3 160#ifndef UNIFDEF_DRIVERKIT
9385eb3d 161void exit(int) __dead2;
70ad1dc8 162/* free is now declared in _malloc.h */
9385eb3d 163char *getenv(const char *);
507116e3 164#endif /* UNIFDEF_DRIVERKIT */
9385eb3d
A
165long labs(long) __pure2;
166ldiv_t ldiv(long, long) __pure2;
3d9156a7
A
167#if !__DARWIN_NO_LONG_LONG
168long long
169 llabs(long long);
170lldiv_t lldiv(long long, long long);
171#endif /* !__DARWIN_NO_LONG_LONG */
507116e3 172#ifndef UNIFDEF_DRIVERKIT
70ad1dc8 173/* malloc is now declared in _malloc.h */
507116e3 174#endif /* UNIFDEF_DRIVERKIT */
974e3884 175int mblen(const char *__s, size_t __n);
9385eb3d
A
176size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
177int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
507116e3 178#ifndef UNIFDEF_DRIVERKIT
70ad1dc8 179/* posix_memalign is now declared in _malloc.h */
507116e3 180#endif /* UNIFDEF_DRIVERKIT */
974e3884
A
181void qsort(void *__base, size_t __nel, size_t __width,
182 int (* _Nonnull __compar)(const void *, const void *));
507116e3 183#ifndef UNIFDEF_DRIVERKIT
974e3884 184int rand(void) __swift_unavailable("Use arc4random instead.");
70ad1dc8 185/* realloc is now declared in _malloc.h */
974e3884 186void srand(unsigned) __swift_unavailable("Use arc4random instead.");
507116e3 187#endif /* UNIFDEF_DRIVERKIT */
224c7076
A
188double strtod(const char *, char **) __DARWIN_ALIAS(strtod);
189float strtof(const char *, char **) __DARWIN_ALIAS(strtof);
974e3884 190long strtol(const char *__str, char **__endptr, int __base);
9385eb3d 191long double
ad3c9f2a 192 strtold(const char *, char **);
3d9156a7
A
193#if !__DARWIN_NO_LONG_LONG
194long long
974e3884 195 strtoll(const char *__str, char **__endptr, int __base);
3d9156a7 196#endif /* !__DARWIN_NO_LONG_LONG */
5b2abdfb 197unsigned long
974e3884 198 strtoul(const char *__str, char **__endptr, int __base);
3d9156a7
A
199#if !__DARWIN_NO_LONG_LONG
200unsigned long long
974e3884 201 strtoull(const char *__str, char **__endptr, int __base);
3d9156a7 202#endif /* !__DARWIN_NO_LONG_LONG */
507116e3 203#ifndef UNIFDEF_DRIVERKIT
224c7076
A
204//Begin-Libc
205#ifndef LIBC_ALIAS_SYSTEM
206//End-Libc
974e3884 207
a9aaacca 208#if TARGET_OS_IPHONE
974e3884
A
209#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg)
210#else
211#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg)
212#endif
213
214__swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable")
b061a43b 215__API_AVAILABLE(macos(10.0)) __IOS_PROHIBITED
974e3884
A
216__WATCHOS_PROHIBITED __TVOS_PROHIBITED
217int system(const char *) __DARWIN_ALIAS_C(system);
224c7076
A
218//Begin-Libc
219#else /* LIBC_ALIAS_SYSTEM */
220int system(const char *) LIBC_ALIAS_C(system);
221#endif /* !LIBC_ALIAS_SYSTEM */
222//End-Libc
974e3884
A
223
224#undef __swift_unavailable_on
507116e3 225#endif /* UNIFDEF_DRIVERKIT */
974e3884 226
9385eb3d 227size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t);
3d9156a7 228int wctomb(char *, wchar_t);
5b2abdfb 229
507116e3 230#ifndef UNIFDEF_DRIVERKIT
5b2abdfb 231#ifndef _ANSI_SOURCE
3d9156a7
A
232void _Exit(int) __dead2;
233long a64l(const char *);
9385eb3d 234double drand48(void);
3d9156a7 235char *ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */
974e3884 236double erand48(unsigned short[3]);
3d9156a7
A
237char *fcvt(double, int, int *__restrict, int *__restrict); /* LEGACY */
238char *gcvt(double, int, char *); /* LEGACY */
239int getsubopt(char **, char * const *, char **);
240int grantpt(int);
241#if __DARWIN_UNIX03
242char *initstate(unsigned, char *, size_t); /* no __DARWIN_ALIAS needed */
243#else /* !__DARWIN_UNIX03 */
244char *initstate(unsigned long, char *, long);
245#endif /* __DARWIN_UNIX03 */
974e3884 246long jrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead.");
3d9156a7 247char *l64a(long);
9385eb3d 248void lcong48(unsigned short[7]);
974e3884 249long lrand48(void) __swift_unavailable("Use arc4random instead.");
3d9156a7
A
250char *mktemp(char *);
251int mkstemp(char *);
974e3884
A
252long mrand48(void) __swift_unavailable("Use arc4random instead.");
253long nrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead.");
3d9156a7
A
254int posix_openpt(int);
255char *ptsname(int);
e07eda1a
A
256
257#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
258int ptsname_r(int fildes, char *buffer, size_t buflen) __API_AVAILABLE(macos(10.13.4), ios(11.3), tvos(11.3), watchos(4.3));
259#endif
260
224c7076
A
261//Begin-Libc
262#ifndef LIBC_ALIAS_PUTENV
263//End-Libc
3d9156a7 264int putenv(char *) __DARWIN_ALIAS(putenv);
224c7076
A
265//Begin-Libc
266#else /* LIBC_ALIAS_PUTENV */
267int putenv(char *) LIBC_ALIAS(putenv);
268#endif /* !LIBC_ALIAS_PUTENV */
269//End-Libc
974e3884
A
270long random(void) __swift_unavailable("Use arc4random instead.");
271int rand_r(unsigned *) __swift_unavailable("Use arc4random instead.");
224c7076
A
272//Begin-Libc
273#ifdef __LIBC__
274#ifndef LIBC_ALIAS_REALPATH
275char *realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath);
276#else /* LIBC_ALIAS_REALPATH */
277#ifdef VARIANT_DARWINEXTSN
278char *realpath(const char * __restrict, char * __restrict) LIBC_EXTSN(realpath);
279#else /* !VARIANT_DARWINEXTSN */
280char *realpath(const char * __restrict, char * __restrict) LIBC_ALIAS(realpath);
281#endif /* VARIANT_DARWINEXTSN */
282#endif /* !LIBC_ALIAS_REALPATH */
283#else /* !__LIBC__ */
284//End-Libc
285#if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH)
286char *realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath);
287#else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */
288char *realpath(const char * __restrict, char * __restrict) __DARWIN_ALIAS(realpath);
289#endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */
290//Begin-Libc
291#endif /* __LIBC__ */
292//End-Libc
9385eb3d
A
293unsigned short
294 *seed48(unsigned short[3]);
224c7076
A
295//Begin-Libc
296#ifndef LIBC_ALIAS_SETENV
297//End-Libc
974e3884 298int setenv(const char * __name, const char * __value, int __overwrite) __DARWIN_ALIAS(setenv);
224c7076
A
299//Begin-Libc
300#else /* LIBC_ALIAS_SETENV */
974e3884 301int setenv(const char * __name, const char * __value, int __overwrite) LIBC_ALIAS(setenv);
224c7076
A
302#endif /* !LIBC_ALIAS_SETENV */
303//End-Libc
3d9156a7 304#if __DARWIN_UNIX03
224c7076
A
305//Begin-Libc
306#ifndef LIBC_ALIAS_SETKEY
307//End-Libc
3d9156a7 308void setkey(const char *) __DARWIN_ALIAS(setkey);
224c7076
A
309//Begin-Libc
310#else /* LIBC_ALIAS_SETKEY */
311void setkey(const char *) LIBC_ALIAS(setkey);
312#endif /* !LIBC_ALIAS_SETKEY */
313//End-Libc
3d9156a7
A
314#else /* !__DARWIN_UNIX03 */
315int setkey(const char *);
316#endif /* __DARWIN_UNIX03 */
317char *setstate(const char *);
9385eb3d 318void srand48(long);
3d9156a7
A
319#if __DARWIN_UNIX03
320void srandom(unsigned);
321#else /* !__DARWIN_UNIX03 */
322void srandom(unsigned long);
323#endif /* __DARWIN_UNIX03 */
324int unlockpt(int);
325#if __DARWIN_UNIX03
224c7076
A
326//Begin-Libc
327#ifndef LIBC_ALIAS_UNSETENV
328//End-Libc
3d9156a7 329int unsetenv(const char *) __DARWIN_ALIAS(unsetenv);
224c7076
A
330//Begin-Libc
331#else /* LIBC_ALIAS_UNSETENV */
332int unsetenv(const char *) LIBC_ALIAS(unsetenv);
333#endif /* !LIBC_ALIAS_UNSETENV */
334//End-Libc
3d9156a7
A
335#else /* !__DARWIN_UNIX03 */
336void unsetenv(const char *);
337#endif /* __DARWIN_UNIX03 */
224c7076 338#endif /* !_ANSI_SOURCE */
507116e3 339#endif /* UNIFDEF_DRIVERKIT */
3d9156a7 340
224c7076 341#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
3d9156a7 342#include <machine/types.h>
507116e3 343#ifndef UNIFDEF_DRIVERKIT
6465356a
A
344#include <sys/_types/_dev_t.h>
345#include <sys/_types/_mode_t.h>
507116e3 346#endif /* UNIFDEF_DRIVERKIT */
974e3884 347#include <_types/_uint32_t.h>
3d9156a7 348
974e3884 349uint32_t arc4random(void);
507116e3 350#ifndef UNIFDEF_DRIVERKIT
974e3884
A
351void arc4random_addrandom(unsigned char * /*dat*/, int /*datlen*/)
352 __OSX_DEPRECATED(10.0, 10.12, "use arc4random_stir")
353 __IOS_DEPRECATED(2.0, 10.0, "use arc4random_stir")
354 __TVOS_DEPRECATED(2.0, 10.0, "use arc4random_stir")
355 __WATCHOS_DEPRECATED(1.0, 3.0, "use arc4random_stir");
507116e3 356#endif /* UNIFDEF_DRIVERKIT */
974e3884 357void arc4random_buf(void * __buf, size_t __nbytes) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
3d9156a7 358void arc4random_stir(void);
974e3884
A
359uint32_t
360 arc4random_uniform(uint32_t __upper_bound) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
34e8f829 361#ifdef __BLOCKS__
507116e3 362#ifndef UNIFDEF_DRIVERKIT
974e3884 363int atexit_b(void (^ _Nonnull)(void)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
507116e3 364#endif /* UNIFDEF_DRIVERKIT */
974e3884
A
365void *bsearch_b(const void *__key, const void *__base, size_t __nel,
366 size_t __width, int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
34e8f829 367#endif /* __BLOCKS__ */
9385eb3d 368
507116e3 369#ifndef UNIFDEF_DRIVERKIT
9385eb3d
A
370 /* getcap(3) functions */
371char *cgetcap(char *, const char *, int);
372int cgetclose(void);
373int cgetent(char **, char **, const char *);
374int cgetfirst(char **, char **);
375int cgetmatch(const char *, const char *);
376int cgetnext(char **, char **);
377int cgetnum(char *, const char *, long *);
378int cgetset(const char *);
379int cgetstr(char *, const char *, char **);
380int cgetustr(char *, const char *, char **);
381
5f125488 382int 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;
3d9156a7
A
383char *devname(dev_t, mode_t);
384char *devname_r(dev_t, mode_t, char *buf, int len);
9385eb3d
A
385char *getbsize(int *, long *);
386int getloadavg(double [], int);
387const char
388 *getprogname(void);
507116e3
A
389void setprogname(const char *);
390#endif /* UNIFDEF_DRIVERKIT */
391
392#ifdef __BLOCKS__
393#if __has_attribute(noescape)
394#define __sort_noescape __attribute__((__noescape__))
395#else
396#define __sort_noescape
397#endif
398#endif /* __BLOCKS__ */
9385eb3d 399
974e3884
A
400int heapsort(void *__base, size_t __nel, size_t __width,
401 int (* _Nonnull __compar)(const void *, const void *));
34e8f829 402#ifdef __BLOCKS__
974e3884 403int heapsort_b(void *__base, size_t __nel, size_t __width,
507116e3
A
404 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape)
405 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
34e8f829 406#endif /* __BLOCKS__ */
974e3884
A
407int mergesort(void *__base, size_t __nel, size_t __width,
408 int (* _Nonnull __compar)(const void *, const void *));
34e8f829 409#ifdef __BLOCKS__
974e3884 410int mergesort_b(void *__base, size_t __nel, size_t __width,
507116e3
A
411 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape)
412 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
34e8f829 413#endif /* __BLOCKS__ */
507116e3 414#ifndef UNIFDEF_DRIVERKIT
974e3884 415void psort(void *__base, size_t __nel, size_t __width,
507116e3
A
416 int (* _Nonnull __compar)(const void *, const void *))
417 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
34e8f829 418#ifdef __BLOCKS__
974e3884 419void psort_b(void *__base, size_t __nel, size_t __width,
507116e3
A
420 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape)
421 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
34e8f829 422#endif /* __BLOCKS__ */
974e3884 423void psort_r(void *__base, size_t __nel, size_t __width, void *,
507116e3
A
424 int (* _Nonnull __compar)(void *, const void *, const void *))
425 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
426#endif /* UNIFDEF_DRIVERKIT */
34e8f829 427#ifdef __BLOCKS__
974e3884 428void qsort_b(void *__base, size_t __nel, size_t __width,
507116e3
A
429 int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape)
430 __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
34e8f829 431#endif /* __BLOCKS__ */
974e3884
A
432void qsort_r(void *__base, size_t __nel, size_t __width, void *,
433 int (* _Nonnull __compar)(void *, const void *, const void *));
434int radixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
435 unsigned __endbyte);
507116e3
A
436int rpmatch(const char *)
437 __API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0), watchos(6.0));
974e3884
A
438int sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table,
439 unsigned __endbyte);
507116e3 440#ifndef UNIFDEF_DRIVERKIT
9385eb3d
A
441void sranddev(void);
442void srandomdev(void);
b061a43b 443void *reallocf(void *__ptr, size_t __size) __alloc_size(2);
a9aaacca
A
444long long
445 strtonum(const char *__numstr, long long __minval, long long __maxval, const char **__errstrp)
446 __API_AVAILABLE(macos(10.16), ios(14.0), tvos(14.0), watchos(7.0));
507116e3 447#endif /* UNIFDEF_DRIVERKIT */
3d9156a7 448#if !__DARWIN_NO_LONG_LONG
5b2abdfb 449long long
974e3884 450 strtoq(const char *__str, char **__endptr, int __base);
5b2abdfb 451unsigned long long
974e3884 452 strtouq(const char *__str, char **__endptr, int __base);
3d9156a7 453#endif /* !__DARWIN_NO_LONG_LONG */
507116e3 454#ifndef UNIFDEF_DRIVERKIT
3d9156a7 455extern char *suboptarg; /* getsubopt(3) external variable */
70ad1dc8 456/* valloc is now declared in _malloc.h */
507116e3 457#endif /* UNIFDEF_DRIVERKIT */
224c7076
A
458#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
459
460/* Poison the following routines if -fshort-wchar is set */
461#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU
462#pragma GCC poison mbstowcs mbtowc wcstombs wctomb
5b2abdfb
A
463#endif
464__END_DECLS
465
3d9156a7
A
466#ifdef _USE_EXTENDED_LOCALES_
467#include <xlocale/_stdlib.h>
468#endif /* _USE_EXTENDED_LOCALES_ */
469
5b2abdfb 470#endif /* _STDLIB_H_ */