1 /*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by the University of 16 * California, Berkeley and its contributors. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 34 * $FreeBSD: src/include/stdlib.h,v 1.16.2.5 2002/12/13 01:34:00 tjr Exp $ 35 * $DragonFly: src/include/stdlib.h,v 1.9 2005/01/05 11:51:18 joerg Exp $ 36 */ 37 38 #ifndef _STDLIB_H_ 39 #define _STDLIB_H_ 40 41 #include <sys/cdefs.h> 42 43 #ifndef _SYS_STDINT_H_ 44 #include <sys/stdint.h> 45 #endif 46 47 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 48 #ifndef _RUNE_T_DECLARED 49 #define _RUNE_T_DECLARED 50 typedef __rune_t rune_t; 51 #endif 52 #endif 53 54 #ifndef __cplusplus 55 #ifndef _WCHAR_T_DECLARED 56 #define _WCHAR_T_DECLARED 57 typedef __wchar_t wchar_t; 58 #endif 59 #endif 60 61 #ifndef _SIZE_T_DECLARED 62 #define _SIZE_T_DECLARED 63 typedef __size_t size_t; 64 #endif 65 66 typedef struct { 67 int quot; /* quotient */ 68 int rem; /* remainder */ 69 } div_t; 70 71 typedef struct { 72 long quot; /* quotient */ 73 long rem; /* remainder */ 74 } ldiv_t; 75 76 #ifndef NULL 77 #define NULL 0 78 #endif 79 80 #define EXIT_FAILURE 1 81 #define EXIT_SUCCESS 0 82 83 #define RAND_MAX 0x7fffffff 84 85 extern int __mb_cur_max; 86 #define MB_CUR_MAX __mb_cur_max 87 88 __BEGIN_DECLS 89 void _Exit(int) __dead2; 90 void abort(void) __dead2; 91 int abs(int) __pure2; 92 int atexit(void (*)(void)); 93 double atof(const char *); 94 int atoi(const char *); 95 long atol(const char *); 96 void *bsearch(const void *, const void *, size_t, 97 size_t, int (*)(const void *, const void *)); 98 void *calloc(size_t, size_t); 99 div_t div(int, int) __pure2; 100 void exit(int) __dead2; 101 void free(void *); 102 char *getenv(const char *); 103 long labs(long) __pure2; 104 ldiv_t ldiv(long, long) __pure2; 105 void *malloc(size_t); 106 void qsort(void *, size_t, size_t, int(*)(const void *, const void *)); 107 int rand(void); 108 void *realloc(void *, size_t); 109 void srand(unsigned); 110 double strtod(const char *, char **); 111 long strtol(const char *, char **, int); 112 unsigned long strtoul(const char *, char **, int); 113 #ifdef __LONG_LONG_SUPPORTED 114 long long strtoll(const char *, char **, int); 115 unsigned long long strtoull(const char *, char **, int); 116 #endif 117 int system(const char *); 118 119 int mblen(const char *, size_t); 120 size_t mbstowcs(wchar_t *, const char *, size_t); 121 int wctomb(char *, wchar_t); 122 int mbtowc(wchar_t *, const char *, size_t); 123 size_t wcstombs(char *, const wchar_t *, size_t); 124 125 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 126 int putenv(const char *); 127 int setenv(const char *, const char *, int); 128 129 double drand48(void); 130 double erand48(unsigned short[3]); 131 long jrand48(unsigned short[3]); 132 void lcong48(unsigned short[7]); 133 long lrand48(void); 134 long mrand48(void); 135 long nrand48(unsigned short[3]); 136 unsigned short *seed48(unsigned short[3]); 137 void srand48(long); 138 139 void *alloca(size_t); /* built-in for gcc */ 140 /* getcap(3) functions */ 141 __uint32_t arc4random(void); 142 void arc4random_addrandom(unsigned char *, int); 143 void arc4random_stir(void); 144 char *getbsize(int *, long *); 145 char *cgetcap(char *, char *, int); 146 int cgetclose(void); 147 int cgetent(char **, char **, char *); 148 int cgetfirst(char **, char **); 149 int cgetmatch(char *, char *); 150 int cgetnext(char **, char **); 151 int cgetnum(char *, char *, long *); 152 int cgetset(char *); 153 int cgetstr(char *, char *, char **); 154 int cgetustr(char *, char *, char **); 155 156 int daemon(int, int); 157 char *devname(int, int); 158 char *devname_r(int, int, char *, size_t); 159 int getloadavg(double [], int); 160 const char *getprogname(void); 161 162 char *group_from_gid(unsigned long, int); 163 int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); 164 char *initstate(unsigned long, char *, long); 165 int mergesort(void *, size_t, size_t, int (*)(const void *, const void *)); 166 int radixsort(const unsigned char **, int, const unsigned char *, 167 unsigned int); 168 int sradixsort(const unsigned char **, int, const unsigned char *, 169 unsigned int); 170 int rand_r(unsigned *); 171 long random(void); 172 void *reallocf(void *, size_t); 173 char *realpath(const char *, char []); 174 void setprogname(const char *); 175 char *setstate(char *); 176 void srandom(unsigned long); 177 void srandomdev(void); 178 char *user_from_uid(unsigned long, int); 179 #ifndef __STRICT_ANSI__ 180 __int64_t strtoq(const char *, char **, int); 181 __uint64_t strtouq(const char *, char **, int); 182 183 #ifdef __LONG_LONG_SUPPORTED 184 unsigned long long strtonum(const char *, long long, unsigned long long, 185 const char **); 186 #endif 187 #endif 188 void unsetenv(const char *); 189 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 190 __END_DECLS 191 192 #endif /* !_STDLIB_H_ */ 193