Home | History | Annotate | Line # | Download | only in include
stdlib.h revision 1.41
      1 /*	$NetBSD: stdlib.h,v 1.41 1998/07/30 00:44:16 mycroft 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) && !defined(_POSIX_C_SOURCE) && \
     72     !defined(_XOPEN_SOURCE)
     73 typedef struct {
     74 	quad_t quot;		/* quotient */
     75 	quad_t rem;		/* remainder */
     76 } qdiv_t;
     77 #endif
     78 
     79 
     80 #ifndef	NULL
     81 #define	NULL	0
     82 #endif
     83 
     84 #define	EXIT_FAILURE	1
     85 #define	EXIT_SUCCESS	0
     86 
     87 #define	RAND_MAX	0x7fffffff
     88 
     89 #if 0	/* no wide char stuff (yet) */
     90 extern int __mb_cur_max;
     91 #define	MB_CUR_MAX	__mb_cur_max
     92 #else
     93 #define	MB_CUR_MAX	1	/* XXX */
     94 #endif
     95 
     96 __BEGIN_DECLS
     97 __dead	 void abort __P((void)) __attribute__((__noreturn__));
     98 __pure	 int abs __P((int));
     99 int	 atexit __P((void (*)(void)));
    100 double	 atof __P((const char *));
    101 int	 atoi __P((const char *));
    102 long	 atol __P((const char *));
    103 void	*bsearch __P((const void *, const void *, size_t,
    104 	    size_t, int (*)(const void *, const void *)));
    105 void	*calloc __P((size_t, size_t));
    106 div_t	 div __P((int, int));
    107 __dead	 void exit __P((int)) __attribute__((__noreturn__));
    108 void	 free __P((void *));
    109 __aconst 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 void	*realloc __P((void *, size_t));
    118 void	 srand __P((unsigned));
    119 double	 strtod __P((const char *, char **));
    120 long	 strtol __P((const char *, char **, int));
    121 unsigned long
    122 	 strtoul __P((const char *, char **, int));
    123 int	 system __P((const char *));
    124 
    125 /* These are currently just stubs. */
    126 int	 mblen __P((const char *, size_t));
    127 size_t	 mbstowcs __P((wchar_t *, const char *, size_t));
    128 int	 wctomb __P((char *, wchar_t));
    129 int	 mbtowc __P((wchar_t *, const char *, size_t));
    130 size_t	 wcstombs __P((char *, const wchar_t *, size_t));
    131 
    132 #if !defined(_ANSI_SOURCE)
    133 
    134 
    135 /*
    136  * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
    137  */
    138 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    139     (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
    140     defined(_REENTRANT)
    141 int	 rand_r __P((unsigned int *));
    142 #endif
    143 
    144 
    145 /*
    146  * X/Open Portability Guide >= Issue 4
    147  */
    148 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    149     (_XOPEN_SOURCE - 0) >= 4
    150 double	 drand48 __P((void));
    151 double	 erand48 __P((unsigned short[3]));
    152 long	 jrand48 __P((unsigned short[3]));
    153 void	 lcong48 __P((unsigned short[7]));
    154 long	 lrand48 __P((void));
    155 long	 mrand48 __P((void));
    156 long	 nrand48 __P((unsigned short[3]));
    157 unsigned short *
    158 	 seed48 __P((unsigned short[3]));
    159 void	 srand48 __P((long));
    160 
    161 int	 putenv __P((const char *));
    162 #endif
    163 
    164 
    165 /*
    166  * X/Open Portability Guide >= Issue 4 Version 2
    167  */
    168 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    169     (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
    170     (_XOPEN_SOURCE - 0) >= 500
    171 long	 a64l __P((const char *));
    172 char	*l64a __P((long));
    173 
    174 char	*initstate __P((unsigned long, char *, size_t));
    175 long	 random __P((void));
    176 char	*setstate __P((char *));
    177 void	 srandom __P((unsigned long));
    178 
    179 char	*mkdtemp __P((char *));
    180 int	 mkstemp __P((char *));
    181 #ifndef __AUDIT__
    182 char	*mktemp __P((char *));
    183 #endif
    184 
    185 int	 setkey __P((const char *));
    186 
    187 char	*realpath __P((const char *, char *));
    188 
    189 int	 ttyslot __P((void));
    190 
    191 void	*valloc __P((size_t));		/* obsoleted by malloc() */
    192 #endif
    193 
    194 
    195 /*
    196  * Implementation-defined extensions
    197  */
    198 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
    199 #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
    200 void	*alloca __P((int));     /* built-in for gcc */
    201 #else
    202 void	*alloca __P((size_t));
    203 #endif /* __GNUC__ */
    204 
    205 char	*getbsize __P((int *, long *));
    206 char	*cgetcap __P((char *, const char *, int));
    207 int	 cgetclose __P((void));
    208 int	 cgetent __P((char **, char **, const char *));
    209 int	 cgetfirst __P((char **, char **));
    210 int	 cgetmatch __P((const char *, const char *));
    211 int	 cgetnext __P((char **, char **));
    212 int	 cgetnum __P((char *, const char *, long *));
    213 int	 cgetset __P((const char *));
    214 int	 cgetstr __P((char *, const char *, char **));
    215 int	 cgetustr __P((char *, const char *, char **));
    216 
    217 int	 daemon __P((int, int));
    218 __aconst char *devname __P((dev_t, mode_t));
    219 int	 getloadavg __P((double [], int));
    220 
    221 void	 cfree __P((void *));
    222 
    223 int	 heapsort __P((void *, size_t, size_t,
    224 	    int (*)(const void *, const void *)));
    225 int	 mergesort __P((void *, size_t, size_t,
    226 	    int (*)(const void *, const void *)));
    227 int	 radixsort __P((const unsigned char **, int, const unsigned char *,
    228 	    unsigned));
    229 int	 sradixsort __P((const unsigned char **, int, const unsigned char *,
    230 	    unsigned));
    231 
    232 int	 setenv __P((const char *, const char *, int));
    233 void	 unsetenv __P((const char *));
    234 void	 setproctitle __P((const char *, ...));
    235 
    236 quad_t	 qabs __P((quad_t));
    237 qdiv_t	 qdiv __P((quad_t, quad_t));
    238 quad_t	 strtoq __P((const char *, char **, int));
    239 u_quad_t strtouq __P((const char *, char **, int));
    240 #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
    241 #endif /* !_ANSI_SOURCE */
    242 __END_DECLS
    243 
    244 #endif /* !_STDLIB_H_ */
    245