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.
|
|
|
|
*/
|
|
|
|
#ifndef _STDLIB_H_
|
|
|
|
#define _STDLIB_H_
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <alloca.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <memory.h>
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
#define EXIT_FAILURE 1
|
|
|
|
#define EXIT_SUCCESS 0
|
|
|
|
|
|
|
|
extern __noreturn void abort(void);
|
2014-04-09 02:14:01 +02:00
|
|
|
extern __noreturn void exit(int);
|
|
|
|
extern __noreturn void _Exit(int);
|
2009-03-04 04:28:35 +01:00
|
|
|
extern int atexit(void (*)(void));
|
|
|
|
|
2014-04-30 02:49:06 +02:00
|
|
|
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
|
|
|
|
int at_quick_exit(void (*)(void));
|
|
|
|
void quick_exit(int) __noreturn;
|
|
|
|
#endif
|
|
|
|
|
2014-04-23 02:41:00 +02:00
|
|
|
extern char* getenv(const char*);
|
|
|
|
extern int putenv(char*);
|
|
|
|
extern int setenv(const char*, const char*, int);
|
|
|
|
extern int unsetenv(const char*);
|
2009-03-04 04:28:35 +01:00
|
|
|
extern int clearenv(void);
|
|
|
|
|
2013-12-18 05:43:30 +01:00
|
|
|
extern char* mkdtemp(char*);
|
|
|
|
extern char* mktemp(char*) __warnattr("mktemp possibly used unsafely; consider using mkstemp");
|
|
|
|
extern int mkstemp(char*);
|
2014-02-21 16:11:03 +01:00
|
|
|
extern int mkstemp64(char*);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern long strtol(const char *, char **, int);
|
|
|
|
extern long long strtoll(const char *, char **, int);
|
|
|
|
extern unsigned long strtoul(const char *, char **, int);
|
|
|
|
extern unsigned long long strtoull(const char *, char **, int);
|
|
|
|
|
2011-12-15 05:50:01 +01:00
|
|
|
extern int posix_memalign(void **memptr, size_t alignment, size_t size);
|
|
|
|
|
2014-03-13 00:12:57 +01:00
|
|
|
extern double atof(const char*);
|
2014-04-22 21:32:49 +02:00
|
|
|
|
|
|
|
extern double strtod(const char*, char**) __LIBC_ABI_PUBLIC__;
|
|
|
|
extern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__;
|
|
|
|
extern long double strtold(const char*, char**) __LIBC_ABI_PUBLIC__;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-03-13 00:12:57 +01:00
|
|
|
extern int atoi(const char*) __purefunc;
|
|
|
|
extern long atol(const char*) __purefunc;
|
|
|
|
extern long long atoll(const char*) __purefunc;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2013-08-12 21:07:05 +02:00
|
|
|
extern int abs(int) __pure2;
|
|
|
|
extern long labs(long) __pure2;
|
|
|
|
extern long long llabs(long long) __pure2;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
extern char * realpath(const char *path, char *resolved);
|
|
|
|
extern int system(const char * string);
|
|
|
|
|
|
|
|
extern void * bsearch(const void *key, const void *base0,
|
|
|
|
size_t nmemb, size_t size,
|
|
|
|
int (*compar)(const void *, const void *));
|
|
|
|
|
|
|
|
extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
|
|
|
|
|
|
|
|
extern long jrand48(unsigned short *);
|
|
|
|
extern long mrand48(void);
|
|
|
|
extern long nrand48(unsigned short *);
|
|
|
|
extern long lrand48(void);
|
|
|
|
extern unsigned short *seed48(unsigned short*);
|
2010-06-17 01:36:41 +02:00
|
|
|
extern double erand48(unsigned short xsubi[3]);
|
|
|
|
extern double drand48(void);
|
2009-03-04 04:28:35 +01:00
|
|
|
extern void srand48(long);
|
|
|
|
extern unsigned int arc4random(void);
|
|
|
|
extern void arc4random_stir(void);
|
|
|
|
extern void arc4random_addrandom(unsigned char *, int);
|
|
|
|
|
|
|
|
#define RAND_MAX 0x7fffffff
|
2014-06-12 20:48:04 +02:00
|
|
|
|
2014-06-13 02:50:52 +02:00
|
|
|
/* Work around x86 libvpx build breakage caused by postproc_x86.c. */
|
|
|
|
#if defined(__i386__) && defined(rand)
|
|
|
|
#undef rand
|
|
|
|
#define __rand lrand48
|
|
|
|
#endif
|
|
|
|
|
2014-06-12 20:48:04 +02:00
|
|
|
int rand(void);
|
|
|
|
int rand_r(unsigned int*);
|
|
|
|
void srand(unsigned int);
|
|
|
|
|
|
|
|
char* initstate(unsigned int, char*, size_t);
|
|
|
|
long random(void);
|
|
|
|
char* setstate(char*);
|
|
|
|
void srandom(unsigned int);
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
/* Basic PTY functions. These only work if devpts is mounted! */
|
|
|
|
|
|
|
|
extern int unlockpt(int);
|
|
|
|
extern char* ptsname(int);
|
2010-01-12 21:58:12 +01:00
|
|
|
extern int ptsname_r(int, char*, size_t);
|
2009-03-04 04:28:35 +01:00
|
|
|
extern int getpt(void);
|
|
|
|
|
2010-05-21 05:25:48 +02:00
|
|
|
static __inline__ int grantpt(int __fd __attribute((unused)))
|
2009-03-04 04:28:35 +01:00
|
|
|
{
|
|
|
|
(void)__fd;
|
|
|
|
return 0; /* devpts does this all for us! */
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int quot;
|
|
|
|
int rem;
|
|
|
|
} div_t;
|
|
|
|
|
2014-06-11 05:47:49 +02:00
|
|
|
extern div_t div(int, int) __pure2;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
long int quot;
|
|
|
|
long int rem;
|
|
|
|
} ldiv_t;
|
|
|
|
|
2014-06-11 05:47:49 +02:00
|
|
|
extern ldiv_t ldiv(long, long) __pure2;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
long long int quot;
|
|
|
|
long long int rem;
|
|
|
|
} lldiv_t;
|
|
|
|
|
2014-06-11 05:47:49 +02:00
|
|
|
extern lldiv_t lldiv(long long, long long) __pure2;
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2014-03-01 01:23:27 +01:00
|
|
|
/* BSD compatibility. */
|
|
|
|
extern const char* getprogname(void);
|
|
|
|
extern void setprogname(const char*);
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
/* make STLPort happy */
|
|
|
|
extern int mblen(const char *, size_t);
|
|
|
|
extern size_t mbstowcs(wchar_t *, const char *, size_t);
|
|
|
|
extern int mbtowc(wchar_t *, const char *, size_t);
|
|
|
|
|
|
|
|
/* Likewise, make libstdc++-v3 happy. */
|
|
|
|
extern int wctomb(char *, wchar_t);
|
|
|
|
extern size_t wcstombs(char *, const wchar_t *, size_t);
|
2010-10-09 17:56:55 +02:00
|
|
|
|
2014-06-06 05:10:09 +02:00
|
|
|
#define MB_CUR_MAX 4U
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2010-10-09 17:56:55 +02:00
|
|
|
#if 0 /* MISSING FROM BIONIC */
|
|
|
|
extern int on_exit(void (*)(int, void *), void *);
|
|
|
|
#endif /* MISSING */
|
|
|
|
|
2009-03-04 04:28:35 +01:00
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif /* _STDLIB_H_ */
|