1stdlib.h(0P) POSIX Programmer's Manual stdlib.h(0P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
11
13 stdlib.h — standard library definitions
14
16 #include <stdlib.h>
17
19 Some of the functionality described on this reference page extends the
20 ISO C standard. Applications shall define the appropriate feature test
21 macro (see the System Interfaces volume of POSIX.1‐2008, Section 2.2,
22 The Compilation Environment) to enable the visibility of these symbols
23 in this header.
24
25 The <stdlib.h> header shall define the following macros which shall
26 expand to integer constant expressions:
27
28 EXIT_FAILURE
29 Unsuccessful termination for exit(); evaluates to a non-
30 zero value.
31
32 EXIT_SUCCESS
33 Successful termination for exit(); evaluates to 0.
34
35 {RAND_MAX} Maximum value returned by rand(); at least 32767.
36
37 The <stdlib.h> header shall define the following macro which shall
38 expand to a positive integer expression with type size_t:
39
40 {MB_CUR_MAX}
41 Maximum number of bytes in a character specified by the
42 current locale (category LC_CTYPE).
43
44 The <stdlib.h> header shall define NULL as described in <stddef.h>.
45
46 The <stdlib.h> header shall define the following data types through
47 typedef:
48
49 div_t Structure type returned by the div() function.
50
51 ldiv_t Structure type returned by the ldiv() function.
52
53 lldiv_t Structure type returned by the lldiv() function.
54
55 size_t As described in <stddef.h>.
56
57 wchar_t As described in <stddef.h>.
58
59 In addition, the <stdlib.h> header shall define the following symbolic
60 constants and macros as described in <sys/wait.h>:
61
62 WEXITSTATUS
63 WIFEXITED
64 WIFSIGNALED
65 WIFSTOPPED
66 WNOHANG
67 WSTOPSIG
68 WTERMSIG
69 WUNTRACED
70
71 The following shall be declared as functions and may also be defined as
72 macros. Function prototypes shall be provided.
73
74 void _Exit(int);
75 long a64l(const char *);
76 void abort(void);
77 int abs(int);
78 int atexit(void (*)(void));
79 double atof(const char *);
80 int atoi(const char *);
81 long atol(const char *);
82 long long atoll(const char *);
83 void *bsearch(const void *, const void *, size_t, size_t,
84 int (*)(const void *, const void *));
85 void *calloc(size_t, size_t);
86 div_t div(int, int);
87 double drand48(void);
88 double erand48(unsigned short [3]);
89 void exit(int);
90 void free(void *);
91 char *getenv(const char *);
92 int getsubopt(char **, char *const *, char **);
93 int grantpt(int);
94 char *initstate(unsigned, char *, size_t);
95 long jrand48(unsigned short [3]);
96 char *l64a(long);
97 long labs(long);
98 void lcong48(unsigned short [7]);
99 ldiv_t ldiv(long, long);
100 long long llabs(long long);
101 lldiv_t lldiv(long long, long long);
102 long lrand48(void);
103 void *malloc(size_t);
104 int mblen(const char *, size_t);
105 size_t mbstowcs(wchar_t *restrict, const char *restrict, size_t);
106 int mbtowc(wchar_t *restrict, const char *restrict, size_t);
107 char *mkdtemp(char *);
108 int mkstemp(char *);
109 long mrand48(void);
110 long nrand48(unsigned short [3]);
111 int posix_memalign(void **, size_t, size_t);
112 int posix_openpt(int);
113 char *ptsname(int);
114 int putenv(char *);
115 void qsort(void *, size_t, size_t, int (*)(const void *,
116 const void *));
117 int rand(void);
118 int rand_r(unsigned *);
119 long random(void);
120 void *realloc(void *, size_t);
121 char *realpath(const char *restrict, char *restrict);
122 unsigned short *seed48(unsigned short [3]);
123 int setenv(const char *, const char *, int);
124 void setkey(const char *);
125 char *setstate(char *);
126 void srand(unsigned);
127 void srand48(long);
128 void srandom(unsigned);
129 double strtod(const char *restrict, char **restrict);
130 float strtof(const char *restrict, char **restrict);
131 long strtol(const char *restrict, char **restrict, int);
132 long double strtold(const char *restrict, char **restrict);
133 long long strtoll(const char *restrict, char **restrict, int);
134 unsigned long strtoul(const char *restrict, char **restrict, int);
135 unsigned long long
136 strtoull(const char *restrict, char **restrict, int);
137 int system(const char *);
138 int unlockpt(int);
139 int unsetenv(const char *);
140 size_t wcstombs(char *restrict, const wchar_t *restrict, size_t);
141 int wctomb(char *, wchar_t);
142
143 Inclusion of the <stdlib.h> header may also make visible all symbols
144 from <stddef.h>, <limits.h>, <math.h>, and <sys/wait.h>.
145
146 The following sections are informative.
147
149 None.
150
152 None.
153
155 None.
156
158 <limits.h>, <math.h>, <stddef.h>, <sys_types.h>, <sys_wait.h>
159
160 The System Interfaces volume of POSIX.1‐2008, Section 2.2, The Compila‐
161 tion Environment, _Exit(), a64l(), abort(), abs(), atexit(), atof(),
162 atoi(), atol(), bsearch(), calloc(), div(), drand48(), exit(), free(),
163 getenv(), getsubopt(), grantpt(), initstate(), labs(), ldiv(), mal‐
164 loc(), mblen(), mbstowcs(), mbtowc(), mkdtemp(), posix_memalign(),
165 posix_openpt(), ptsname(), putenv(), qsort(), rand(), realloc(), real‐
166 path(), setenv(), setkey(), strtod(), strtol(), strtoul(), system(),
167 unlockpt(), unsetenv(), wcstombs(), wctomb()
168
170 Portions of this text are reprinted and reproduced in electronic form
171 from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
172 -- Portable Operating System Interface (POSIX), The Open Group Base
173 Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
174 cal and Electronics Engineers, Inc and The Open Group. (This is
175 POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
176 event of any discrepancy between this version and the original IEEE and
177 The Open Group Standard, the original IEEE and The Open Group Standard
178 is the referee document. The original Standard can be obtained online
179 at http://www.unix.org/online.html .
180
181 Any typographical or formatting errors that appear in this page are
182 most likely to have been introduced during the conversion of the source
183 files to man page format. To report such errors, see https://www.ker‐
184 nel.org/doc/man-pages/reporting_bugs.html .
185
186
187
188IEEE/The Open Group 2013 stdlib.h(0P)