Home | History | Annotate | Line # | Download | only in include
stdlib.h revision 1.45.2.1
      1 /*	$NetBSD: stdlib.h,v 1.45.2.1 2000/05/28 22:41:02 minoura 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_
     52 typedef	_BSD_SIZE_T_	size_t;
     53 #undef	_BSD_SIZE_T_
     54 #endif
     55 
     56 #ifdef	_BSD_WCHAR_T_
     57 typedef	_BSD_WCHAR_T_	wchar_t;
     58 #undef	_BSD_WCHAR_T_
     59 #endif
     60 
     61 typedef struct {
     62 	int quot;		/* quotient */
     63 	int rem;		/* remainder */
     64 } div_t;
     65 
     66 typedef struct {
     67 	long quot;		/* quotient */
     68 	long rem;		/* remainder */
     69 } ldiv_t;
     70 
     71 #if !defined(_ANSI_SOURCE) && \
     72     (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) || \
     73      defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L)
     74 typedef struct {
     75 	/* LONGLONG */
     76 	long long int quot;	/* quotient */
     77 	/* LONGLONG */
     78 	long long int rem;	/* remainder */
     79 } lldiv_t;
     80 #endif
     81 
     82 #if !defined(_ANSI_SOURCE) && !defined(_ISOC99_SOURCE) && \
     83     !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
     84 typedef struct {
     85 	quad_t quot;		/* quotient */
     86 	quad_t rem;		/* remainder */
     87 } qdiv_t;
     88 #endif
     89 
     90 
     91 #include <sys/null.h>
     92 
     93 #define	EXIT_FAILURE	1
     94 #define	EXIT_SUCCESS	0
     95 
     96 #define	RAND_MAX	0x7fffffff
     97 
     98 #if 1	/* no wide char stuff (yet) */
     99 extern int __mb_cur_max;
    100 #define	MB_CUR_MAX	__mb_cur_max
    101 #else
    102 #define	MB_CUR_MAX	1	/* XXX */
    103 #endif
    104 
    105 __BEGIN_DECLS
    106 __dead	 void abort __P((void)) __attribute__((__noreturn__));
    107 __pure	 int abs __P((int));
    108 int	 atexit __P((void (*)(void)));
    109 double	 atof __P((const char *));
    110 int	 atoi __P((const char *));
    111 long	 atol __P((const char *));
    112 void	*bsearch __P((const void *, const void *, size_t,
    113 	    size_t, int (*)(const void *, const void *)));
    114 void	*calloc __P((size_t, size_t));
    115 div_t	 div __P((int, int));
    116 __dead	 void exit __P((int)) __attribute__((__noreturn__));
    117 void	 free __P((void *));
    118 __aconst char *getenv __P((const char *));
    119 __pure long
    120 	 labs __P((long));
    121 ldiv_t	 ldiv __P((long, long));
    122 void	*malloc __P((size_t));
    123 void	 qsort __P((void *, size_t, size_t,
    124 	    int (*)(const void *, const void *)));
    125 int	 rand __P((void));
    126 void	*realloc __P((void *, size_t));
    127 void	 srand __P((unsigned));
    128 double	 strtod __P((const char *, char **));
    129 long	 strtol __P((const char *, char **, int));
    130 unsigned long
    131 	 strtoul __P((const char *, char **, int));
    132 int	 system __P((const char *));
    133 
    134 int	 mblen __P((const char *, size_t));
    135 size_t	 mbstowcs __P((wchar_t *, const char *, size_t));
    136 int	 wctomb __P((char *, wchar_t));
    137 int	 mbtowc __P((wchar_t *, const char *, size_t));
    138 size_t	 wcstombs __P((char *, const wchar_t *, size_t));
    139 
    140 #if !defined(_ANSI_SOURCE)
    141 
    142 
    143 /*
    144  * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
    145  */
    146 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    147     (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
    148     defined(_REENTRANT)
    149 int	 rand_r __P((unsigned int *));
    150 #endif
    151 
    152 
    153 /*
    154  * X/Open Portability Guide >= Issue 4
    155  */
    156 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    157     (_XOPEN_SOURCE - 0) >= 4
    158 double	 drand48 __P((void));
    159 double	 erand48 __P((unsigned short[3]));
    160 long	 jrand48 __P((unsigned short[3]));
    161 void	 lcong48 __P((unsigned short[7]));
    162 long	 lrand48 __P((void));
    163 long	 mrand48 __P((void));
    164 long	 nrand48 __P((unsigned short[3]));
    165 unsigned short *
    166 	 seed48 __P((unsigned short[3]));
    167 void	 srand48 __P((long));
    168 
    169 int	 putenv __P((const char *));
    170 #endif
    171 
    172 
    173 /*
    174  * X/Open Portability Guide >= Issue 4 Version 2
    175  */
    176 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    177     (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
    178     (_XOPEN_SOURCE - 0) >= 500
    179 long	 a64l __P((const char *));
    180 char	*l64a __P((long));
    181 
    182 char	*initstate __P((unsigned long, char *, size_t));
    183 long	 random __P((void));
    184 char	*setstate __P((char *));
    185 void	 srandom __P((unsigned long));
    186 
    187 char	*mkdtemp __P((char *));
    188 int	 mkstemp __P((char *));
    189 #ifndef __AUDIT__
    190 char	*mktemp __P((char *));
    191 #endif
    192 
    193 int	 setkey __P((const char *));
    194 
    195 char	*realpath __P((const char *, char *));
    196 
    197 int	 ttyslot __P((void));
    198 
    199 void	*valloc __P((size_t));		/* obsoleted by malloc() */
    200 #endif
    201 
    202 /*
    203  * ISO C99
    204  */
    205 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    206     defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L
    207 /* LONGLONG */
    208 long long int	atoll __P((const char *));
    209 /* LONGLONG */
    210 long long int	llabs __P((long long int));
    211 /* LONGLONG */
    212 lldiv_t		lldiv __P((long long int, long long int));
    213 /* LONGLONG */
    214 long long int	strtoll __P((const char *, char **, int));
    215 /* LONGLONG */
    216 unsigned long long int	strtoull __P((const char *, char **, int));
    217 #endif
    218 
    219 /*
    220  * Implementation-defined extensions
    221  */
    222 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
    223 #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
    224 void	*alloca __P((int));     /* built-in for gcc */
    225 #else
    226 void	*alloca __P((size_t));
    227 #endif /* __GNUC__ */
    228 
    229 char	*getbsize __P((int *, long *));
    230 char	*cgetcap __P((char *, const char *, int));
    231 int	 cgetclose __P((void));
    232 int	 cgetent __P((char **, char **, const char *));
    233 int	 cgetfirst __P((char **, char **));
    234 int	 cgetmatch __P((const char *, const char *));
    235 int	 cgetnext __P((char **, char **));
    236 int	 cgetnum __P((char *, const char *, long *));
    237 int	 cgetset __P((const char *));
    238 int	 cgetstr __P((char *, const char *, char **));
    239 int	 cgetustr __P((char *, const char *, char **));
    240 
    241 int	 daemon __P((int, int));
    242 __aconst char *devname __P((dev_t, mode_t));
    243 int	 getloadavg __P((double [], int));
    244 
    245 void	 cfree __P((void *));
    246 
    247 int	 heapsort __P((void *, size_t, size_t,
    248 	    int (*)(const void *, const void *)));
    249 int	 mergesort __P((void *, size_t, size_t,
    250 	    int (*)(const void *, const void *)));
    251 int	 radixsort __P((const unsigned char **, int, const unsigned char *,
    252 	    unsigned));
    253 int	 sradixsort __P((const unsigned char **, int, const unsigned char *,
    254 	    unsigned));
    255 
    256 int	 setenv __P((const char *, const char *, int));
    257 void	 unsetenv __P((const char *));
    258 void	 setproctitle __P((const char *, ...));
    259 
    260 quad_t	 qabs __P((quad_t));
    261 qdiv_t	 qdiv __P((quad_t, quad_t));
    262 quad_t	 strtoq __P((const char *, char **, int));
    263 u_quad_t strtouq __P((const char *, char **, int));
    264 
    265 int	 l64a_r __P((long, char *, int));
    266 #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
    267 #endif /* !_ANSI_SOURCE */
    268 __END_DECLS
    269 
    270 #endif /* !_STDLIB_H_ */
    271