stdlib.h revision 101912
156043Syokota/*- 256043Syokota * Copyright (c) 1990, 1993 356043Syokota * The Regents of the University of California. All rights reserved. 456043Syokota * 556043Syokota * Redistribution and use in source and binary forms, with or without 656043Syokota * modification, are permitted provided that the following conditions 756043Syokota * are met: 856043Syokota * 1. Redistributions of source code must retain the above copyright 956043Syokota * notice, this list of conditions and the following disclaimer. 1056043Syokota * 2. Redistributions in binary form must reproduce the above copyright 1156043Syokota * notice, this list of conditions and the following disclaimer in the 1256043Syokota * documentation and/or other materials provided with the distribution. 1356043Syokota * 3. All advertising materials mentioning features or use of this software 1456043Syokota * must display the following acknowledgement: 1556043Syokota * This product includes software developed by the University of 1656043Syokota * California, Berkeley and its contributors. 1756043Syokota * 4. Neither the name of the University nor the names of its contributors 1856043Syokota * may be used to endorse or promote products derived from this software 1956043Syokota * without specific prior written permission. 2056043Syokota * 2156043Syokota * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2256043Syokota * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2356043Syokota * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2456043Syokota * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2556043Syokota * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2656043Syokota * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2756043Syokota * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2856043Syokota * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2956043Syokota * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3056043Syokota * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3156043Syokota * SUCH DAMAGE. 3256043Syokota * 3356043Syokota * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 3456043Syokota * $FreeBSD: head/include/stdlib.h 101912 2002-08-15 09:25:04Z robert $ 3556043Syokota */ 3656043Syokota 3756043Syokota#ifndef _STDLIB_H_ 3856043Syokota#define _STDLIB_H_ 3956043Syokota 4056043Syokota#include <sys/cdefs.h> 4156043Syokota 4256043Syokota#include <machine/ansi.h> 4356043Syokota 4456043Syokota#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 4556043Syokota#ifdef _BSD_RUNE_T_ 4656043Syokotatypedef _BSD_RUNE_T_ rune_t; 4756043Syokota#undef _BSD_RUNE_T_ 4856043Syokota#endif 4956043Syokota#endif 5056043Syokota 5156043Syokota#ifdef _BSD_SIZE_T_ 5256043Syokotatypedef _BSD_SIZE_T_ size_t; 5356043Syokota#undef _BSD_SIZE_T_ 5456043Syokota#endif 5556043Syokota 5656043Syokota#ifndef __cplusplus 5756043Syokota#ifdef _BSD_WCHAR_T_ 5856043Syokotatypedef _BSD_WCHAR_T_ wchar_t; 5956043Syokota#undef _BSD_WCHAR_T_ 6056043Syokota#endif 6156043Syokota#endif 6256043Syokota 6356043Syokotatypedef struct { 6456043Syokota int quot; /* quotient */ 6556043Syokota int rem; /* remainder */ 6656043Syokota} div_t; 6756043Syokota 6856043Syokotatypedef struct { 6956043Syokota long quot; /* quotient */ 7056043Syokota long rem; /* remainder */ 7156043Syokota} ldiv_t; 7256043Syokota 7356043Syokota#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 7456043Syokota#ifdef __LONG_LONG_SUPPORTED 7556043Syokota/* LONGLONG */ 7656043Syokotatypedef struct { 7756043Syokota long long quot; 7856043Syokota long long rem; 7956043Syokota} lldiv_t; 8056043Syokota#endif 8156043Syokota#endif 8256043Syokota 8356043Syokota#ifndef NULL 8456043Syokota#define NULL 0 8556043Syokota#endif 8656043Syokota 8756043Syokota#define EXIT_FAILURE 1 8856043Syokota#define EXIT_SUCCESS 0 8956043Syokota 9056043Syokota#define RAND_MAX 0x7fffffff 9156043Syokota 9256043Syokotaextern int __mb_cur_max; 9356043Syokota#define MB_CUR_MAX __mb_cur_max 9456043Syokota 9556043Syokota__BEGIN_DECLS 9656043Syokotavoid abort(void) __dead2; 9756043Syokotaint abs(int) __pure2; 9856043Syokotaint atexit(void (*)(void)); 9956043Syokotadouble atof(const char *); 10056043Syokotaint atoi(const char *); 10156043Syokotalong atol(const char *); 10256043Syokotavoid *bsearch(const void *, const void *, size_t, 10356043Syokota size_t, int (*)(const void *, const void *)); 10456043Syokotavoid *calloc(size_t, size_t); 10556043Syokotadiv_t div(int, int) __pure2; 10656043Syokotavoid exit(int) __dead2; 10756043Syokotavoid free(void *); 10856043Syokotachar *getenv(const char *); 10956043Syokotalong labs(long) __pure2; 11056043Syokotaldiv_t ldiv(long, long) __pure2; 11156043Syokotavoid *malloc(size_t); 11256043Syokotavoid qsort(void *, size_t, size_t, 11356043Syokota int (*)(const void *, const void *)); 11456043Syokotaint rand(void); 11556043Syokotavoid *realloc(void *, size_t); 11656043Syokotavoid srand(unsigned); 11756043Syokotadouble strtod(const char *__restrict, char **__restrict); 11856043Syokotalong strtol(const char *__restrict, char **__restrict, int); 11956043Syokotaunsigned long 12056043Syokota strtoul(const char *__restrict, char **__restrict, int); 12156043Syokotaint system(const char *); 12256043Syokota 12356043Syokotaint mblen(const char *, size_t); 12456043Syokotasize_t mbstowcs(wchar_t *, const char *, size_t); 12556043Syokotaint wctomb(char *, wchar_t); 12656043Syokotaint mbtowc(wchar_t *, const char *, size_t); 12756043Syokotasize_t wcstombs(char *, const wchar_t *, size_t); 12856043Syokota 12956043Syokota#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 13056043Syokotaextern const char *_malloc_options; 13156043Syokotaextern void (*_malloc_message)(const char *p1, const char *p2, const char *p3, const char *p4); 13256043Syokota 13356043Syokotaint putenv(const char *); 13456043Syokotaint setenv(const char *, const char *, int); 13556043Syokota 13656043Syokotadouble drand48(void); 13756043Syokotadouble erand48(unsigned short[3]); 13856043Syokotalong jrand48(unsigned short[3]); 13956043Syokotavoid lcong48(unsigned short[7]); 14056043Syokotalong lrand48(void); 14156043Syokotalong mrand48(void); 14256043Syokotalong nrand48(unsigned short[3]); 14356043Syokotaunsigned short 14456043Syokota *seed48(unsigned short[3]); 14556043Syokotavoid srand48(long); 14656043Syokota 14756043Syokotavoid *alloca(size_t); /* built-in for gcc */ 14856043Syokota /* getcap(3) functions */ 14956043Syokota__uint32_t 15056043Syokota arc4random(void); 15156043Syokotavoid arc4random_addrandom(unsigned char *dat, int datlen); 15256043Syokotavoid arc4random_stir(void); 15356043Syokota#ifdef __LONG_LONG_SUPPORTED 15456043Syokota/* LONGLONG */ 15556043Syokotalong long 15656043Syokota atoll(const char *); 15756043Syokota#endif 15856043Syokotachar *getbsize(int *, long *); 15956043Syokotachar *cgetcap(char *, const char *, int); 16056043Syokotaint cgetclose(void); 16156043Syokotaint cgetent(char **, char **, const char *); 16256043Syokotaint cgetfirst(char **, char **); 16356043Syokotaint cgetmatch(const char *, const char *); 16456043Syokotaint cgetnext(char **, char **); 16556043Syokotaint cgetnum(char *, const char *, long *); 16656043Syokotaint cgetset(const char *); 16756043Syokotaint cgetstr(char *, const char *, char **); 16856043Syokotaint cgetustr(char *, const char *, char **); 16956043Syokota 17056043Syokotaint daemon(int, int); 17156043Syokotachar *devname(int, int); 17256043Syokotaint getloadavg(double [], int); 17356043Syokota__const char * 17456043Syokota getprogname(void); 17556043Syokota 17656043Syokotaint heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); 17756043Syokotachar *initstate(unsigned long, char *, long); 17856043Syokota#ifdef __LONG_LONG_SUPPORTED 17956043Syokota/* LONGLONG */ 18056043Syokotalong long 18156043Syokota llabs(long long) __pure2; 18256043Syokotalldiv_t lldiv(long long, long long) __pure2; 18356043Syokota#endif 18456043Syokotaint mergesort(void *, size_t, size_t, int (*)(const void *, const void *)); 18556043Syokotaint radixsort(const unsigned char **, int, const unsigned char *, 18656043Syokota unsigned); 18756043Syokotaint sradixsort(const unsigned char **, int, const unsigned char *, 18856043Syokota unsigned); 18956043Syokotaint rand_r(unsigned *); 19056043Syokotalong random(void); 19156043Syokotavoid *reallocf(void *, size_t); 19256043Syokotachar *realpath(const char *, char resolved_path[]); 19356043Syokotavoid setprogname(const char *); 19456043Syokotachar *setstate(char *); 19556043Syokotavoid sranddev(void); 19656043Syokotavoid srandom(unsigned long); 19756043Syokotavoid srandomdev(void); 19856043Syokota#ifdef __LONG_LONG_SUPPORTED 19956043Syokota/* LONGLONG */ 20056043Syokotalong long 20156043Syokota strtoll(const char *__restrict, char **__restrict, int); 20256043Syokota#endif 20356043Syokota__int64_t strtoq(const char *, char **, int); 20456043Syokota#ifdef __LONG_LONG_SUPPORTED 20556043Syokota/* LONGLONG */ 20656043Syokotaunsigned long long 20756043Syokota strtoull(const char *__restrict, char **__restrict, int); 20856043Syokota#endif 20956043Syokota__uint64_t 21056043Syokota strtouq(const char *, char **, int); 21156043Syokotavoid unsetenv(const char *); 21256043Syokota#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 21356043Syokota__END_DECLS 21456043Syokota 21556043Syokota#endif /* !_STDLIB_H_ */ 21656043Syokota