stdlib.h revision cce36c187896fb0d4bd36519c4b2e90c502137dc
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 491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char *getenv(const char *); 501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int putenv(const char *); 511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int setenv(const char *, const char *, int); 521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int unsetenv(const char *); 531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int clearenv(void); 541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 55c13fb75ceabb47f8292be206db80b93889fccf66Elliott Hughesextern char* mkdtemp(char*); 56c13fb75ceabb47f8292be206db80b93889fccf66Elliott Hughesextern char* mktemp(char*) __warnattr("mktemp possibly used unsafely; consider using mkstemp"); 57c13fb75ceabb47f8292be206db80b93889fccf66Elliott Hughesextern int mkstemp(char*); 58fe317a3775e16d466bb884a8e054fd77f7087bb3Calin Juravleextern int mkstemp64(char*); 591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long strtol(const char *, char **, int); 611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long long strtoll(const char *, char **, int); 621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern unsigned long strtoul(const char *, char **, int); 631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern unsigned long long strtoull(const char *, char **, int); 641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 6585aad909560508410101c18c6ecc6633df39c596Ken Sumrallextern int posix_memalign(void **memptr, size_t alignment, size_t size); 6685aad909560508410101c18c6ecc6633df39c596Ken Sumrall 675a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern double atof(const char*); 68cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughes 69cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughesextern double strtod(const char*, char**) __LIBC_ABI_PUBLIC__; 70cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughesextern float strtof(const char*, char**) __LIBC_ABI_PUBLIC__; 71cce36c187896fb0d4bd36519c4b2e90c502137dcElliott Hughesextern long double strtold(const char*, char**) __LIBC_ABI_PUBLIC__; 721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 735a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern int atoi(const char*) __purefunc; 745a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern long atol(const char*) __purefunc; 755a8173860d65182af022be88fed0c5d8d5dcb69dElliott Hughesextern long long atoll(const char*) __purefunc; 761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 77aec2ffbc5a7b45368ceab3663265fbb659968fe7Elliott Hughesextern int abs(int) __pure2; 78aec2ffbc5a7b45368ceab3663265fbb659968fe7Elliott Hughesextern long labs(long) __pure2; 79aec2ffbc5a7b45368ceab3663265fbb659968fe7Elliott Hughesextern long long llabs(long long) __pure2; 801dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 811dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char * realpath(const char *path, char *resolved); 821dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int system(const char * string); 831dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 841dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern void * bsearch(const void *key, const void *base0, 851dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project size_t nmemb, size_t size, 861dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project int (*compar)(const void *, const void *)); 871dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 881dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); 891dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 901dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long jrand48(unsigned short *); 911dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long mrand48(void); 921dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long nrand48(unsigned short *); 931dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long lrand48(void); 941dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern unsigned short *seed48(unsigned short*); 9550ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turnerextern double erand48(unsigned short xsubi[3]); 9650ace4fec5e8cb5afcbc656a4556fa528adfd760David 'Digit' Turnerextern double drand48(void); 971dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern void srand48(long); 981dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern unsigned int arc4random(void); 991dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern void arc4random_stir(void); 1001dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern void arc4random_addrandom(unsigned char *, int); 1011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1021dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define RAND_MAX 0x7fffffff 1031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectstatic __inline__ int rand(void) { 1041dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project return (int)lrand48(); 1051dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} 1061dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectstatic __inline__ void srand(unsigned int __s) { 1071dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project srand48(__s); 1081dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} 1091dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectstatic __inline__ long random(void) 1101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project{ 1111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project return lrand48(); 1121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} 1131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectstatic __inline__ void srandom(unsigned int __s) 1141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project{ 1151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project srand48(__s); 1161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} 1171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* Basic PTY functions. These only work if devpts is mounted! */ 1191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int unlockpt(int); 1211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char* ptsname(int); 1226458c49c96fd2069a82fa6bb48283b4397087a25Colin Crossextern int ptsname_r(int, char*, size_t); 1231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int getpt(void); 1241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 125506b13d910a1a603b29fbc5a9ba41ba4c533b14cJing Yustatic __inline__ int grantpt(int __fd __attribute((unused))) 1261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project{ 1271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project (void)__fd; 1281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project return 0; /* devpts does this all for us! */ 1291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} 1301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projecttypedef struct { 1321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project int quot; 1331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project int rem; 1341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} div_t; 1351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern div_t div(int, int); 1371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projecttypedef struct { 1391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project long int quot; 1401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project long int rem; 1411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} ldiv_t; 1421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern ldiv_t ldiv(long, long); 1441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projecttypedef struct { 1461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project long long int quot; 1471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project long long int rem; 1481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project} lldiv_t; 1491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern lldiv_t lldiv(long long, long long); 1511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 152692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughes/* BSD compatibility. */ 153692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughesextern const char* getprogname(void); 154692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughesextern void setprogname(const char*); 155692207eb457f9b4bf6cb4301d710d19b6e85c902Elliott Hughes 1561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* make STLPort happy */ 1571dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int mblen(const char *, size_t); 1581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern size_t mbstowcs(wchar_t *, const char *, size_t); 1591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int mbtowc(wchar_t *, const char *, size_t); 1601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* Likewise, make libstdc++-v3 happy. */ 1621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int wctomb(char *, wchar_t); 1631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern size_t wcstombs(char *, const wchar_t *, size_t); 164bb5581ad6eec40041dab4e961149f7a8a3a83497David 'Digit' Turner 1651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define MB_CUR_MAX 1 1661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 167bb5581ad6eec40041dab4e961149f7a8a3a83497David 'Digit' Turner#if 0 /* MISSING FROM BIONIC */ 168bb5581ad6eec40041dab4e961149f7a8a3a83497David 'Digit' Turnerextern int on_exit(void (*)(int, void *), void *); 169bb5581ad6eec40041dab4e961149f7a8a3a83497David 'Digit' Turner#endif /* MISSING */ 170bb5581ad6eec40041dab4e961149f7a8a3a83497David 'Digit' Turner 1711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project__END_DECLS 1721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project 1731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* _STDLIB_H_ */ 174