Home | History | Annotate | Line # | Download | only in include
stdlib.h revision 1.47
      1  1.47   kleink /*	$NetBSD: stdlib.h,v 1.47 2000/08/10 10:03:43 kleink Exp $	*/
      2  1.20      cgd 
      3   1.1      cgd /*-
      4  1.30    perry  * Copyright (c) 1990, 1993
      5  1.30    perry  *	The Regents of the University of California.  All rights reserved.
      6   1.1      cgd  *
      7   1.1      cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1      cgd  * modification, are permitted provided that the following conditions
      9   1.1      cgd  * are met:
     10   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1      cgd  *    documentation and/or other materials provided with the distribution.
     15   1.1      cgd  * 3. All advertising materials mentioning features or use of this software
     16   1.1      cgd  *    must display the following acknowledgement:
     17   1.1      cgd  *	This product includes software developed by the University of
     18   1.1      cgd  *	California, Berkeley and its contributors.
     19   1.1      cgd  * 4. Neither the name of the University nor the names of its contributors
     20   1.1      cgd  *    may be used to endorse or promote products derived from this software
     21   1.1      cgd  *    without specific prior written permission.
     22   1.1      cgd  *
     23   1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24   1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25   1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26   1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27   1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28   1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29   1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30   1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31   1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32   1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33   1.1      cgd  * SUCH DAMAGE.
     34   1.1      cgd  *
     35  1.30    perry  *	@(#)stdlib.h	8.5 (Berkeley) 5/19/95
     36   1.1      cgd  */
     37   1.1      cgd 
     38   1.1      cgd #ifndef _STDLIB_H_
     39   1.1      cgd #define _STDLIB_H_
     40   1.6      jtc 
     41  1.37  mycroft #include <sys/cdefs.h>
     42  1.32   kleink #include <sys/featuretest.h>
     43  1.32   kleink 
     44  1.32   kleink #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
     45  1.32   kleink     !defined(_XOPEN_SOURCE)
     46  1.32   kleink #include <sys/types.h>		/* for quad_t, etc. */
     47  1.23      jtc #endif
     48  1.23      jtc 
     49  1.30    perry #include <machine/ansi.h>
     50  1.30    perry 
     51  1.16      cgd #ifdef	_BSD_SIZE_T_
     52  1.16      cgd typedef	_BSD_SIZE_T_	size_t;
     53  1.16      cgd #undef	_BSD_SIZE_T_
     54   1.6      jtc #endif
     55   1.1      cgd 
     56  1.16      cgd #ifdef	_BSD_WCHAR_T_
     57  1.16      cgd typedef	_BSD_WCHAR_T_	wchar_t;
     58  1.16      cgd #undef	_BSD_WCHAR_T_
     59   1.1      cgd #endif
     60   1.1      cgd 
     61   1.1      cgd typedef struct {
     62   1.1      cgd 	int quot;		/* quotient */
     63   1.1      cgd 	int rem;		/* remainder */
     64   1.1      cgd } div_t;
     65  1.23      jtc 
     66   1.1      cgd typedef struct {
     67   1.1      cgd 	long quot;		/* quotient */
     68   1.1      cgd 	long rem;		/* remainder */
     69   1.1      cgd } ldiv_t;
     70  1.10      jtc 
     71  1.45   kleink #if !defined(_ANSI_SOURCE) && \
     72  1.45   kleink     (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) || \
     73  1.45   kleink      defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L)
     74  1.45   kleink typedef struct {
     75  1.45   kleink 	/* LONGLONG */
     76  1.45   kleink 	long long int quot;	/* quotient */
     77  1.45   kleink 	/* LONGLONG */
     78  1.45   kleink 	long long int rem;	/* remainder */
     79  1.45   kleink } lldiv_t;
     80  1.45   kleink #endif
     81  1.45   kleink 
     82  1.45   kleink #if !defined(_ANSI_SOURCE) && !defined(_ISOC99_SOURCE) && \
     83  1.45   kleink     !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
     84  1.23      jtc typedef struct {
     85  1.23      jtc 	quad_t quot;		/* quotient */
     86  1.23      jtc 	quad_t rem;		/* remainder */
     87  1.23      jtc } qdiv_t;
     88  1.23      jtc #endif
     89  1.23      jtc 
     90  1.23      jtc 
     91  1.44   kleink #include <sys/null.h>
     92   1.1      cgd 
     93   1.1      cgd #define	EXIT_FAILURE	1
     94   1.1      cgd #define	EXIT_SUCCESS	0
     95   1.1      cgd 
     96   1.1      cgd #define	RAND_MAX	0x7fffffff
     97   1.1      cgd 
     98  1.47   kleink extern size_t __mb_cur_max;
     99  1.30    perry #define	MB_CUR_MAX	__mb_cur_max
    100   1.1      cgd 
    101   1.1      cgd __BEGIN_DECLS
    102  1.41  mycroft __dead	 void abort __P((void)) __attribute__((__noreturn__));
    103  1.40  mycroft __pure	 int abs __P((int));
    104   1.1      cgd int	 atexit __P((void (*)(void)));
    105   1.1      cgd double	 atof __P((const char *));
    106   1.1      cgd int	 atoi __P((const char *));
    107   1.1      cgd long	 atol __P((const char *));
    108   1.1      cgd void	*bsearch __P((const void *, const void *, size_t,
    109   1.1      cgd 	    size_t, int (*)(const void *, const void *)));
    110   1.1      cgd void	*calloc __P((size_t, size_t));
    111   1.1      cgd div_t	 div __P((int, int));
    112  1.41  mycroft __dead	 void exit __P((int)) __attribute__((__noreturn__));
    113   1.1      cgd void	 free __P((void *));
    114  1.35  mycroft __aconst char *getenv __P((const char *));
    115  1.30    perry __pure long
    116  1.30    perry 	 labs __P((long));
    117   1.1      cgd ldiv_t	 ldiv __P((long, long));
    118   1.1      cgd void	*malloc __P((size_t));
    119   1.1      cgd void	 qsort __P((void *, size_t, size_t,
    120   1.1      cgd 	    int (*)(const void *, const void *)));
    121   1.1      cgd int	 rand __P((void));
    122   1.1      cgd void	*realloc __P((void *, size_t));
    123   1.1      cgd void	 srand __P((unsigned));
    124   1.1      cgd double	 strtod __P((const char *, char **));
    125   1.1      cgd long	 strtol __P((const char *, char **, int));
    126   1.1      cgd unsigned long
    127   1.1      cgd 	 strtoul __P((const char *, char **, int));
    128   1.1      cgd int	 system __P((const char *));
    129   1.1      cgd 
    130  1.30    perry /* These are currently just stubs. */
    131   1.1      cgd int	 mblen __P((const char *, size_t));
    132   1.1      cgd size_t	 mbstowcs __P((wchar_t *, const char *, size_t));
    133   1.1      cgd int	 wctomb __P((char *, wchar_t));
    134   1.1      cgd int	 mbtowc __P((wchar_t *, const char *, size_t));
    135   1.1      cgd size_t	 wcstombs __P((char *, const wchar_t *, size_t));
    136   1.5   brezak 
    137  1.33   kleink #if !defined(_ANSI_SOURCE)
    138  1.32   kleink 
    139  1.32   kleink 
    140  1.33   kleink /*
    141  1.33   kleink  * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
    142  1.33   kleink  */
    143  1.33   kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    144  1.33   kleink     (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
    145  1.33   kleink     defined(_REENTRANT)
    146  1.33   kleink int	 rand_r __P((unsigned int *));
    147  1.33   kleink #endif
    148  1.32   kleink 
    149  1.32   kleink 
    150  1.33   kleink /*
    151  1.33   kleink  * X/Open Portability Guide >= Issue 4
    152  1.33   kleink  */
    153  1.33   kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    154  1.33   kleink     (_XOPEN_SOURCE - 0) >= 4
    155  1.32   kleink double	 drand48 __P((void));
    156  1.32   kleink double	 erand48 __P((unsigned short[3]));
    157  1.32   kleink long	 jrand48 __P((unsigned short[3]));
    158  1.32   kleink void	 lcong48 __P((unsigned short[7]));
    159  1.32   kleink long	 lrand48 __P((void));
    160  1.32   kleink long	 mrand48 __P((void));
    161  1.32   kleink long	 nrand48 __P((unsigned short[3]));
    162  1.32   kleink unsigned short *
    163  1.32   kleink 	 seed48 __P((unsigned short[3]));
    164  1.32   kleink void	 srand48 __P((long));
    165  1.32   kleink 
    166  1.33   kleink int	 putenv __P((const char *));
    167  1.33   kleink #endif
    168  1.33   kleink 
    169  1.33   kleink 
    170  1.33   kleink /*
    171  1.33   kleink  * X/Open Portability Guide >= Issue 4 Version 2
    172  1.33   kleink  */
    173  1.33   kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    174  1.33   kleink     (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
    175  1.33   kleink     (_XOPEN_SOURCE - 0) >= 500
    176  1.33   kleink long	 a64l __P((const char *));
    177  1.33   kleink char	*l64a __P((long));
    178  1.33   kleink 
    179  1.33   kleink char	*initstate __P((unsigned long, char *, size_t));
    180  1.33   kleink long	 random __P((void));
    181  1.33   kleink char	*setstate __P((char *));
    182  1.33   kleink void	 srandom __P((unsigned long));
    183  1.33   kleink 
    184  1.39  mycroft char	*mkdtemp __P((char *));
    185  1.33   kleink int	 mkstemp __P((char *));
    186  1.36  mycroft #ifndef __AUDIT__
    187  1.33   kleink char	*mktemp __P((char *));
    188  1.36  mycroft #endif
    189  1.33   kleink 
    190  1.33   kleink int	 setkey __P((const char *));
    191  1.33   kleink 
    192  1.33   kleink char	*realpath __P((const char *, char *));
    193  1.33   kleink 
    194  1.33   kleink int	 ttyslot __P((void));
    195  1.33   kleink 
    196  1.33   kleink void	*valloc __P((size_t));		/* obsoleted by malloc() */
    197  1.33   kleink #endif
    198  1.33   kleink 
    199  1.45   kleink /*
    200  1.45   kleink  * ISO C99
    201  1.45   kleink  */
    202  1.45   kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    203  1.45   kleink     defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L
    204  1.45   kleink /* LONGLONG */
    205  1.45   kleink long long int	atoll __P((const char *));
    206  1.45   kleink /* LONGLONG */
    207  1.45   kleink long long int	llabs __P((long long int));
    208  1.45   kleink /* LONGLONG */
    209  1.45   kleink lldiv_t		lldiv __P((long long int, long long int));
    210  1.45   kleink /* LONGLONG */
    211  1.45   kleink long long int	strtoll __P((const char *, char **, int));
    212  1.45   kleink /* LONGLONG */
    213  1.45   kleink unsigned long long int	strtoull __P((const char *, char **, int));
    214  1.45   kleink #endif
    215  1.33   kleink 
    216  1.33   kleink /*
    217  1.33   kleink  * Implementation-defined extensions
    218  1.33   kleink  */
    219  1.33   kleink #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
    220   1.3   brezak #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
    221  1.27    mikel void	*alloca __P((int));     /* built-in for gcc */
    222   1.2      cgd #else
    223  1.27    mikel void	*alloca __P((size_t));
    224   1.2      cgd #endif /* __GNUC__ */
    225  1.11      cgd 
    226  1.13      cgd char	*getbsize __P((int *, long *));
    227  1.34  mycroft char	*cgetcap __P((char *, const char *, int));
    228  1.11      cgd int	 cgetclose __P((void));
    229  1.34  mycroft int	 cgetent __P((char **, char **, const char *));
    230  1.11      cgd int	 cgetfirst __P((char **, char **));
    231  1.34  mycroft int	 cgetmatch __P((const char *, const char *));
    232  1.11      cgd int	 cgetnext __P((char **, char **));
    233  1.34  mycroft int	 cgetnum __P((char *, const char *, long *));
    234  1.34  mycroft int	 cgetset __P((const char *));
    235  1.34  mycroft int	 cgetstr __P((char *, const char *, char **));
    236  1.34  mycroft int	 cgetustr __P((char *, const char *, char **));
    237  1.18  deraadt 
    238  1.18  deraadt int	 daemon __P((int, int));
    239  1.35  mycroft __aconst char *devname __P((dev_t, mode_t));
    240  1.18  deraadt int	 getloadavg __P((double [], int));
    241   1.8      jtc 
    242   1.7      jtc void	 cfree __P((void *));
    243   1.7      jtc 
    244   1.1      cgd int	 heapsort __P((void *, size_t, size_t,
    245   1.1      cgd 	    int (*)(const void *, const void *)));
    246  1.17  mycroft int	 mergesort __P((void *, size_t, size_t,
    247  1.17  mycroft 	    int (*)(const void *, const void *)));
    248  1.17  mycroft int	 radixsort __P((const unsigned char **, int, const unsigned char *,
    249  1.17  mycroft 	    unsigned));
    250  1.17  mycroft int	 sradixsort __P((const unsigned char **, int, const unsigned char *,
    251  1.17  mycroft 	    unsigned));
    252   1.7      jtc 
    253   1.7      jtc int	 setenv __P((const char *, const char *, int));
    254   1.1      cgd void	 unsetenv __P((const char *));
    255  1.14      cgd void	 setproctitle __P((const char *, ...));
    256  1.19      jtc 
    257  1.24      jtc quad_t	 qabs __P((quad_t));
    258  1.23      jtc qdiv_t	 qdiv __P((quad_t, quad_t));
    259  1.19      jtc quad_t	 strtoq __P((const char *, char **, int));
    260  1.19      jtc u_quad_t strtouq __P((const char *, char **, int));
    261  1.42   kleink 
    262  1.42   kleink int	 l64a_r __P((long, char *, int));
    263  1.33   kleink #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
    264  1.33   kleink #endif /* !_ANSI_SOURCE */
    265   1.1      cgd __END_DECLS
    266   1.1      cgd 
    267  1.27    mikel #endif /* !_STDLIB_H_ */
    268