stdlib.h revision 88399
1183840Sraj/*- 2183840Sraj * Copyright (c) 1990, 1993 3183840Sraj * The Regents of the University of California. All rights reserved. 4183840Sraj * 5183840Sraj * Redistribution and use in source and binary forms, with or without 6183840Sraj * modification, are permitted provided that the following conditions 7183840Sraj * are met: 8183840Sraj * 1. Redistributions of source code must retain the above copyright 9183840Sraj * notice, this list of conditions and the following disclaimer. 10183840Sraj * 2. Redistributions in binary form must reproduce the above copyright 11183840Sraj * notice, this list of conditions and the following disclaimer in the 12183840Sraj * documentation and/or other materials provided with the distribution. 13183840Sraj * 3. All advertising materials mentioning features or use of this software 14183840Sraj * must display the following acknowledgement: 15183840Sraj * This product includes software developed by the University of 16183840Sraj * California, Berkeley and its contributors. 17183840Sraj * 4. Neither the name of the University nor the names of its contributors 18183840Sraj * may be used to endorse or promote products derived from this software 19183840Sraj * without specific prior written permission. 20183840Sraj * 21183840Sraj * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22183840Sraj * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23183840Sraj * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24183840Sraj * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25183840Sraj * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26183840Sraj * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27183840Sraj * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28183840Sraj * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29183840Sraj * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30183840Sraj * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31183840Sraj * SUCH DAMAGE. 32183840Sraj * 33183840Sraj * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 34183840Sraj * $FreeBSD: head/include/stdlib.h 88399 2001-12-22 05:18:37Z mike $ 35183840Sraj */ 36183840Sraj 37183840Sraj#ifndef _STDLIB_H_ 38183840Sraj#define _STDLIB_H_ 39183840Sraj 40183840Sraj#include <sys/cdefs.h> 41183840Sraj 42183840Sraj#include <machine/ansi.h> 43194072Smarcel 44183840Sraj#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 45186909Sraj#ifdef _BSD_RUNE_T_ 46183840Srajtypedef _BSD_RUNE_T_ rune_t; 47183840Sraj#undef _BSD_RUNE_T_ 48183840Sraj#endif 49183840Sraj#endif 50183840Sraj 51183840Sraj#ifdef _BSD_SIZE_T_ 52183840Srajtypedef _BSD_SIZE_T_ size_t; 53183840Sraj#undef _BSD_SIZE_T_ 54183840Sraj#endif 55183840Sraj 56183840Sraj#ifdef _BSD_WCHAR_T_ 57186909Srajtypedef _BSD_WCHAR_T_ wchar_t; 58209131Sraj#undef _BSD_WCHAR_T_ 59186909Sraj#endif 60186909Sraj 61209131Srajtypedef struct { 62186909Sraj int quot; /* quotient */ 63186899Sraj int rem; /* remainder */ 64186899Sraj} div_t; 65186899Sraj 66186899Srajtypedef struct { 67186899Sraj long quot; /* quotient */ 68186899Sraj long rem; /* remainder */ 69186899Sraj} ldiv_t; 70186899Sraj 71204764Sraj#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 72186899Sraj#ifdef __LONG_LONG_SUPPORTED 73186899Srajtypedef struct { 74186899Sraj long long quot; 75204764Sraj long long rem; 76186899Sraj} lldiv_t; 77238873Shrs#endif 78238873Shrs#endif 79186899Sraj 80186899Sraj#ifndef NULL 81186899Sraj#define NULL 0 82#endif 83 84#define EXIT_FAILURE 1 85#define EXIT_SUCCESS 0 86 87#define RAND_MAX 0x7fffffff 88 89extern int __mb_cur_max; 90#define MB_CUR_MAX __mb_cur_max 91 92__BEGIN_DECLS 93void abort __P((void)) __dead2; 94int abs __P((int)) __pure2; 95int atexit __P((void (*)(void))); 96double atof __P((const char *)); 97int atoi __P((const char *)); 98long atol __P((const char *)); 99void *bsearch __P((const void *, const void *, size_t, 100 size_t, int (*)(const void *, const void *))); 101void *calloc __P((size_t, size_t)); 102div_t div __P((int, int)) __pure2; 103void exit __P((int)) __dead2; 104void free __P((void *)); 105char *getenv __P((const char *)); 106long labs __P((long)) __pure2; 107ldiv_t ldiv __P((long, long)) __pure2; 108void *malloc __P((size_t)); 109void qsort __P((void *, size_t, size_t, 110 int (*)(const void *, const void *))); 111int rand __P((void)); 112void *realloc __P((void *, size_t)); 113void srand __P((unsigned)); 114double strtod __P((const char *, char **)); 115long strtol __P((const char *, char **, int)); 116unsigned long 117 strtoul __P((const char *, char **, int)); 118int system __P((const char *)); 119 120int mblen __P((const char *, size_t)); 121size_t mbstowcs __P((wchar_t *, const char *, size_t)); 122int wctomb __P((char *, wchar_t)); 123int mbtowc __P((wchar_t *, const char *, size_t)); 124size_t wcstombs __P((char *, const wchar_t *, size_t)); 125 126#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 127extern char *_malloc_options; 128extern void (*_malloc_message)__P((char *p1, char *p2, char *p3, char *p4)); 129 130int putenv __P((const char *)); 131int setenv __P((const char *, const char *, int)); 132 133double drand48 __P((void)); 134double erand48 __P((unsigned short[3])); 135long jrand48 __P((unsigned short[3])); 136void lcong48 __P((unsigned short[7])); 137long lrand48 __P((void)); 138long mrand48 __P((void)); 139long nrand48 __P((unsigned short[3])); 140unsigned short 141 *seed48 __P((unsigned short[3])); 142void srand48 __P((long)); 143 144void *alloca __P((size_t)); /* built-in for gcc */ 145 /* getcap(3) functions */ 146__uint32_t 147 arc4random __P((void)); 148void arc4random_addrandom __P((unsigned char *dat, int datlen)); 149void arc4random_stir __P((void)); 150#ifdef __LONG_LONG_SUPPORTED 151long long 152 atoll __P((const char *)); 153#endif 154char *getbsize __P((int *, long *)); 155char *cgetcap __P((char *, char *, int)); 156int cgetclose __P((void)); 157int cgetent __P((char **, char **, char *)); 158int cgetfirst __P((char **, char **)); 159int cgetmatch __P((char *, char *)); 160int cgetnext __P((char **, char **)); 161int cgetnum __P((char *, char *, long *)); 162int cgetset __P((char *)); 163int cgetstr __P((char *, char *, char **)); 164int cgetustr __P((char *, char *, char **)); 165 166int daemon __P((int, int)); 167char *devname __P((int, int)); 168int getloadavg __P((double [], int)); 169__const char * 170 getprogname __P((void)); 171 172char *group_from_gid __P((unsigned long, int)); 173int heapsort __P((void *, size_t, size_t, 174 int (*)(const void *, const void *))); 175char *initstate __P((unsigned long, char *, long)); 176#ifdef __LONG_LONG_SUPPORTED 177long long 178 llabs __P((long long)) __pure2; 179lldiv_t lldiv __P((long long, long long)) __pure2; 180#endif 181int mergesort __P((void *, size_t, size_t, 182 int (*)(const void *, const void *))); 183int radixsort __P((const unsigned char **, int, const unsigned char *, 184 unsigned)); 185int sradixsort __P((const unsigned char **, int, const unsigned char *, 186 unsigned)); 187int rand_r __P((unsigned *)); 188long random __P((void)); 189void *reallocf __P((void *, size_t)); 190char *realpath __P((const char *, char resolved_path[])); 191void setprogname __P((const char *)); 192char *setstate __P((char *)); 193void sranddev __P((void)); 194void srandom __P((unsigned long)); 195void srandomdev __P((void)); 196#ifdef __LONG_LONG_SUPPORTED 197long long 198 strtoll __P((const char *, char **, int)); 199#endif 200__int64_t strtoq __P((const char *, char **, int)); 201#ifdef __LONG_LONG_SUPPORTED 202unsigned long long 203 strtoull __P((const char *, char **, int)); 204#endif 205__uint64_t 206 strtouq __P((const char *, char **, int)); 207void unsetenv __P((const char *)); 208char *user_from_uid __P((unsigned long, int)); 209#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 210__END_DECLS 211 212#endif /* !_STDLIB_H_ */ 213