stdlib.h revision a381fe8ebcd196614a00f4dca3539e0860ef9e84
11dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/*
21dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * All rights reserved.
41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Redistribution and use in source and binary forms, with or without
61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * modification, are permitted provided that the following conditions
71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * are met:
81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *  * Redistributions of source code must retain the above copyright
91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *  * Redistributions in binary form must reproduce the above copyright
111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    notice, this list of conditions and the following disclaimer in
121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    the documentation and/or other materials provided with the
131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    distribution.
141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * SUCH DAMAGE.
271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */
281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifndef _STDLIB_H_
291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _STDLIB_H_
301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <sys/cdefs.h>
321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <stddef.h>
341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <string.h>
351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <alloca.h>
361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <strings.h>
371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <memory.h>
381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project__BEGIN_DECLS
401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define EXIT_FAILURE 1
421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define EXIT_SUCCESS 0
431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern __noreturn void abort(void);
459f525644df99cb2f7f81a23ca23840f0a8f82275Elliott Hughesextern __noreturn void exit(int);
469f525644df99cb2f7f81a23ca23840f0a8f82275Elliott Hughesextern __noreturn void _Exit(int);
471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int atexit(void (*)(void));
481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
49b8425c549a0bfe08b01b5906b95603d8523c1b16Dan Albert#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
50b8425c549a0bfe08b01b5906b95603d8523c1b16Dan Albertint at_quick_exit(void (*)(void));
51b8425c549a0bfe08b01b5906b95603d8523c1b16Dan Albertvoid quick_exit(int) __noreturn;
52b8425c549a0bfe08b01b5906b95603d8523c1b16Dan Albert#endif
53b8425c549a0bfe08b01b5906b95603d8523c1b16Dan Albert
5458d9e280d459225aa8dc4533e883182b08215f7dElliott Hughesextern char* getenv(const char*);
5558d9e280d459225aa8dc4533e883182b08215f7dElliott Hughesextern int putenv(char*);
5658d9e280d459225aa8dc4533e883182b08215f7dElliott Hughesextern int setenv(const char*, const char*, int);
5758d9e280d459225aa8dc4533e883182b08215f7dElliott Hughesextern int unsetenv(const char*);
581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int clearenv(void);
591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
60c13fb75ceabb47f8292be206db80b93889fccf66Elliott Hughesextern char* mkdtemp(char*);
61c13fb75ceabb47f8292be206db80b93889fccf66Elliott Hughesextern char* mktemp(char*) __warnattr("mktemp possibly used unsafely; consider using mkstemp");
6231165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughes
6331165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesextern int mkostemp64(char*, int);
6431165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesextern int mkostemp(char*, int);
6531165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesextern int mkostemps64(char*, int, int);
6631165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesextern int mkostemps(char*, int, int);
67fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravleextern int mkstemp64(char*);
6831165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesextern int mkstemp(char*);
6931165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesextern int mkstemps64(char*, int);
7031165edf5733dae8fbe79551b18cbc0e56c8d808Elliott Hughesextern int mkstemps(char*, int);
711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long strtol(const char *, char **, int);
731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long long strtoll(const char *, char **, int);
741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern unsigned long strtoul(const char *, char **, int);
751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern unsigned long long strtoull(const char *, char **, int);
761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
7785aad909560508410101c18c6ecc6633df39c596Ken Sumrallextern int posix_memalign(void **memptr, size_t alignment, size_t size);
7885aad909560508410101c18c6ecc6633df39c596Ken Sumrall
795a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern double atof(const char*);
80cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughes
81cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughesextern double strtod(const char*, char**) __LIBC_ABI_PUBLIC__;
82cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughesextern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__;
83cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughesextern long double strtold(const char*, char**) __LIBC_ABI_PUBLIC__;
841dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
85dfb5ce42bcc5a275af49211c0bbe64c5ec3d2668Dan Albertextern long double strtold_l(const char *, char **, locale_t) __LIBC_ABI_PUBLIC__;
863c5037f1b3b747e79d17a5f717d9f9c365132d33Dan Albertextern long long strtoll_l(const char *, char **, int, locale_t) __LIBC_ABI_PUBLIC__;
873c5037f1b3b747e79d17a5f717d9f9c365132d33Dan Albertextern unsigned long long strtoull_l(const char *, char **, int, locale_t) __LIBC_ABI_PUBLIC__;
88dfb5ce42bcc5a275af49211c0bbe64c5ec3d2668Dan Albert
895a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern int atoi(const char*) __purefunc;
905a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern long atol(const char*) __purefunc;
915a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern long long atoll(const char*) __purefunc;
921dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
93aec2ffbc5a7b45368ceab3663265fbb659968fe7Elliott Hughesextern int abs(int) __pure2;
94aec2ffbc5a7b45368ceab3663265fbb659968fe7Elliott Hughesextern long labs(long) __pure2;
95aec2ffbc5a7b45368ceab3663265fbb659968fe7Elliott Hughesextern long long llabs(long long) __pure2;
961dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
971dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char * realpath(const char *path, char *resolved);
981dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int system(const char * string);
991dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1001dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern void * bsearch(const void *key, const void *base0,
1011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project	size_t nmemb, size_t size,
1021dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project	int (*compar)(const void *, const void *));
1031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1041dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1051dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
106a39f939e0d1a11290411430d9085ab578d471247Yabin Cuiuint32_t arc4random(void);
107a39f939e0d1a11290411430d9085ab578d471247Yabin Cuiuint32_t arc4random_uniform(uint32_t);
1080468feb28696751efcddada8de69a622afffdba8Elliott Hughesvoid arc4random_buf(void*, size_t);
1091dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define RAND_MAX 0x7fffffff
111a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hughes
112a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hughesint rand(void);
113a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hughesint rand_r(unsigned int*);
114a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hughesvoid srand(unsigned int);
115a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hughes
116274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hughesdouble drand48(void);
117274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hughesdouble erand48(unsigned short[3]);
118274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hugheslong jrand48(unsigned short[3]);
119274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hughesvoid lcong48(unsigned short[7]);
120274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hugheslong lrand48(void);
121274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hugheslong mrand48(void);
122274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hugheslong nrand48(unsigned short[3]);
123274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hughesunsigned short* seed48(unsigned short[3]);
124274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hughesvoid srand48(long);
125274afe8f0eab4139c94d5f8b1ee3d267f449ef42Elliott Hughes
126a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hugheschar* initstate(unsigned int, char*, size_t);
127a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hugheslong random(void);
128a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hugheschar* setstate(char*);
129a0beeeabbc8735bc830544cbbb1d920122b8d958Elliott Hughesvoid srandom(unsigned int);
1301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1314916706cfe590eb06c9b5bd4bd402ce056034d51Elliott Hughesint getpt(void);
1324916706cfe590eb06c9b5bd4bd402ce056034d51Elliott Hughesint grantpt(int);
1334916706cfe590eb06c9b5bd4bd402ce056034d51Elliott Hughesint posix_openpt(int);
134a381fe8ebcd196614a00f4dca3539e0860ef9e84Elliott Hugheschar* ptsname(int);
1354916706cfe590eb06c9b5bd4bd402ce056034d51Elliott Hughesint ptsname_r(int, char*, size_t);
1364916706cfe590eb06c9b5bd4bd402ce056034d51Elliott Hughesint unlockpt(int);
1371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projecttypedef struct {
1391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    int  quot;
1401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    int  rem;
1411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} div_t;
1421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
143b27a840f4b520bfa095db99b0a2e5205634b0003Elliott Hughesextern div_t   div(int, int) __pure2;
1441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projecttypedef struct {
1461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    long int  quot;
1471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    long int  rem;
1481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} ldiv_t;
1491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
150b27a840f4b520bfa095db99b0a2e5205634b0003Elliott Hughesextern ldiv_t   ldiv(long, long) __pure2;
1511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projecttypedef struct {
1531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    long long int  quot;
1541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project    long long int  rem;
1551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} lldiv_t;
1561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
157b27a840f4b520bfa095db99b0a2e5205634b0003Elliott Hughesextern lldiv_t   lldiv(long long, long long) __pure2;
1581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
159692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughes/* BSD compatibility. */
160692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughesextern const char* getprogname(void);
161692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughesextern void setprogname(const char*);
162692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughes
1631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* make STLPort happy */
1641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int      mblen(const char *, size_t);
1651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern size_t   mbstowcs(wchar_t *, const char *, size_t);
1661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int      mbtowc(wchar_t *, const char *, size_t);
1671dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1681dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* Likewise, make libstdc++-v3 happy.  */
1691dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int	wctomb(char *, wchar_t);
1701dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern size_t	wcstombs(char *, const wchar_t *, size_t);
171bb5581ad6eec40041dab4e961149f7a8a3a83497David 'Digit' Turner
172224ff048efc782bd60047a3ae53eb66941f73125Dan Albertextern size_t __ctype_get_mb_cur_max(void);
173224ff048efc782bd60047a3ae53eb66941f73125Dan Albert#define MB_CUR_MAX __ctype_get_mb_cur_max()
1741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project__END_DECLS
1761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1771dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* _STDLIB_H_ */
178