stdlib.h revision 1.44
1/* $NetBSD: stdlib.h,v 1.44 2000/01/10 16:58:38 kleink Exp $ */ 2 3/*- 4 * Copyright (c) 1990, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by the University of 18 * California, Berkeley and its contributors. 19 * 4. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 36 */ 37 38#ifndef _STDLIB_H_ 39#define _STDLIB_H_ 40 41#include <sys/cdefs.h> 42#include <sys/featuretest.h> 43 44#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ 45 !defined(_XOPEN_SOURCE) 46#include <sys/types.h> /* for quad_t, etc. */ 47#endif 48 49#include <machine/ansi.h> 50 51#ifdef _BSD_SIZE_T_ 52typedef _BSD_SIZE_T_ size_t; 53#undef _BSD_SIZE_T_ 54#endif 55 56#ifdef _BSD_WCHAR_T_ 57typedef _BSD_WCHAR_T_ wchar_t; 58#undef _BSD_WCHAR_T_ 59#endif 60 61typedef struct { 62 int quot; /* quotient */ 63 int rem; /* remainder */ 64} div_t; 65 66typedef struct { 67 long quot; /* quotient */ 68 long rem; /* remainder */ 69} ldiv_t; 70 71#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ 72 !defined(_XOPEN_SOURCE) 73typedef struct { 74 quad_t quot; /* quotient */ 75 quad_t rem; /* remainder */ 76} qdiv_t; 77#endif 78 79 80#include <sys/null.h> 81 82#define EXIT_FAILURE 1 83#define EXIT_SUCCESS 0 84 85#define RAND_MAX 0x7fffffff 86 87#if 0 /* no wide char stuff (yet) */ 88extern int __mb_cur_max; 89#define MB_CUR_MAX __mb_cur_max 90#else 91#define MB_CUR_MAX 1 /* XXX */ 92#endif 93 94__BEGIN_DECLS 95__dead void abort __P((void)) __attribute__((__noreturn__)); 96__pure int abs __P((int)); 97int atexit __P((void (*)(void))); 98double atof __P((const char *)); 99int atoi __P((const char *)); 100long atol __P((const char *)); 101void *bsearch __P((const void *, const void *, size_t, 102 size_t, int (*)(const void *, const void *))); 103void *calloc __P((size_t, size_t)); 104div_t div __P((int, int)); 105__dead void exit __P((int)) __attribute__((__noreturn__)); 106void free __P((void *)); 107__aconst char *getenv __P((const char *)); 108__pure long 109 labs __P((long)); 110ldiv_t ldiv __P((long, long)); 111void *malloc __P((size_t)); 112void qsort __P((void *, size_t, size_t, 113 int (*)(const void *, const void *))); 114int rand __P((void)); 115void *realloc __P((void *, size_t)); 116void srand __P((unsigned)); 117double strtod __P((const char *, char **)); 118long strtol __P((const char *, char **, int)); 119unsigned long 120 strtoul __P((const char *, char **, int)); 121int system __P((const char *)); 122 123/* These are currently just stubs. */ 124int mblen __P((const char *, size_t)); 125size_t mbstowcs __P((wchar_t *, const char *, size_t)); 126int wctomb __P((char *, wchar_t)); 127int mbtowc __P((wchar_t *, const char *, size_t)); 128size_t wcstombs __P((char *, const wchar_t *, size_t)); 129 130#if !defined(_ANSI_SOURCE) 131 132 133/* 134 * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2 135 */ 136#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \ 137 (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ 138 defined(_REENTRANT) 139int rand_r __P((unsigned int *)); 140#endif 141 142 143/* 144 * X/Open Portability Guide >= Issue 4 145 */ 146#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \ 147 (_XOPEN_SOURCE - 0) >= 4 148double drand48 __P((void)); 149double erand48 __P((unsigned short[3])); 150long jrand48 __P((unsigned short[3])); 151void lcong48 __P((unsigned short[7])); 152long lrand48 __P((void)); 153long mrand48 __P((void)); 154long nrand48 __P((unsigned short[3])); 155unsigned short * 156 seed48 __P((unsigned short[3])); 157void srand48 __P((long)); 158 159int putenv __P((const char *)); 160#endif 161 162 163/* 164 * X/Open Portability Guide >= Issue 4 Version 2 165 */ 166#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \ 167 (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ 168 (_XOPEN_SOURCE - 0) >= 500 169long a64l __P((const char *)); 170char *l64a __P((long)); 171 172char *initstate __P((unsigned long, char *, size_t)); 173long random __P((void)); 174char *setstate __P((char *)); 175void srandom __P((unsigned long)); 176 177char *mkdtemp __P((char *)); 178int mkstemp __P((char *)); 179#ifndef __AUDIT__ 180char *mktemp __P((char *)); 181#endif 182 183int setkey __P((const char *)); 184 185char *realpath __P((const char *, char *)); 186 187int ttyslot __P((void)); 188 189void *valloc __P((size_t)); /* obsoleted by malloc() */ 190#endif 191 192 193/* 194 * Implementation-defined extensions 195 */ 196#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 197#if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2) 198void *alloca __P((int)); /* built-in for gcc */ 199#else 200void *alloca __P((size_t)); 201#endif /* __GNUC__ */ 202 203char *getbsize __P((int *, long *)); 204char *cgetcap __P((char *, const char *, int)); 205int cgetclose __P((void)); 206int cgetent __P((char **, char **, const char *)); 207int cgetfirst __P((char **, char **)); 208int cgetmatch __P((const char *, const char *)); 209int cgetnext __P((char **, char **)); 210int cgetnum __P((char *, const char *, long *)); 211int cgetset __P((const char *)); 212int cgetstr __P((char *, const char *, char **)); 213int cgetustr __P((char *, const char *, char **)); 214 215int daemon __P((int, int)); 216__aconst char *devname __P((dev_t, mode_t)); 217int getloadavg __P((double [], int)); 218 219void cfree __P((void *)); 220 221int heapsort __P((void *, size_t, size_t, 222 int (*)(const void *, const void *))); 223int mergesort __P((void *, size_t, size_t, 224 int (*)(const void *, const void *))); 225int radixsort __P((const unsigned char **, int, const unsigned char *, 226 unsigned)); 227int sradixsort __P((const unsigned char **, int, const unsigned char *, 228 unsigned)); 229 230int setenv __P((const char *, const char *, int)); 231void unsetenv __P((const char *)); 232void setproctitle __P((const char *, ...)); 233 234quad_t qabs __P((quad_t)); 235qdiv_t qdiv __P((quad_t, quad_t)); 236quad_t strtoq __P((const char *, char **, int)); 237u_quad_t strtouq __P((const char *, char **, int)); 238 239int l64a_r __P((long, char *, int)); 240#endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */ 241#endif /* !_ANSI_SOURCE */ 242__END_DECLS 243 244#endif /* !_STDLIB_H_ */ 245