stdlib.h revision 41927
11539Srgrimes/*- 21539Srgrimes * Copyright (c) 1990, 1993 31539Srgrimes * The Regents of the University of California. All rights reserved. 41539Srgrimes * 51539Srgrimes * Redistribution and use in source and binary forms, with or without 61539Srgrimes * modification, are permitted provided that the following conditions 71539Srgrimes * are met: 81539Srgrimes * 1. Redistributions of source code must retain the above copyright 91539Srgrimes * notice, this list of conditions and the following disclaimer. 101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111539Srgrimes * notice, this list of conditions and the following disclaimer in the 121539Srgrimes * documentation and/or other materials provided with the distribution. 131539Srgrimes * 3. All advertising materials mentioning features or use of this software 141539Srgrimes * must display the following acknowledgement: 151539Srgrimes * This product includes software developed by the University of 161539Srgrimes * California, Berkeley and its contributors. 171539Srgrimes * 4. Neither the name of the University nor the names of its contributors 181539Srgrimes * may be used to endorse or promote products derived from this software 191539Srgrimes * without specific prior written permission. 201539Srgrimes * 211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311539Srgrimes * SUCH DAMAGE. 321539Srgrimes * 3323657Speter * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 341539Srgrimes */ 351539Srgrimes 361539Srgrimes#ifndef _STDLIB_H_ 377865Sbde#define _STDLIB_H_ 381539Srgrimes 3933861Sbde#include <sys/cdefs.h> 4033861Sbde 411539Srgrimes#include <machine/ansi.h> 4226636Sache 4326636Sache#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 4415483Sbde#ifdef _BSD_RUNE_T_ 4515483Sbdetypedef _BSD_RUNE_T_ rune_t; 4615483Sbde#undef _BSD_RUNE_T_ 4715483Sbde#endif 4815483Sbde#endif 4915483Sbde 501539Srgrimes#ifdef _BSD_SIZE_T_ 511539Srgrimestypedef _BSD_SIZE_T_ size_t; 521539Srgrimes#undef _BSD_SIZE_T_ 531539Srgrimes#endif 541539Srgrimes 551539Srgrimes#ifdef _BSD_WCHAR_T_ 561539Srgrimestypedef _BSD_WCHAR_T_ wchar_t; 571539Srgrimes#undef _BSD_WCHAR_T_ 581539Srgrimes#endif 591539Srgrimes 601539Srgrimestypedef struct { 611539Srgrimes int quot; /* quotient */ 621539Srgrimes int rem; /* remainder */ 631539Srgrimes} div_t; 641539Srgrimes 651539Srgrimestypedef struct { 661539Srgrimes long quot; /* quotient */ 671539Srgrimes long rem; /* remainder */ 681539Srgrimes} ldiv_t; 691539Srgrimes 701539Srgrimes#ifndef NULL 711539Srgrimes#define NULL 0 721539Srgrimes#endif 731539Srgrimes 741539Srgrimes#define EXIT_FAILURE 1 751539Srgrimes#define EXIT_SUCCESS 0 761539Srgrimes 771539Srgrimes#define RAND_MAX 0x7fffffff 781539Srgrimes 791539Srgrimesextern int __mb_cur_max; 801539Srgrimes#define MB_CUR_MAX __mb_cur_max 811539Srgrimes 821539Srgrimes__BEGIN_DECLS 8318286Sbdevoid abort __P((void)) __dead2; 8418286Sbdeint abs __P((int)) __pure2; 851539Srgrimesint atexit __P((void (*)(void))); 861539Srgrimesdouble atof __P((const char *)); 871539Srgrimesint atoi __P((const char *)); 881539Srgrimeslong atol __P((const char *)); 891539Srgrimesvoid *bsearch __P((const void *, const void *, size_t, 901539Srgrimes size_t, int (*)(const void *, const void *))); 911539Srgrimesvoid *calloc __P((size_t, size_t)); 9218286Sbdediv_t div __P((int, int)) __pure2; 9318286Sbdevoid exit __P((int)) __dead2; 941539Srgrimesvoid free __P((void *)); 951539Srgrimeschar *getenv __P((const char *)); 9618286Sbdelong labs __P((long)) __pure2; 9718286Sbdeldiv_t ldiv __P((long, long)) __pure2; 981539Srgrimesvoid *malloc __P((size_t)); 991539Srgrimesvoid qsort __P((void *, size_t, size_t, 1001539Srgrimes int (*)(const void *, const void *))); 1011539Srgrimesint rand __P((void)); 1021539Srgrimesvoid *realloc __P((void *, size_t)); 1031539Srgrimesvoid srand __P((unsigned)); 1041539Srgrimesdouble strtod __P((const char *, char **)); 1051539Srgrimeslong strtol __P((const char *, char **, int)); 1061539Srgrimesunsigned long 1071539Srgrimes strtoul __P((const char *, char **, int)); 1081539Srgrimesint system __P((const char *)); 1091539Srgrimes 1101539Srgrimesint mblen __P((const char *, size_t)); 1111539Srgrimessize_t mbstowcs __P((wchar_t *, const char *, size_t)); 1121539Srgrimesint wctomb __P((char *, wchar_t)); 1131539Srgrimesint mbtowc __P((wchar_t *, const char *, size_t)); 1141539Srgrimessize_t wcstombs __P((char *, const wchar_t *, size_t)); 1151539Srgrimes 1167865Sbde#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 1171539Srgrimesint putenv __P((const char *)); 1181539Srgrimesint setenv __P((const char *, const char *, int)); 1191539Srgrimes 1207865Sbdedouble drand48 __P((void)); 1217865Sbdedouble erand48 __P((unsigned short[3])); 1227865Sbdelong jrand48 __P((unsigned short[3])); 1237865Sbdevoid lcong48 __P((unsigned short[7])); 1247865Sbdelong lrand48 __P((void)); 1257865Sbdelong mrand48 __P((void)); 1267865Sbdelong nrand48 __P((unsigned short[3])); 1277865Sbdeunsigned short 1287865Sbde *seed48 __P((unsigned short[3])); 1297865Sbdevoid srand48 __P((long)); 1304749Sats 1311539Srgrimesvoid *alloca __P((size_t)); /* built-in for gcc */ 1321539Srgrimes /* getcap(3) functions */ 13341927Sdt__uint32_t 13426630Sache arc4random __P((void)); 13526636Sachevoid arc4random_addrandom __P((unsigned char *dat, int datlen)); 13626630Sachevoid arc4random_stir __P((void)); 1371539Srgrimeschar *getbsize __P((int *, long *)); 1381539Srgrimeschar *cgetcap __P((char *, char *, int)); 1391539Srgrimesint cgetclose __P((void)); 1401539Srgrimesint cgetent __P((char **, char **, char *)); 1411539Srgrimesint cgetfirst __P((char **, char **)); 1421539Srgrimesint cgetmatch __P((char *, char *)); 1431539Srgrimesint cgetnext __P((char **, char **)); 1441539Srgrimesint cgetnum __P((char *, char *, long *)); 1451539Srgrimesint cgetset __P((char *)); 1461539Srgrimesint cgetstr __P((char *, char *, char **)); 1471539Srgrimesint cgetustr __P((char *, char *, char **)); 1481539Srgrimes 1491539Srgrimesint daemon __P((int, int)); 1501539Srgrimeschar *devname __P((int, int)); 1511539Srgrimesint getloadavg __P((double [], int)); 1521539Srgrimes 1531539Srgrimeschar *group_from_gid __P((unsigned long, int)); 1541539Srgrimesint heapsort __P((void *, size_t, size_t, 1551539Srgrimes int (*)(const void *, const void *))); 15623657Speterchar *initstate __P((unsigned long, char *, long)); 1571539Srgrimesint mergesort __P((void *, size_t, size_t, 1581539Srgrimes int (*)(const void *, const void *))); 1591539Srgrimesint radixsort __P((const unsigned char **, int, const unsigned char *, 1601539Srgrimes unsigned)); 1611539Srgrimesint sradixsort __P((const unsigned char **, int, const unsigned char *, 1621539Srgrimes unsigned)); 1631539Srgrimeslong random __P((void)); 16439191Simpvoid *reallocf __P((void *, size_t)); 1651539Srgrimeschar *realpath __P((const char *, char resolved_path[])); 1661539Srgrimeschar *setstate __P((char *)); 16723657Spetervoid srandom __P((unsigned long)); 16826624Sachevoid srandomdev __P((void)); 1691539Srgrimeschar *user_from_uid __P((unsigned long, int)); 1701539Srgrimes#ifndef __STRICT_ANSI__ 17141927Sdt__int64_t strtoq __P((const char *, char **, int)); 17241927Sdt__uint64_t 1731539Srgrimes strtouq __P((const char *, char **, int)); 1741539Srgrimes#endif 1751539Srgrimesvoid unsetenv __P((const char *)); 1767865Sbde#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 1771539Srgrimes__END_DECLS 1781539Srgrimes 1797865Sbde#endif /* !_STDLIB_H_ */ 180