[BACK]Return to stdlib.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/stdlib.h, Revision 1.41

1.41    ! otto        1: /*     $OpenBSD: stdlib.h,v 1.40 2007/09/03 14:37:02 millert Exp $     */
1.2       deraadt     2: /*     $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $  */
1.1       deraadt     3:
                      4: /*-
                      5:  * Copyright (c) 1990 The Regents of the University of California.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
1.25      millert    16:  * 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    17:  *    may be used to endorse or promote products derived from this software
                     18:  *    without specific prior written permission.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     30:  * SUCH DAMAGE.
                     31:  *
                     32:  *     @(#)stdlib.h    5.13 (Berkeley) 6/4/91
                     33:  */
                     34:
                     35: #ifndef _STDLIB_H_
                     36: #define _STDLIB_H_
                     37:
1.35      millert    38: #include <sys/cdefs.h>
1.36      millert    39: #include <machine/_types.h>
                     40: #if __BSD_VISIBLE      /* for quad_t, etc. (XXX - use protected types) */
1.1       deraadt    41: #include <sys/types.h>
                     42: #endif
                     43:
1.36      millert    44: #ifndef        _SIZE_T_DEFINED_
                     45: #define        _SIZE_T_DEFINED_
                     46: typedef        __size_t        size_t;
1.1       deraadt    47: #endif
                     48:
1.11      espie      49: /* in C++, wchar_t is a built-in type */
1.36      millert    50: #if !defined(_WCHAR_T_DEFINED_) && !defined(__cplusplus)
                     51: #define _WCHAR_T_DEFINED_
                     52: typedef        __wchar_t       wchar_t;
1.1       deraadt    53: #endif
                     54:
                     55: typedef struct {
                     56:        int quot;               /* quotient */
                     57:        int rem;                /* remainder */
                     58: } div_t;
                     59:
                     60: typedef struct {
                     61:        long quot;              /* quotient */
                     62:        long rem;               /* remainder */
                     63: } ldiv_t;
                     64:
1.37      millert    65: #if __ISO_C_VISIBLE >= 1999
                     66: typedef struct {
                     67:        long long quot;         /* quotient */
                     68:        long long rem;          /* remainder */
                     69: } lldiv_t;
                     70: #endif
                     71:
1.35      millert    72: #if __BSD_VISIBLE
1.1       deraadt    73: typedef struct {
                     74:        quad_t quot;            /* quotient */
                     75:        quad_t rem;             /* remainder */
                     76: } qdiv_t;
                     77: #endif
                     78:
                     79:
                     80: #ifndef        NULL
1.10      espie      81: #ifdef         __GNUG__
                     82: #define NULL   __null
                     83: #else
1.21      millert    84: #define        NULL    0L
1.10      espie      85: #endif
1.1       deraadt    86: #endif
                     87:
                     88: #define        EXIT_FAILURE    1
                     89: #define        EXIT_SUCCESS    0
                     90:
                     91: #define        RAND_MAX        0x7fffffff
                     92:
1.33      espie      93: extern size_t  __mb_cur_max;
                     94: #define        MB_CUR_MAX      __mb_cur_max
1.1       deraadt    95:
                     96: #include <sys/cdefs.h>
                     97:
1.18      millert    98: /*
                     99:  * Some header files may define an abs macro.
                    100:  * If defined, undef it to prevent a syntax error and issue a warning.
                    101:  */
                    102: #ifdef abs
                    103: #undef abs
                    104: #warning abs macro collides with abs() prototype, undefining
                    105: #endif
                    106:
1.1       deraadt   107: __BEGIN_DECLS
1.16      millert   108: __dead void     abort(void);
                    109: int     abs(int);
1.17      millert   110: int     atexit(void (*)(void));
1.16      millert   111: double  atof(const char *);
                    112: int     atoi(const char *);
                    113: long    atol(const char *);
