stdlib.h revision 103164
193383Smdodd/*- 293383Smdodd * Copyright (c) 1990, 1993 321826Sjoerg * The Regents of the University of California. All rights reserved. 421826Sjoerg * 521826Sjoerg * Redistribution and use in source and binary forms, with or without 621826Sjoerg * modification, are permitted provided that the following conditions 721826Sjoerg * are met: 821826Sjoerg * 1. Redistributions of source code must retain the above copyright 921826Sjoerg * notice, this list of conditions and the following disclaimer. 1021826Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 1121826Sjoerg * notice, this list of conditions and the following disclaimer in the 1221826Sjoerg * documentation and/or other materials provided with the distribution. 1393383Smdodd * 3. All advertising materials mentioning features or use of this software 1421826Sjoerg * must display the following acknowledgement: 1521826Sjoerg * This product includes software developed by the University of 1621826Sjoerg * California, Berkeley and its contributors. 1721826Sjoerg * 4. Neither the name of the University nor the names of its contributors 1821826Sjoerg * may be used to endorse or promote products derived from this software 1921826Sjoerg * without specific prior written permission. 2021826Sjoerg * 2121826Sjoerg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2221826Sjoerg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2321826Sjoerg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2421826Sjoerg * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2521826Sjoerg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2693383Smdodd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2721826Sjoerg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2821826Sjoerg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29119418Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30119418Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31119418Sobrien * SUCH DAMAGE. 3221826Sjoerg * 3321826Sjoerg * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 3421826Sjoerg * $FreeBSD: head/include/stdlib.h 103164 2002-09-10 02:02:49Z wollman $ 3521826Sjoerg */ 3621826Sjoerg 3721826Sjoerg#ifndef _STDLIB_H_ 3821826Sjoerg#define _STDLIB_H_ 3921826Sjoerg 4093383Smdodd#include <sys/cdefs.h> 4132350Seivind#include <sys/_types.h> 4221826Sjoerg 4393383Smdodd#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 4493383Smdodd#ifndef _RUNE_T_DECLARED 4593383Smdoddtypedef __rune_t rune_t; 4693383Smdodd#define _RUNE_T_DECLARED 4793383Smdodd#endif 4821826Sjoerg#endif 4924204Sbde 5021826Sjoerg#ifndef _SIZE_T_DECLARED 5193383Smdoddtypedef __size_t size_t; 5293383Smdodd#define _SIZE_T_DECLARED 5393383Smdodd#endif 5493383Smdodd 5593383Smdodd#ifndef __cplusplus 5693383Smdodd#ifndef _WCHAR_T_DECLARED 5793383Smdoddtypedef __wchar_t wchar_t; 5821826Sjoerg#define _WCHAR_T_DECLARED 5993383Smdodd#endif 6021826Sjoerg#endif 6193383Smdodd 62147256Sbrookstypedef struct { 6393383Smdodd int quot; /* quotient */ 6421826Sjoerg int rem; /* remainder */ 6521826Sjoerg} div_t; 6621826Sjoerg 6793383Smdoddtypedef struct { 6893383Smdodd long quot; /* quotient */ 6921826Sjoerg long rem; /* remainder */ 7093383Smdodd} ldiv_t; 7121826Sjoerg 72199542Sjhb#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 73199542Sjhb#ifdef __LONG_LONG_SUPPORTED 7421826Sjoerg/* LONGLONG */ 75199542Sjhbtypedef struct { 7621826Sjoerg long long quot; 77199542Sjhb long long rem; 78199542Sjhb} lldiv_t; 79199542Sjhb#endif 80199542Sjhb#endif 81199542Sjhb 82199542Sjhb#ifndef NULL 83199542Sjhb#define NULL 0 84199542Sjhb#endif 85199542Sjhb 86199542Sjhb#define EXIT_FAILURE 1 87199542Sjhb#define EXIT_SUCCESS 0 88199542Sjhb 89147256Sbrooks#define RAND_MAX 0x7fffffff 90148887Srwatson 91147256Sbrooksextern int __mb_cur_max; 9221826Sjoerg#define MB_CUR_MAX __mb_cur_max 9321826Sjoerg 9421826Sjoerg__BEGIN_DECLS 9521826Sjoergvoid _Exit(int) __dead2; 96147256Sbrooksvoid abort(void) __dead2; 9721826Sjoergint abs(int) __pure2; 9821826Sjoergint atexit(void (*)(void)); 9921826Sjoergdouble atof(const char *); 10021826Sjoergint atoi(const char *); 10121826Sjoerglong atol(const char *); 10221826Sjoergvoid *bsearch(const void *, const void *, size_t, 103199542Sjhb size_t, int (*)(const void *, const void *)); 104199542Sjhbvoid *calloc(size_t, size_t); 105199542Sjhbdiv_t div(int, int) __pure2; 10621826Sjoergvoid exit(int) __dead2; 107199542Sjhbvoid free(void *); 108199542Sjhbchar *getenv(const char *); 109199542Sjhblong labs(long) __pure2; 110199542Sjhbldiv_t ldiv(long, long) __pure2; 111199542Sjhbvoid *malloc(size_t); 112199542Sjhbvoid qsort(void *, size_t, size_t, 113199542Sjhb int (*)(const void *, const void *)); 114199542Sjhbint rand(void); 115199542Sjhbvoid *realloc(void *, size_t); 116199542Sjhbvoid srand(unsigned); 117199542Sjhbdouble strtod(const char * __restrict, char ** __restrict); 11821826Sjoerglong strtol(const char * __restrict, char ** __restrict, int); 11993383Smdoddunsigned long 120199542Sjhb strtoul(const char * __restrict, char ** __restrict, int); 12121826Sjoergint system(const char *); 122199542Sjhb 123199542Sjhbint mblen(const char *, size_t); 124199542Sjhbsize_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t); 125199542Sjhbint wctomb(char *, wchar_t); 126199542Sjhbint mbtowc(wchar_t * __restrict, const char * __restrict, size_t); 127199542Sjhbsize_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); 128199542Sjhb 129199542Sjhb#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 130199542Sjhbextern const char *_malloc_options; 13121826Sjoergextern void (*_malloc_message)(const char *p1, const char *p2, const char *p3, const char *p4); 13221826Sjoerg 13321826Sjoergint putenv(const char *); 13421826Sjoergint setenv(const char *, const char *, int); 135199542Sjhb 136148887Srwatsondouble drand48(void); 13793383Smdodddouble erand48(unsigned short[3]); 13893383Smdoddlong jrand48(unsigned short[3]); 13993383Smdoddvoid lcong48(unsigned short[7]); 14093383Smdoddlong lrand48(void); 14193383Smdoddlong mrand48(void); 14293383Smdoddlong nrand48(unsigned short[3]); 14393383Smdoddunsigned short 14421826Sjoerg *seed48(unsigned short[3]); 14521826Sjoergvoid srand48(long); 14693383Smdodd 147199542Sjhbvoid *alloca(size_t); /* built-in for gcc */ 14821826Sjoerg /* getcap(3) functions */ 14993383Smdodd__uint32_t 15021826Sjoerg arc4random(void); 15121826Sjoergvoid arc4random_addrandom(unsigned char *dat, int datlen); 15221826Sjoergvoid arc4random_stir(void); 153199542Sjhb#ifdef __LONG_LONG_SUPPORTED 154148887Srwatson/* LONGLONG */ 15521826Sjoerglong long 15621826Sjoerg atoll(const char *); 157199542Sjhb#endif 158199542Sjhbchar *getbsize(int *, long *); 15921826Sjoergchar *cgetcap(char *, const char *, int); 16021826Sjoergint cgetclose(void); 161148887Srwatsonint cgetent(char **, char **, const char *); 16221826Sjoergint cgetfirst(char **, char **); 16321826Sjoergint cgetmatch(const char *, const char *); 16493383Smdoddint cgetnext(char **, char **); 16521826Sjoergint cgetnum(char *, const char *, long *); 16693383Smdoddint cgetset(const char *); 16721826Sjoergint cgetstr(char *, const char *, char **); 16821826Sjoergint cgetustr(char *, const char *, char **); 16993383Smdodd 17093383Smdoddint daemon(int, int); 17193383Smdoddchar *devname(int, int); 17293383Smdoddint getloadavg(double [], int); 17393383Smdodd__const char * 17493383Smdodd getprogname(void); 17593383Smdodd 17693383Smdoddint heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); 17793383Smdoddchar *initstate(unsigned long, char *, long); 17893383Smdodd#ifdef __LONG_LONG_SUPPORTED 17993383Smdodd/* LONGLONG */ 18093383Smdoddlong long 18193383Smdodd llabs(long long) __pure2; 18293383Smdoddlldiv_t lldiv(long long, long long) __pure2; 18393383Smdodd#endif 18493383Smdoddint mergesort(void *, size_t, size_t, int (*)(const void *, const void *)); 18593383Smdoddvoid qsort_r(void *, size_t, size_t, void *, 18693383Smdodd int (*)(void *, const void *, const void *)); 18793383Smdoddint radixsort(const unsigned char **, int, const unsigned char *, 18893383Smdodd unsigned); 18993383Smdoddint rand_r(unsigned *); 19093383Smdoddlong random(void); 19193383Smdoddvoid *reallocf(void *, size_t); 19293383Smdoddchar *realpath(const char *, char resolved_path[]); 19393383Smdoddvoid setprogname(const char *); 19493383Smdoddchar *setstate(char *); 19593383Smdoddint sradixsort(const unsigned char **, int, const unsigned char *, 19693383Smdodd unsigned); 19721826Sjoergvoid sranddev(void); 19893383Smdoddvoid srandom(unsigned long); 19921826Sjoergvoid srandomdev(void); 20021826Sjoerg#ifdef __LONG_LONG_SUPPORTED 20193383Smdodd/* LONGLONG */ 202148887Srwatsonlong long 20393383Smdodd strtoll(const char * __restrict, char ** __restrict, int); 20493383Smdodd#endif 20521826Sjoerg__int64_t strtoq(const char *, char **, int); 20621826Sjoerg#ifdef __LONG_LONG_SUPPORTED 20793383Smdodd/* LONGLONG */ 20821826Sjoergunsigned long long 209199542Sjhb strtoull(const char * __restrict, char ** __restrict, int); 210199542Sjhb#endif 211199542Sjhb__uint64_t 212199542Sjhb strtouq(const char *, char **, int); 213199542Sjhbvoid unsetenv(const char *); 214199542Sjhb#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 215199542Sjhb__END_DECLS 216199542Sjhb 217199542Sjhb#endif /* !_STDLIB_H_ */ 218199542Sjhb