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