Home | History | Annotate | Line # | Download | only in include
stdlib.h revision 1.54
      1  1.54    kleink /*	$NetBSD: stdlib.h,v 1.54 2001/03/21 22:42:28 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.51  christos #ifndef __BSEARCH_DECLARED
    109  1.51  christos #define __BSEARCH_DECLARED
    110  1.51  christos /* also in search.h */
    111  1.51  christos void	*bsearch __P((const void *, const void *, size_t, size_t,
    112  1.51  christos     int (*)(const void *, const void *)));
    113  1.51  christos #endif /* __BSEARCH_DECLARED */
    114   1.1       cgd void	*calloc __P((size_t, size_t));
    115   1.1       cgd div_t	 div __P((int, int));
    116  1.41   mycroft __dead	 void exit __P((int)) __attribute__((__noreturn__));
    117   1.1       cgd void	 free __P((void *));
    118  1.35   mycroft __aconst char *getenv __P((const char *));
    119  1.30     perry __pure long
    120  1.30     perry 	 labs __P((long));
    121   1.1       cgd ldiv_t	 ldiv __P((long, long));
    122   1.1       cgd void	*malloc __P((size_t));
    123   1.1       cgd void	 qsort __P((void *, size_t, size_t,
    124   1.1       cgd 	    int (*)(const void *, const void *)));
    125   1.1       cgd int	 rand __P((void));
    126   1.1       cgd void	*realloc __P((void *, size_t));
    127   1.1       cgd void	 srand __P((unsigned));
    128  1.54    kleink double	 strtod __P((const char * __restrict, char ** __restrict));
    129  1.54    kleink long	 strtol __P((const char * __restrict, char ** __restrict, int));
    130   1.1       cgd unsigned long
    131  1.54    kleink 	 strtoul __P((const char * __restrict, char ** __restrict, int));
    132   1.1       cgd int	 system __P((const char *));
    133   1.1       cgd 
    134  1.30     perry /* These are currently just stubs. */
    135   1.1       cgd int	 mblen __P((const char *, size_t));
    136  1.54    kleink size_t	 mbstowcs __P((wchar_t * __restrict, const char * __restrict, size_t));
    137   1.1       cgd int	 wctomb __P((char *, wchar_t));
    138  1.54    kleink int	 mbtowc __P((wchar_t * __restrict, const char * __restrict, size_t));
    139  1.54    kleink size_t	 wcstombs __P((char * __restrict, const wchar_t * __restrict, size_t));
    140   1.5    brezak 
    141  1.33    kleink #if !defined(_ANSI_SOURCE)
    142  1.32    kleink 
    143  1.32    kleink 
    144  1.33    kleink /*
    145  1.33    kleink  * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
    146  1.33    kleink  */
    147  1.33    kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    148  1.33    kleink     (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
    149  1.33    kleink     defined(_REENTRANT)
    150  1.33    kleink int	 rand_r __P((unsigned int *));
    151  1.33    kleink #endif
    152  1.32    kleink 
    153  1.32    kleink 
    154  1.33    kleink /*
    155  1.33    kleink  * X/Open Portability Guide >= Issue 4
    156  1.33    kleink  */
    157  1.33    kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    158  1.33    kleink     (_XOPEN_SOURCE - 0) >= 4
    159  1.32    kleink double	 drand48 __P((void));
    160  1.32    kleink double	 erand48 __P((unsigned short[3]));
    161  1.32    kleink long	 jrand48 __P((unsigned short[3]));
    162  1.32    kleink void	 lcong48 __P((unsigned short[7]));
    163  1.32    kleink long	 lrand48 __P((void));
    164  1.32    kleink long	 mrand48 __P((void));
    165  1.32    kleink long	 nrand48 __P((unsigned short[3]));
    166  1.32    kleink unsigned short *
    167  1.32    kleink 	 seed48 __P((unsigned short[3]));
    168  1.32    kleink void	 srand48 __P((long));
    169  1.32    kleink 
    170  1.33    kleink int	 putenv __P((const char *));
    171  1.33    kleink #endif
    172  1.33    kleink 
    173  1.33    kleink 
    174  1.33    kleink /*
    175  1.33    kleink  * X/Open Portability Guide >= Issue 4 Version 2
    176  1.33    kleink  */
    177  1.33    kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    178  1.33    kleink     (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
    179  1.33    kleink     (_XOPEN_SOURCE - 0) >= 500
    180  1.33    kleink long	 a64l __P((const char *));
    181  1.33    kleink char	*l64a __P((long));
    182  1.33    kleink 
    183  1.33    kleink char	*initstate __P((unsigned long, char *, size_t));
    184  1.33    kleink long	 random __P((void));
    185  1.33    kleink char	*setstate __P((char *));
    186  1.33    kleink void	 srandom __P((unsigned long));
    187  1.33    kleink 
    188  1.39   mycroft char	*mkdtemp __P((char *));
    189  1.33    kleink int	 mkstemp __P((char *));
    190  1.36   mycroft #ifndef __AUDIT__
    191  1.33    kleink char	*mktemp __P((char *));
    192  1.36   mycroft #endif
    193  1.33    kleink 
    194  1.33    kleink int	 setkey __P((const char *));
    195  1.33    kleink 
    196  1.33    kleink char	*realpath __P((const char *, char *));
    197  1.33    kleink 
    198  1.33    kleink int	 ttyslot __P((void));
    199  1.33    kleink 
    200  1.33    kleink void	*valloc __P((size_t));		/* obsoleted by malloc() */
    201  1.33    kleink #endif
    202  1.33    kleink 
    203  1.45    kleink /*
    204  1.45    kleink  * ISO C99
    205  1.45    kleink  */
    206  1.45    kleink #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    207  1.45    kleink     defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L
    208  1.45    kleink /* LONGLONG */
    209  1.45    kleink long long int	atoll __P((const char *));
    210  1.45    kleink /* LONGLONG */
    211  1.45    kleink long long int	llabs __P((long long int));
    212  1.45    kleink /* LONGLONG */
    213  1.45    kleink lldiv_t		lldiv __P((long long int, long long int));
    214  1.45    kleink /* LONGLONG */
    215  1.54    kleink long long int	strtoll __P((const char * __restrict, char ** __restrict, int));
    216  1.45    kleink /* LONGLONG */
    217  1.54    kleink unsigned long long int
    218  1.54    kleink 		strtoull __P((const char * __restrict, char ** __restrict,
    219  1.54    kleink 		    int));
    220  1.45    kleink #endif
    221  1.33    kleink 
    222  1.33    kleink /*
    223  1.33    kleink  * Implementation-defined extensions
    224  1.33    kleink  */
    225  1.33    kleink #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
    226   1.3    brezak #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
    227  1.27     mikel void	*alloca __P((int));     /* built-in for gcc */
    228   1.2       cgd #else
    229  1.27     mikel void	*alloca __P((size_t));
    230   1.2       cgd #endif /* __GNUC__ */
    231  1.11       cgd 
    232  1.13       cgd char	*getbsize __P((int *, long *));
    233  1.34   mycroft char	*cgetcap __P((char *, const char *, int));
    234  1.11       cgd int	 cgetclose __P((void));
    235  1.34   mycroft int	 cgetent __P((char **, char **, const char *));
    236  1.11       cgd int	 cgetfirst __P((char **, char **));
    237  1.34   mycroft int	 cgetmatch __P((const char *, const char *));
    238  1.11       cgd int	 cgetnext __P((char **, char **));
    239  1.34   mycroft int	 cgetnum __P((char *, const char *, long *));
    240  1.34   mycroft int	 cgetset __P((const char *));
    241  1.34   mycroft int	 cgetstr __P((char *, const char *, char **));
    242  1.34   mycroft int	 cgetustr __P((char *, const char *, char **));
    243  1.18   deraadt 
    244  1.18   deraadt int	 daemon __P((int, int));
    245  1.35   mycroft __aconst char *devname __P((dev_t, mode_t));
    246  1.18   deraadt int	 getloadavg __P((double [], int));
    247   1.8       jtc 
    248   1.7       jtc void	 cfree __P((void *));
    249   1.7       jtc 
    250   1.1       cgd int	 heapsort __P((void *, size_t, size_t,
    251   1.1       cgd 	    int (*)(const void *, const void *)));
    252  1.17   mycroft int	 mergesort __P((void *, size_t, size_t,
    253  1.17   mycroft 	    int (*)(const void *, const void *)));
    254  1.17   mycroft int	 radixsort __P((const unsigned char **, int, const unsigned char *,
    255  1.17   mycroft 	    unsigned));
    256  1.17   mycroft int	 sradixsort __P((const unsigned char **, int, const unsigned char *,
    257  1.17   mycroft 	    unsigned));
    258   1.7       jtc 
    259   1.7       jtc int	 setenv __P((const char *, const char *, int));
    260   1.1       cgd void	 unsetenv __P((const char *));
    261  1.48  sommerfe void	 setproctitle __P((const char *, ...))
    262  1.48  sommerfe 	    __attribute__((__format__(__printf__, 1, 2)));
    263  1.52       cgd const char *getprogname __P((void)) __attribute__((__const__));
    264  1.52       cgd void	setprogname __P((const char *));
    265  1.19       jtc 
    266  1.24       jtc quad_t	 qabs __P((quad_t));
    267  1.23       jtc qdiv_t	 qdiv __P((quad_t, quad_t));
    268  1.54    kleink quad_t	 strtoq __P((const char * __restrict, char ** __restrict, int));
    269  1.54    kleink u_quad_t strtouq __P((const char * __restrict, char ** __restrict, int));
    270  1.42    kleink 
    271  1.42    kleink int	 l64a_r __P((long, char *, int));
    272  1.53       cgd 
    273  1.53       cgd size_t	shquote __P((const char *arg, char *buf, size_t bufsize));
    274  1.53       cgd size_t	shquotev __P((int argc, char * const * argv, char *buf,
    275  1.53       cgd 	    size_t bufsize));
    276  1.33    kleink #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
    277  1.33    kleink #endif /* !_ANSI_SOURCE */
    278   1.1       cgd __END_DECLS
    279   1.1       cgd 
    280  1.27     mikel #endif /* !_STDLIB_H_ */
    281