1.17      millert   114: void   *bsearch(const void *, const void *, size_t, size_t,
                    115:            int (*)(const void *, const void *));
1.16      millert   116: void   *calloc(size_t, size_t);
                    117: div_t   div(int, int);
1.23      millert   118: char   *ecvt(double, int, int *, int *);
1.16      millert   119: __dead void     exit(int);
1.30      millert   120: __dead void     _Exit(int);
1.23      millert   121: char   *fcvt(double, int, int *, int *);
1.16      millert   122: void    free(void *);
1.23      millert   123: char   *gcvt(double, int, char *);
1.16      millert   124: char   *getenv(const char *);
                    125: long    labs(long);
                    126: ldiv_t  ldiv(long, long);
                    127: void   *malloc(size_t);
1.17      millert   128: void    qsort(void *, size_t, size_t, int (*)(const void *, const void *));
1.16      millert   129: int     rand(void);
                    130: void   *realloc(void *, size_t);
1.40      millert   131: void   *recalloc(void *, size_t, size_t);
1.16      millert   132: void    srand(unsigned);
                    133: double  strtod(const char *, char **);
                    134: long    strtol(const char *, char **, int);
1.1       deraadt   135: unsigned long
1.16      millert   136:         strtoul(const char *, char **, int);
                    137: int     system(const char *);
1.1       deraadt   138:
                    139: /* these are currently just stubs */
1.16      millert   140: int     mblen(const char *, size_t);
                    141: size_t  mbstowcs(wchar_t *, const char *, size_t);
                    142: int     wctomb(char *, wchar_t);
                    143: int     mbtowc(wchar_t *, const char *, size_t);
                    144: size_t  wcstombs(char *, const wchar_t *, size_t);
1.1       deraadt   145:
1.35      millert   146: /*
                    147:  * IEEE Std 1003.1c-95, also adopted by X/Open CAE Spec Issue 5 Version 2
                    148:  */
                    149: #if __BSD_VISIBLE || __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE >= 500 || \
                    150:        defined(_REENTRANT)
                    151: int     rand_r(unsigned int *);
                    152: #endif
                    153:
                    154: #if __BSD_VISIBLE || __XPG_VISIBLE >= 400
                    155: double  drand48(void);
                    156: double  erand48(unsigned short[3]);
                    157: long    jrand48(unsigned short[3]);
                    158: void    lcong48(unsigned short[7]);
                    159: long    lrand48(void);
                    160: long    mrand48(void);
                    161: long    nrand48(unsigned short[3]);
                    162: unsigned short *seed48(unsigned short[3]);
                    163: void    srand48(long);
                    164:
                    165: int     putenv(const char *);
                    166: #endif
                    167:
                    168: #if __BSD_VISIBLE || __XPG_VISIBLE >= 420
                    169: long    a64l(const char *);
                    170: char   *l64a(long);
                    171:
                    172: char   *initstate(unsigned int, char *, size_t)
                    173:                __attribute__((__bounded__ (__string__,2,3)));
                    174: long    random(void);
                    175: char   *setstate(const char *);
                    176: void    srandom(unsigned int);
                    177:
                    178: int     mkstemp(char *);
                    179: char   *mktemp(char *);
                    180:
                    181: char   *realpath(const char *, char *);
                    182:
                    183: int     setkey(const char *);
                    184:
                    185: int     ttyslot(void);
                    186:
                    187: void   *valloc(size_t);                /* obsoleted by malloc() */
                    188: #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
                    189:
                    190: /*
                    191:  * ISO C99
                    192:  */
1.37      millert   193: #if __ISO_C_VISIBLE >= 1999
1.35      millert   194: long long
                    195:         atoll(const char *);
                    196: long long
                    197:         llabs(long long);
1.39      djm       198: lldiv_t
                    199:         lldiv(long long, long long);
