stdlib.h revision 1539
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 * 331539Srgrimes * @(#)stdlib.h 8.3 (Berkeley) 2/16/94 341539Srgrimes */ 351539Srgrimes 361539Srgrimes#ifndef _STDLIB_H_ 371539Srgrimes#define _STDLIB_H_ 381539Srgrimes 391539Srgrimes#include <machine/ansi.h> 401539Srgrimes 411539Srgrimes#ifdef _BSD_SIZE_T_ 421539Srgrimestypedef _BSD_SIZE_T_ size_t; 431539Srgrimes#undef _BSD_SIZE_T_ 441539Srgrimes#endif 451539Srgrimes 461539Srgrimes#ifdef _BSD_WCHAR_T_ 471539Srgrimes#ifndef _ANSI_SOURCE 481539Srgrimestypedef _BSD_WCHAR_T_ rune_t; 491539Srgrimes#endif 501539Srgrimestypedef _BSD_WCHAR_T_ wchar_t; 511539Srgrimes#undef _BSD_WCHAR_T_ 521539Srgrimes#endif 531539Srgrimes 541539Srgrimestypedef struct { 551539Srgrimes int quot; /* quotient */ 561539Srgrimes int rem; /* remainder */ 571539Srgrimes} div_t; 581539Srgrimes 591539Srgrimestypedef struct { 601539Srgrimes long quot; /* quotient */ 611539Srgrimes long rem; /* remainder */ 621539Srgrimes} ldiv_t; 631539Srgrimes 641539Srgrimes#ifndef NULL 651539Srgrimes#define NULL 0 661539Srgrimes#endif 671539Srgrimes 681539Srgrimes#define EXIT_FAILURE 1 691539Srgrimes#define EXIT_SUCCESS 0 701539Srgrimes 711539Srgrimes#define RAND_MAX 0x7fffffff 721539Srgrimes 731539Srgrimesextern int __mb_cur_max; 741539Srgrimes#define MB_CUR_MAX __mb_cur_max 751539Srgrimes 761539Srgrimes#include <sys/cdefs.h> 771539Srgrimes 781539Srgrimes__BEGIN_DECLS 791539Srgrimes__dead void 801539Srgrimes abort __P((void)); 811539Srgrimes__pure int 821539Srgrimes abs __P((int)); 831539Srgrimesint atexit __P((void (*)(void))); 841539Srgrimesdouble atof __P((const char *)); 851539Srgrimesint atoi __P((const char *)); 861539Srgrimeslong atol __P((const char *)); 871539Srgrimesvoid *bsearch __P((const void *, const void *, size_t, 881539Srgrimes size_t, int (*)(const void *, const void *))); 891539Srgrimesvoid *calloc __P((size_t, size_t)); 901539Srgrimes__pure div_t 911539Srgrimes div __P((int, int)); 921539Srgrimes__dead void 931539Srgrimes exit __P((int)); 941539Srgrimesvoid free __P((void *)); 951539Srgrimeschar *getenv __P((const char *)); 961539Srgrimes__pure long 971539Srgrimes labs __P((long)); 981539Srgrimes__pure ldiv_t 991539Srgrimes ldiv __P((long, long)); 1001539Srgrimesvoid *malloc __P((size_t)); 1011539Srgrimesvoid qsort __P((void *, size_t, size_t, 1021539Srgrimes int (*)(const void *, const void *))); 1031539Srgrimesint rand __P((void)); 1041539Srgrimesvoid *realloc __P((void *, size_t)); 1051539Srgrimesvoid srand __P((unsigned)); 1061539Srgrimesdouble strtod __P((const char *, char **)); 1071539Srgrimeslong strtol __P((const char *, char **, int)); 1081539Srgrimesunsigned long 1091539Srgrimes strtoul __P((const char *, char **, int)); 1101539Srgrimesint system __P((const char *)); 1111539Srgrimes 1121539Srgrimes/* These are currently just stubs. */ 1131539Srgrimesint mblen __P((const char *, size_t)); 1141539Srgrimessize_t mbstowcs __P((wchar_t *, const char *, size_t)); 1151539Srgrimesint wctomb __P((char *, wchar_t)); 1161539Srgrimesint mbtowc __P((wchar_t *, const char *, size_t)); 1171539Srgrimessize_t wcstombs __P((char *, const wchar_t *, size_t)); 1181539Srgrimes 1191539Srgrimes#ifndef _ANSI_SOURCE 1201539Srgrimesint putenv __P((const char *)); 1211539Srgrimesint setenv __P((const char *, const char *, int)); 1221539Srgrimes#endif 1231539Srgrimes 1241539Srgrimes#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 1251539Srgrimesvoid *alloca __P((size_t)); /* built-in for gcc */ 1261539Srgrimes /* getcap(3) functions */ 1271539Srgrimeschar *getbsize __P((int *, long *)); 1281539Srgrimeschar *cgetcap __P((char *, char *, int)); 1291539Srgrimesint cgetclose __P((void)); 1301539Srgrimesint cgetent __P((char **, char **, char *)); 1311539Srgrimesint cgetfirst __P((char **, char **)); 1321539Srgrimesint cgetmatch __P((char *, char *)); 1331539Srgrimesint cgetnext __P((char **, char **)); 1341539Srgrimesint cgetnum __P((char *, char *, long *)); 1351539Srgrimesint cgetset __P((char *)); 1361539Srgrimesint cgetstr __P((char *, char *, char **)); 1371539Srgrimesint cgetustr __P((char *, char *, char **)); 1381539Srgrimes 1391539Srgrimesint daemon __P((int, int)); 1401539Srgrimeschar *devname __P((int, int)); 1411539Srgrimesint getloadavg __P((double [], int)); 1421539Srgrimes 1431539Srgrimesextern char *optarg; /* getopt(3) external variables */ 1441539Srgrimesextern int opterr, optind, optopt; 1451539Srgrimesint getopt __P((int, char * const *, const char *)); 1461539Srgrimes 1471539Srgrimesextern char *suboptarg; /* getsubopt(3) external variable */ 1481539Srgrimesint getsubopt __P((char **, char * const *, char **)); 1491539Srgrimes 1501539Srgrimeschar *group_from_gid __P((unsigned long, int)); 1511539Srgrimesint heapsort __P((void *, size_t, size_t, 1521539Srgrimes int (*)(const void *, const void *))); 1531539Srgrimeschar *initstate __P((unsigned, char *, int)); 1541539Srgrimesint mergesort __P((void *, size_t, size_t, 1551539Srgrimes int (*)(const void *, const void *))); 1561539Srgrimesint radixsort __P((const unsigned char **, int, const unsigned char *, 1571539Srgrimes unsigned)); 1581539Srgrimesint sradixsort __P((const unsigned char **, int, const unsigned char *, 1591539Srgrimes unsigned)); 1601539Srgrimeslong random __P((void)); 1611539Srgrimeschar *realpath __P((const char *, char resolved_path[])); 1621539Srgrimeschar *setstate __P((char *)); 1631539Srgrimesvoid srandom __P((unsigned)); 1641539Srgrimeschar *user_from_uid __P((unsigned long, int)); 1651539Srgrimes#ifndef __STRICT_ANSI__ 1661539Srgrimeslong long 1671539Srgrimes strtoq __P((const char *, char **, int)); 1681539Srgrimesunsigned long long 1691539Srgrimes strtouq __P((const char *, char **, int)); 1701539Srgrimes#endif 1711539Srgrimesvoid unsetenv __P((const char *)); 1721539Srgrimes#endif 1731539Srgrimes__END_DECLS 1741539Srgrimes 1751539Srgrimes#endif /* _STDLIB_H_ */ 176