stdlib.h revision 1.25
1/* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ 2 3/*- 4 * Copyright (c) 1990 The Regents of the University of California. 5 * 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 5.13 (Berkeley) 6/4/91 36 */ 37 38#ifndef _STDLIB_H_ 39#define _STDLIB_H_ 40#include <machine/ansi.h> 41 42#if !defined(_ANSI_SOURCE) /* for quad_t, etc. */ 43#include <sys/types.h> 44#endif 45 46#ifdef _BSD_SIZE_T_ 47typedef _BSD_SIZE_T_ size_t; 48#undef _BSD_SIZE_T_ 49#endif 50 51#ifdef _BSD_WCHAR_T_ 52typedef _BSD_WCHAR_T_ wchar_t; 53#undef _BSD_WCHAR_T_ 54#endif 55 56typedef struct { 57 int quot; /* quotient */ 58 int rem; /* remainder */ 59} div_t; 60 61typedef struct { 62 long quot; /* quotient */ 63 long rem; /* remainder */ 64} ldiv_t; 65 66#if !defined(_ANSI_SOURCE) 67typedef struct { 68 quad_t quot; /* quotient */ 69 quad_t rem; /* remainder */ 70} qdiv_t; 71#endif 72 73 74#ifndef NULL 75#define NULL 0 76#endif 77 78#define EXIT_FAILURE 1 79#define EXIT_SUCCESS 0 80 81#define RAND_MAX 0x7fffffff 82 83#define MB_CUR_MAX 1 /* XXX */ 84 85#include <sys/cdefs.h> 86 87__BEGIN_DECLS 88__dead void abort __P((void)); 89int abs __P((int)); 90int atexit __P((void (*)(void))); 91double atof __P((const char *)); 92int atoi __P((const char *)); 93long atol __P((const char *)); 94void *bsearch __P((const void *, const void *, size_t, 95 size_t, int (*)(const void *, const void *))); 96void *calloc __P((size_t, size_t)); 97div_t div __P((int, int)); 98__dead void exit __P((int)); 99void free __P((void *)); 100char *getenv __P((const char *)); 101long labs __P((long)); 102ldiv_t ldiv __P((long, long)); 103void *malloc __P((size_t)); 104void qsort __P((void *, size_t, size_t, 105 int (*)(const void *, const void *))); 106int rand __P((void)); 107void *realloc __P((void *, size_t)); 108void srand __P((unsigned)); 109double strtod __P((const char *, char **)); 110long strtol __P((const char *, char **, int)); 111unsigned long 112 strtoul __P((const char *, char **, int)); 113int system __P((const char *)); 114 115/* these are currently just stubs */ 116int mblen __P((const char *, size_t)); 117size_t mbstowcs __P((wchar_t *, const char *, size_t)); 118int wctomb __P((char *, wchar_t)); 119int mbtowc __P((wchar_t *, const char *, size_t)); 120size_t wcstombs __P((char *, const wchar_t *, size_t)); 121 122#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 123#if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2) 124void *alloca __P((int)); /* built-in for gcc */ 125#else 126void *alloca __P((size_t)); 127#endif /* __GNUC__ */ 128 129char *getbsize __P((int *, long *)); 130char *cgetcap __P((char *, char *, int)); 131int cgetclose __P((void)); 132int cgetent __P((char **, char **, char *)); 133int cgetfirst __P((char **, char **)); 134int cgetmatch __P((char *, char *)); 135int cgetnext __P((char **, char **)); 136int cgetnum __P((char *, char *, long *)); 137int cgetset __P((char *)); 138int cgetstr __P((char *, char *, char **)); 139int cgetustr __P((char *, char *, char **)); 140 141int daemon __P((int, int)); 142char *devname __P((int, int)); 143int getloadavg __P((double [], int)); 144 145long a64l __P((const char *)); 146char *l64a __P((long)); 147 148void cfree __P((void *)); 149 150int getopt __P((int, char * const *, const char *)); 151extern char *optarg; /* getopt(3) external variables */ 152extern int opterr; 153extern int optind; 154extern int optopt; 155extern int optreset; 156int getsubopt __P((char **, char * const *, char **)); 157extern char *suboptarg; /* getsubopt(3) external variable */ 158 159int heapsort __P((void *, size_t, size_t, 160 int (*)(const void *, const void *))); 161int mergesort __P((void *, size_t, size_t, 162 int (*)(const void *, const void *))); 163int radixsort __P((const unsigned char **, int, const unsigned char *, 164 unsigned)); 165int sradixsort __P((const unsigned char **, int, const unsigned char *, 166 unsigned)); 167 168char *initstate __P((unsigned, char *, int)); 169long random __P((void)); 170char *realpath __P((const char *, char *)); 171char *setstate __P((char *)); 172void srandom __P((unsigned)); 173 174int putenv __P((const char *)); 175int setenv __P((const char *, const char *, int)); 176void unsetenv __P((const char *)); 177void setproctitle __P((const char *, ...)); 178 179quad_t qabs __P((quad_t)); 180qdiv_t qdiv __P((quad_t, quad_t)); 181quad_t strtoq __P((const char *, char **, int)); 182u_quad_t strtouq __P((const char *, char **, int)); 183 184double drand48 __P((void)); 185double erand48 __P((unsigned short[3])); 186long jrand48 __P((unsigned short[3])); 187void lcong48 __P((unsigned short[7])); 188long lrand48 __P((void)); 189long mrand48 __P((void)); 190long nrand48 __P((unsigned short[3])); 191unsigned short *seed48 __P((unsigned short[3])); 192void srand48 __P((long)); 193#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 194 195__END_DECLS 196 197#endif /* _STDLIB_H_ */ 198