You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/standard-library/cstdlib.md
+27-21Lines changed: 27 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,7 @@ Zero if the registration succeeds, non-zero if it fails.
90
90
91
91
#### Remarks
92
92
93
-
The `at_quick_exit()` functions register the function pointed to by *func* to be called without arguments when `quick_exit` is called. It's unspecified whether a call to `at_quick_exit()` that doesn't happen before all calls to `quick_exit` will succeed and the `at_quick_exit()` functions do not introduce a data race. The order of registration may be indeterminate if `at_quick_exit` was called from more than one thread and since `at_quick_exit` registrations are distinct from the `atexit` registrations, applications may need to call both registration functions with the same argument. The implementation shall support the registration of at least 32 functions.
93
+
The `at_quick_exit()` functions register a function *func*, which is called without arguments when `quick_exit` is called. A call to `at_quick_exit()` that doesn't happen before all calls to `quick_exit` may not succeed. The `at_quick_exit()` functions don't introduce a data race. The order of registration may be indeterminate if `at_quick_exit` was called from more than one thread. Since `at_quick_exit` registrations are distinct from the `atexit` registrations, applications may need to call both registration functions using the same argument. MSVC supports the registration of at least 32 functions.
94
94
95
95
### <a name="atexit"></a> atexit
96
96
@@ -101,7 +101,7 @@ int atexit(atexit-handler * func) noexcept;
101
101
102
102
#### Remarks
103
103
104
-
The `atexit()` functions register the function pointed to by *func* to be called without arguments at normal program termination. It's unspecified whether a call to `atexit()` that doesn't happen before a call to `exit()`will succeed and the `atexit()` functions do not introduce a data race.The implementation shall support the registration of at least 32 functions.
104
+
The `atexit()` functions register the function pointed to by *func* to be called without arguments at normal program termination. A call to `atexit()` that doesn't happen before a call to `exit()`may not succeed. The `atexit()` functions don't introduce a data race.
105
105
106
106
#### Return Value
107
107
@@ -117,11 +117,11 @@ Returns zero if the registration succeeds, nonzero if it fails.
117
117
118
118
First, objects with thread storage duration and associated with the current thread are destroyed.
119
119
120
-
Next, objects with static storage duration are destroyed and functions registered by calling `atexit` are called. Automatic objects aren't destroyed as a result of calling `exit()`. If control leaves a registered function called by `exit` because the function doesn't provide a handler for a thrown exception, `std::terminate()` shall be called. A function is called for every time it is registered. Objects with automatic storage duration are all destroyed in a program whose main function contains no automatic objects and executes the call to `exit()`. Control can be transferred directly to such a main function by throwing an exception that's caught in main.
120
+
Next, objects with static storage duration are destroyed and functions registered by calling `atexit` are called. Automatic objects aren't destroyed when `exit()` is called. If control leaves a registered function called by `exit` because the function doesn't provide a handler for a thrown exception, `std::terminate()` is called. A function is called once for every time it's registered. Objects with automatic storage duration are all destroyed in a program whose `main` function contains no automatic objects and executes the call to `exit()`. Control can be transferred directly to such a `main` function by throwing an exception that's caught in `main`.
121
121
122
-
Next, all open C streams (as mediated by the function signatures declared in <cstdio>) with unwritten buffered data are flushed, all open C streams are closed, and all files created by calling `tmpfile()` are removed.
122
+
Next, all open C streams (as mediated by the function signatures declared in \<cstdio>) with unwritten buffered data are flushed, all open C streams are closed, and all files created by calling `tmpfile()` are removed.
123
123
124
-
Finally, control is returned to the host environment. If status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If status is EXIT_FAILURE, an implementation-defined form of the status unsuccessful termination is returned. Otherwisethe status returned is implementation-defined.
124
+
Finally, control is returned to the host environment. When *status* is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. MSVC returns a value of zero. If *status* is EXIT_FAILURE, MSVC returns a value of 3. Otherwise, MSVC returns the *status* parameter value.
Functions registered by calls to `at_quick_exit` are called in the reverse order of their registration, except that a function shall be called after any previously registered functions that had already been called at the time it was registered. Objects shall not be destroyed as a result of calling
141
-
`quick_exit`. If control leaves a registered function called by `quick_exit` because the function doesn't provide a handler for a thrown exception, `std::terminate()` shall be called. A function registered via `at_quick_exit` is invoked by the thread that calls `quick_exit`, which can be a different thread than the one that registered it, so registered functions shouldn't rely on the identity of objects with thread storage duration. After calling registered functions, `quick_exit` shall call `_Exit(status)`. The standard file buffers aren't flushed. The function `quick_exit` is signal-safe when the functions registered with `at_quick_exit` are.
140
+
Generally, functions registered by calls to `at_quick_exit` are called in the reverse order of their registration. This order doesn't apply to functions registered after other registered functions have already been called. No objects are destroyed when `quick_exit` is called. If control leaves a registered function called by `quick_exit` because the function doesn't provide a handler for a thrown exception, `std::terminate()` is called. A function registered via `at_quick_exit` is invoked by the thread that calls `quick_exit`, which can be a different thread than the one that registered it. That means registered functions shouldn't rely on the identity of objects that have thread storage duration. After calling registered functions, `quick_exit` calls `_Exit(status)`. The standard file buffers aren't flushed. The function `quick_exit` is signal-safe when the functions registered with `at_quick_exit` are.
142
141
143
142
### <a name="system"></a> system
144
143
@@ -149,11 +148,20 @@ int system(const char* string);
//void* aligned_alloc(size_t alignment, size_t size); // Unsupported in MSVC
153
152
void* calloc(size_t nmemb, size_t size);
154
153
void free(void* ptr);
155
154
void* malloc(size_t size);
156
155
void* realloc(void* ptr, size_t size);
156
+
```
157
+
158
+
### Remarks
159
+
160
+
These functions have the semantics specified in the C standard library. MSVC doesn't support the `aligned_alloc` function. C11 specified `aligned_alloc()` in a way that's incompatible with the Microsoft implementation of `free()`, namely, that `free()` must be able to handle highly aligned allocations.
161
+
162
+
## Numeric string conversions
163
+
164
+
```cpp
157
165
double atof(const char* nptr);
158
166
int atoi(const char* nptr);
159
167
long int atol(const char* nptr);
@@ -167,11 +175,11 @@ unsigned long int strtoul(const char* nptr, char** endptr, int base);
167
175
unsigned long long int strtoull(const char* nptr, char** endptr, int base);
168
176
```
169
177
170
-
#### Remarks
178
+
### Remarks
171
179
172
180
These functions have the semantics specified in the C standard library.
173
181
174
-
## Multibyte / wide string and character conversion functions
182
+
## Multibyte / wide string and character conversion functions
175
183
176
184
```cpp
177
185
intmblen(const char* s, size_t n);
@@ -220,6 +228,15 @@ double abs(double j);
220
228
long double abs(long double j);
221
229
long int labs(long int j);
222
230
long long int llabs(long long int j);
231
+
```
232
+
233
+
### Remarks
234
+
235
+
These functions have the semantics specified in the C standard library.
236
+
237
+
## Integer division
238
+
239
+
```cpp
223
240
div_tdiv(int numer, int denom);
224
241
ldiv_t div(long int numer, long int denom);
225
242
lldiv_t div(long long int numer, long long int denom);
@@ -231,17 +248,6 @@ lldiv_t lldiv(long long int numer, long long int denom);
231
248
232
249
These functions have the semantics specified in the C standard library.
0 commit comments