STDLIB.H(7) Miscellaneous Information Manual STDLIB.H(7)

stdlib.hstandard library definitions

#include <stdlib.h>

Some of the functionality described on this reference page extends the ISO C standard. Applications shall define the appropriate feature test macro (see the System Interfaces volume of IEEE Std 1003.1-2001 (“POSIX.1”), xsh_chap02_02(3)) to enable the visibility of these symbols in this header.

The <stdlib.h> header shall define the following macros:

Unsuccessful termination for exit () ; evaluates to a non-zero value.
Successful termination for exit () ; evaluates to 0.
Null pointer.
Maximum value returned by () ; at least 32767.
Integer expression whose value is the maximum number of bytes in a character specified by the current locale.

The following data types shall be defined through :

Structure type returned by the () function.
Structure type returned by the () function.
Structure type returned by the () function.
As described in <stddef.h> .
As described in <stddef.h> .

In addition, the following symbolic names and macros shall be defined as in <sys/wait.h> , for use in decoding the return value from system(3):

[XSI] WNOHANG WUNTRACED WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED WSTOPSIG WTERMSIG

The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.

void          _Exit(int);
[XSI]
long          a64l(const char *);

void          abort(void);
int           abs(int);
int           atexit(void (*)(void));
double        atof(const char *);
int           atoi(const char *);
long          atol(const char *);
long long     atoll(const char *);
void         *bsearch(const void *, const void *, size_t, size_t,
                  int (*)(const void *, const void *));
void         *calloc(size_t, size_t);
div_t         div(int, int);
[XSI]
double        drand48(void);
char         *ecvt(double, int, int *restrict, int *restrict); (LEGACY )
double        erand48(unsigned short[3]);

void          exit(int);
[XSI]
char         *fcvt(double, int, int *restrict, int *restrict); (LEGACY )

void          free(void *);
[XSI]
char         *gcvt(double, int, char *); (LEGACY )

char         *getenv(const char *);
[XSI]
int           getsubopt(char **, char *const *, char **);
int           grantpt(int);
char         *initstate(unsigned, char *, size_t);
long          jrand48(unsigned short[3]);
char         *l64a(long);

long          labs(long);
[XSI]
void          lcong48(unsigned short[7]);

ldiv_t        ldiv(long, long);
long long     llabs(long long);
lldiv_t       lldiv(long long, long long);
[XSI]
long          lrand48(void);

void         *malloc(size_t);
int           mblen(const char *, size_t);
size_t        mbstowcs(wchar_t *restrict, const char *restrict, size_t);
int           mbtowc(wchar_t *restrict, const char *restrict, size_t);
[XSI]
char         *mktemp(char *); (LEGACY )
int           mkstemp(char *);
long          mrand48(void);
long          nrand48(unsigned short[3]);

[ADV]
int           posix_memalign(void **, size_t, size_t);

[XSI]
int           posix_openpt(int);
char         *ptsname(int);
int           putenv(char *);

void          qsort(void *, size_t, size_t, int (*)(const void *,
                  const void *));
int           rand(void);
[TSF]
int           rand_r(unsigned *);

[XSI]
long          random(void);

void         *realloc(void *, size_t);
[XSI]
char         *realpath(const char *restrict, char *restrict);
unsigned short seed48(unsigned short[3]);

[CX]
int           setenv(const char *, const char *, int);

[XSI]
void          setkey(const char *);
char         *setstate(const char *);

void          srand(unsigned);
[XSI]
void          srand48(long);
void          srandom(unsigned);

double        strtod(const char *restrict, char **restrict);
float         strtof(const char *restrict, char **restrict);
long          strtol(const char *restrict, char **restrict, int);
long double   strtold(const char *restrict, char **restrict);
long long     strtoll(const char *restrict, char **restrict, int);
unsigned long strtoul(const char *restrict, char **restrict, int);
unsigned long long
              strtoull(const char *restrict, char **restrict, int);
int           system(const char *);
[XSI]
int           unlockpt(int);

[CX]
int           unsetenv(const char *);

size_t        wcstombs(char *restrict, const wchar_t *restrict, size_t);
int           wctomb(char *, wchar_t);

[XSI] Inclusion of the <stdlib.h> header may also make visible all symbols from <stddef.h>, <limits.h>, <math.h>, and <sys/wait.h>.

None.

None.

None.

<limits.h> , <math.h> , <stddef.h> , <sys/types.h> , <sys/wait.h> , the System Interfaces volume of IEEE Std 1003.1-2001 (“POSIX.1”), _Exit(3), a64l(3), abort(3), abs(3), atexit(3), atof(3), atoi(3), atol(3), atoll(3), bsearch(3), calloc(3), div(3), drand48(3), erand48(3), exit(3), free(3), getenv(3), getsubopt(3), grantpt(3), initstate(3), jrand48(3), l64a(3), labs(3), lcong48(3), ldiv(3), llabs(3), lldiv(3), lrand48(3), malloc(3), mblen(3), mbstowcs(3), mbtowc(3), mkstemp(3), mrand48(3), nrand48(3), posix_memalign(3), ptsname(3), putenv(3), qsort(3), rand(3), realloc(3), realpath(3), setstate(3), srand(3), srand48(3), srandom(3), strtod(3), strtof(3), strtol(3), strtold(3), strtoll(3), strtoul(3), strtoull(3), unlockpt(3), wcstombs(3), wctomb(3)

First released in Issue 3.

The DESCRIPTION is updated for alignment with the POSIX Threads Extension.

The ttyslot () and valloc () functions are marked LEGACY.

The type of the third argument to initstate(3) is changed from to size_t. The type of the return value from setstate(3) is changed from char to char *, and the type of the first argument is changed from char * to .

The Open Group Corrigendum U021/1 is applied, correcting the prototype for realpath(3) to be consistent with the reference page.

The Open Group Corrigendum U028/13 is applied, correcting the prototype for putenv(3) to be consistent with the reference page.

The rand_r(3) function is marked as part of the Thread-Safe Functions option.

Function prototypes for setenv(3) and unsetenv(3) are added.

The posix_memalign(3) function is added for alignment with IEEE Std 1003.1d-1999.

This reference page is updated to align with the ISO/IEC 9899:1999 (“ISO C99”) standard.

The ecvt(3), fcvt(3), gcvt(3), and mktemp(3) functions are marked LEGACY.

The ttyslot () and valloc () functions are removed as they were previously marked LEGACY.

Extensions beyond the ISO C standard are marked.

footer end

December 6, 2001 posix.fail