1.35      millert   200: long long
                    201:         strtoll(const char *, char **, int);
                    202: unsigned long long
                    203:         strtoull(const char *, char **, int);
                    204: #endif
                    205:
                    206: /*
                    207:  * The Open Group Base Specifications, Issue 6; IEEE Std 1003.1-2001 (POSIX)
                    208:  */
                    209: #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE >= 600
                    210: int     setenv(const char *, const char *, int);
                    211: void    unsetenv(const char *);
                    212: #endif
                    213:
                    214: #if __BSD_VISIBLE
1.1       deraadt   215: #if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2)
1.16      millert   216: void  *alloca(int);     /* built-in for gcc */
1.1       deraadt   217: #else
1.16      millert   218: void  *alloca(size_t);
1.1       deraadt   219: #endif /* __GNUC__ */
                    220:
1.16      millert   221: char   *getbsize(int *, long *);
                    222: char   *cgetcap(char *, const char *, int);
                    223: int     cgetclose(void);
                    224: int     cgetent(char **, char **, const char *);
                    225: int     cgetfirst(char **, char **);
                    226: int     cgetmatch(char *, const char *);
                    227: int     cgetnext(char **, char **);
                    228: int     cgetnum(char *, const char *, long *);
                    229: int     cgetset(const char *);
                    230: int     cgetusedb(int);
                    231: int     cgetstr(char *, const char *, char **);
                    232: int     cgetustr(char *, const char *, char **);
                    233:
                    234: int     daemon(int, int);
1.38      deraadt   235: char   *devname(int, mode_t);
1.16      millert   236: int     getloadavg(double [], int);
1.1       deraadt   237:
1.16      millert   238: void    cfree(void *);
1.1       deraadt   239:
1.24      millert   240: #ifndef _GETOPT_DEFINED_
                    241: #define _GETOPT_DEFINED_
1.16      millert   242: int     getopt(int, char * const *, const char *);
1.1       deraadt   243: extern  char *optarg;                  /* getopt(3) external variables */
1.35      millert   244: extern  int opterr, optind, optopt, optreset;
1.16      millert   245: int     getsubopt(char **, char * const *, char **);
1.1       deraadt   246: extern  char *suboptarg;               /* getsubopt(3) external variable */
1.24      millert   247: #endif /* _GETOPT_DEFINED_ */
1.1       deraadt   248:
1.35      millert   249: char   *mkdtemp(char *);
                    250: int     mkstemps(char *, int);
                    251:
1.17      millert   252: int     heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
                    253: int     mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
                    254: int     radixsort(const unsigned char **, int, const unsigned char *,
                    255:            unsigned);
                    256: int     sradixsort(const unsigned char **, int, const unsigned char *,
                    257:            unsigned);
1.1       deraadt   258:
1.16      millert   259: void    srandomdev(void);
1.35      millert   260: long long
                    261:         strtonum(const char *, long long, long long, const char **);
1.16      millert   262:
                    263: void    setproctitle(const char *, ...)
1.15      krw       264:        __attribute__((__format__ (__printf__, 1, 2)));
1.1       deraadt   265:
1.16      millert   266: quad_t  qabs(quad_t);
                    267: qdiv_t  qdiv(quad_t, quad_t);
                    268: quad_t  strtoq(const char *, char **, int);
                    269: u_quad_t strtouq(const char *, char **, int);
                    270:
                    271: u_int32_t arc4random(void);
                    272: void   arc4random_stir(void);
1.28      avsm      273: void   arc4random_addrandom(unsigned char *, int)
                    274:        __attribute__((__bounded__ (__string__,1,2)));
1.41    ! otto      275: u_int32_t arc4random_uniform(u_int32_t);
        !           276: void arc4random_buf(void *, size_t)
        !           277:        __attribute__((__bounded__ (__string__,1,2)));
        !           278:
1.35      millert   279: #endif /* __BSD_VISIBLE */
1.1       deraadt   280:
                    281: __END_DECLS
                    282:
                    283: #endif /* _STDLIB_H_ */