2009-03-04 04:28:35 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2015-01-26 22:34:58 +01:00
|
|
|
|
|
|
|
#ifndef _STDLIB_H
|
|
|
|
#define _STDLIB_H
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
#include <alloca.h>
|
2017-10-21 02:57:17 +02:00
|
|
|
#include <bits/wait.h>
|
2015-01-26 22:34:58 +01:00
|
|
|
#include <malloc.h>
|
|
|
|
#include <stddef.h>
|
2017-10-21 02:57:17 +02:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <xlocale.h>
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
#define EXIT_FAILURE 1
|
|
|
|
#define EXIT_SUCCESS 0
|
|
|
|
|
2016-07-23 03:57:12 +02:00
|
|
|
__noreturn void abort(void);
|
2017-08-12 02:34:44 +02:00
|
|
|
__noreturn void exit(int __status);
|
2019-12-20 22:26:14 +01:00
|
|
|
#if __ANDROID_API__ >= 21
|
2017-08-12 02:34:44 +02:00
|
|
|
__noreturn void _Exit(int __status) __INTRODUCED_IN(21);
|
2017-09-18 23:40:01 +02:00
|
|
|
#else
|
|
|
|
__noreturn void _Exit(int) __RENAME(_exit);
|
|
|
|
#endif
|
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
int atexit(void (*__fn)(void));
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
int at_quick_exit(void (*__fn)(void)) __INTRODUCED_IN(21);
|
|
|
|
void quick_exit(int __status) __noreturn __INTRODUCED_IN(21);
|
2014-04-30 02:49:06 +02:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
char* getenv(const char* __name);
|
|
|
|
int putenv(char* __assignment);
|
|
|
|
int setenv(const char* __name, const char* __value, int __overwrite);
|
|
|
|
int unsetenv(const char* __name);
|
2016-07-23 03:57:12 +02:00
|
|
|
int clearenv(void);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
char* mkdtemp(char* __template);
|
|
|
|
char* mktemp(char* __template) __attribute__((deprecated("mktemp is unsafe, use mkstemp or tmpfile instead")));
|
2014-09-24 02:34:29 +02:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
int mkostemp64(char* __template, int __flags) __INTRODUCED_IN(23);
|
|
|
|
int mkostemp(char* __template, int __flags) __INTRODUCED_IN(23);
|
|
|
|
int mkostemps64(char* __template, int __suffix_length, int __flags) __INTRODUCED_IN(23);
|
|
|
|
int mkostemps(char* __template, int __suffix_length, int __flags) __INTRODUCED_IN(23);
|
|
|
|
int mkstemp64(char* __template) __INTRODUCED_IN(21);
|
|
|
|
int mkstemp(char* __template);
|
|
|
|
int mkstemps64(char* __template, int __flags) __INTRODUCED_IN(23);
|
|
|
|
int mkstemps(char* __template, int __flags);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
long strtol(const char* __s, char** __end_ptr, int __base);
|
|
|
|
long long strtoll(const char* __s, char** __end_ptr, int __base);
|
|
|
|
unsigned long strtoul(const char* __s, char** __end_ptr, int __base);
|
|
|
|
unsigned long long strtoull(const char* __s, char** __end_ptr, int __base);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2018-03-30 00:12:05 +02:00
|
|
|
int posix_memalign(void** __memptr, size_t __alignment, size_t __size) __INTRODUCED_IN(17);
|
2011-12-15 05:50:01 +01:00
|
|
|
|
2018-02-06 03:14:55 +01:00
|
|
|
void* aligned_alloc(size_t __alignment, size_t __size) __INTRODUCED_IN(28);
|
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
double strtod(const char* __s, char** __end_ptr);
|
2017-09-15 00:30:08 +02:00
|
|
|
long double strtold(const char* __s, char** __end_ptr) __RENAME_LDBL(strtod, 3, 21);
|
2016-07-19 22:56:46 +02:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
unsigned long strtoul_l(const char* __s, char** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(26);
|
2014-07-10 00:51:34 +02:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
int atoi(const char* __s) __attribute_pure__;
|
|
|
|
long atol(const char* __s) __attribute_pure__;
|
|
|
|
long long atoll(const char* __s) __attribute_pure__;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2019-06-07 02:23:32 +02:00
|
|
|
__wur char* realpath(const char* __path, char* __resolved);
|
2017-08-12 02:34:44 +02:00
|
|
|
int system(const char* __command);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
void* bsearch(const void* __key, const void* __base, size_t __nmemb, size_t __size, int (*__comparator)(const void* __lhs, const void* __rhs));
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
void qsort(void* __base, size_t __nmemb, size_t __size, int (*__comparator)(const void* __lhs, const void* __rhs));
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-10-28 20:04:02 +01:00
|
|
|
uint32_t arc4random(void);
|
2017-08-12 02:34:44 +02:00
|
|
|
uint32_t arc4random_uniform(uint32_t __upper_bound);
|
|
|
|
void arc4random_buf(void* __buf, size_t __n);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
#define RAND_MAX 0x7fffffff
|
2014-06-12 20:48:04 +02:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
int rand_r(unsigned int* __seed_ptr) __INTRODUCED_IN(21);
|
2014-06-12 20:48:04 +02:00
|
|
|
|
2014-11-06 21:40:08 +01:00
|
|
|
double drand48(void);
|
2017-08-12 02:34:44 +02:00
|
|
|
double erand48(unsigned short __xsubi[3]);
|
|
|
|
long jrand48(unsigned short __xsubi[3]);
|
|
|
|
void lcong48(unsigned short __param[7]) __INTRODUCED_IN(23);
|
2014-11-06 21:40:08 +01:00
|
|
|
long lrand48(void);
|
|
|
|
long mrand48(void);
|
2017-08-12 02:34:44 +02:00
|
|
|
long nrand48(unsigned short __xsubi[3]);
|
|
|
|
unsigned short* seed48(unsigned short __seed16v[3]);
|
|
|
|
void srand48(long __seed);
|
2014-11-06 21:40:08 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
char* initstate(unsigned int __seed, char* __state, size_t __n) __INTRODUCED_IN(21);
|
|
|
|
char* setstate(char* __state) __INTRODUCED_IN(21);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-07-26 02:24:00 +02:00
|
|
|
int getpt(void);
|
2017-08-12 02:34:44 +02:00
|
|
|
int posix_openpt(int __flags) __INTRODUCED_IN(21);
|
|
|
|
char* ptsname(int __fd);
|
|
|
|
int ptsname_r(int __fd, char* __buf, size_t __n);
|
|
|
|
int unlockpt(int __fd);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
int getsubopt(char** __option, char* const* __tokens, char** __value_ptr) __INTRODUCED_IN(26);
|
2016-04-05 02:34:04 +02:00
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
typedef struct {
|
2017-08-12 02:34:44 +02:00
|
|
|
int quot;
|
|
|
|
int rem;
|
2009-03-04 04:28:35 +01:00
|
|
|
} div_t;
|
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
div_t div(int __numerator, int __denominator) __attribute_const__;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2017-08-12 02:34:44 +02:00
|
|
|
long int quot;
|
|
|
|
long int rem;
|
2009-03-04 04:28:35 +01:00
|
|
|
} ldiv_t;
|
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
ldiv_t ldiv(long __numerator, long __denominator) __attribute_const__;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2017-08-12 02:34:44 +02:00
|
|
|
long long int quot;
|
|
|
|
long long int rem;
|
2009-03-04 04:28:35 +01:00
|
|
|
} lldiv_t;
|
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
lldiv_t lldiv(long long __numerator, long long __denominator) __attribute_const__;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2018-10-23 20:23:00 +02:00
|
|
|
/**
|
|
|
|
* [getloadavg(3)](http://man7.org/linux/man-pages/man3/getloadavg.3.html) queries the
|
|
|
|
* number of runnable processes averaged over time. The Linux kernel supports averages
|
|
|
|
* over the last 1, 5, and 15 minutes.
|
|
|
|
*
|
|
|
|
* Returns the number of samples written to `__averages` (at most 3), and returns -1 on failure.
|
|
|
|
*/
|
2019-03-14 17:29:52 +01:00
|
|
|
int getloadavg(double __averages[], int __n) __INTRODUCED_IN(29);
|
2018-10-23 20:23:00 +02:00
|
|
|
|
2014-03-01 01:23:27 +01:00
|
|
|
/* BSD compatibility. */
|
2016-07-23 03:57:12 +02:00
|
|
|
const char* getprogname(void) __INTRODUCED_IN(21);
|
2017-08-12 02:34:44 +02:00
|
|
|
void setprogname(const char* __name) __INTRODUCED_IN(21);
|
2014-03-01 01:23:27 +01:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
int mblen(const char* __s, size_t __n) __INTRODUCED_IN(26) __VERSIONER_NO_GUARD;
|
|
|
|
size_t mbstowcs(wchar_t* __dst, const char* __src, size_t __n);
|
|
|
|
int mbtowc(wchar_t* __wc_ptr, const char* __s, size_t __n) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
|
|
|
|
int wctomb(char* __dst, wchar_t __wc) __INTRODUCED_IN(21) __VERSIONER_NO_GUARD;
|
2016-09-07 01:51:00 +02:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
size_t wcstombs(char* __dst, const wchar_t* __src, size_t __n);
|
2010-10-09 17:56:55 +02:00
|
|
|
|
2019-12-20 22:26:14 +01:00
|
|
|
#if __ANDROID_API__ >= 21
|
2016-07-23 03:57:12 +02:00
|
|
|
size_t __ctype_get_mb_cur_max(void) __INTRODUCED_IN(21);
|
2014-08-14 22:56:51 +02:00
|
|
|
#define MB_CUR_MAX __ctype_get_mb_cur_max()
|
2016-09-07 01:51:00 +02:00
|
|
|
#else
|
|
|
|
/*
|
2017-02-22 00:54:58 +01:00
|
|
|
* Pre-L we didn't have any locale support and so we were always the POSIX
|
|
|
|
* locale. POSIX specifies that MB_CUR_MAX for the POSIX locale is 1:
|
|
|
|
* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
|
2016-09-07 01:51:00 +02:00
|
|
|
*/
|
2017-02-22 00:54:58 +01:00
|
|
|
#define MB_CUR_MAX 1
|
2016-09-07 01:51:00 +02:00
|
|
|
#endif
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2017-07-25 00:05:05 +02:00
|
|
|
#if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
|
|
|
|
#include <bits/fortify/stdlib.h>
|
|
|
|
#endif
|
2015-04-18 19:04:19 +02:00
|
|
|
|
2019-12-20 22:26:14 +01:00
|
|
|
#if __ANDROID_API__ >= 19
|
2018-01-09 01:18:48 +01:00
|
|
|
int abs(int __x) __attribute_const__ __INTRODUCED_IN(19);
|
|
|
|
long labs(long __x) __attribute_const__ __INTRODUCED_IN(19);
|
|
|
|
long long llabs(long long __x) __attribute_const__ __INTRODUCED_IN(19);
|
|
|
|
#else
|
|
|
|
// Implemented as static inlines before 19.
|
|
|
|
#endif
|
|
|
|
|
2019-12-20 22:26:14 +01:00
|
|
|
#if __ANDROID_API__ >= 21
|
2017-08-12 02:34:44 +02:00
|
|
|
float strtof(const char* __s, char** __end_ptr) __INTRODUCED_IN(21);
|
|
|
|
double atof(const char* __s) __attribute_pure__ __INTRODUCED_IN(21);
|
2016-07-27 01:34:40 +02:00
|
|
|
int rand(void) __INTRODUCED_IN(21);
|
2017-08-12 02:34:44 +02:00
|
|
|
void srand(unsigned int __seed) __INTRODUCED_IN(21);
|
2016-07-27 01:34:40 +02:00
|
|
|
long random(void) __INTRODUCED_IN(21);
|
2017-08-12 02:34:44 +02:00
|
|
|
void srandom(unsigned int __seed) __INTRODUCED_IN(21);
|
|
|
|
int grantpt(int __fd) __INTRODUCED_IN(21);
|
2016-09-23 23:06:05 +02:00
|
|
|
|
2017-08-12 02:34:44 +02:00
|
|
|
long long strtoll_l(const char* __s, char** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(21);
|
|
|
|
unsigned long long strtoull_l(const char* __s, char** __end_ptr, int __base, locale_t __l) __INTRODUCED_IN(21);
|
|
|
|
long double strtold_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(21);
|
2016-07-23 00:26:36 +02:00
|
|
|
#else
|
|
|
|
// Implemented as static inlines before 21.
|
|
|
|
#endif
|
|
|
|
|
2019-12-20 22:26:14 +01:00
|
|
|
#if __ANDROID_API__ >= 26
|
2017-08-12 02:34:44 +02:00
|
|
|
double strtod_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(26);
|
|
|
|
float strtof_l(const char* __s, char** __end_ptr, locale_t __l) __INTRODUCED_IN(26);
|
|
|
|
long strtol_l(const char* __s, char** __end_ptr, int, locale_t __l) __INTRODUCED_IN(26);
|
2016-09-23 23:06:05 +02:00
|
|
|
#else
|
2017-07-10 20:51:00 +02:00
|
|
|
// Implemented as static inlines before 26.
|
2016-09-23 23:06:05 +02:00
|
|
|
#endif
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
__END_DECLS
|
|
|
|
|
2016-04-14 02:18:20 +02:00
|
|
|
#include <android/legacy_stdlib_inlines.h>
|
|
|
|
|
2015-01-26 22:34:58 +01:00
|
|
|
#endif /* _STDLIB_H */
|