Skip to content

Commit 105ef6b

Browse files
author
Colin Robertson
committed
Correct stuff, including alligned_alloc
1 parent d4897bc commit 105ef6b

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

docs/standard-library/cstdlib.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Zero if the registration succeeds, non-zero if it fails.
9090
9191
#### Remarks
9292
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.
9494
9595
### <a name="atexit"></a> atexit
9696
@@ -101,7 +101,7 @@ int atexit(atexit-handler * func) noexcept;
101101

102102
#### Remarks
103103

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.
105105

106106
#### Return Value
107107

@@ -117,11 +117,11 @@ Returns zero if the registration succeeds, nonzero if it fails.
117117
118118
First, objects with thread storage duration and associated with the current thread are destroyed.
119119
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`.
121121
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.
123123
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. Otherwise the 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.
125125
126126
### <a name="getenv"></a> getenv
127127
@@ -137,8 +137,7 @@ char* getenv(const char* name);
137137
138138
#### Remarks
139139
140-
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.
142141
143142
### <a name="system"></a> system
144143
@@ -149,11 +148,20 @@ int system(const char* string);
149148
## Memory allocation functions
150149

151150
```cpp
152-
void* aligned_alloc(size_t alignment, size_t size);
151+
// void* aligned_alloc(size_t alignment, size_t size); // Unsupported in MSVC
153152
void* calloc(size_t nmemb, size_t size);
154153
void free(void* ptr);
155154
void* malloc(size_t size);
156155
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
157165
double atof(const char* nptr);
158166
int atoi(const char* nptr);
159167
long int atol(const char* nptr);
@@ -167,11 +175,11 @@ unsigned long int strtoul(const char* nptr, char** endptr, int base);
167175
unsigned long long int strtoull(const char* nptr, char** endptr, int base);
168176
```
169177

170-
#### Remarks
178+
### Remarks
171179

172180
These functions have the semantics specified in the C standard library.
173181

174-
## Multibyte / wide string and character conversion functions
182+
## Multibyte / wide string and character conversion functions
175183

176184
```cpp
177185
int mblen(const char* s, size_t n);
@@ -220,6 +228,15 @@ double abs(double j);
220228
long double abs(long double j);
221229
long int labs(long int j);
222230
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
223240
div_t div(int numer, int denom);
224241
ldiv_t div(long int numer, long int denom);
225242
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);
231248
232249
These functions have the semantics specified in the C standard library.
233250
234-
## Functions
235-
236-
```cpp
237-
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
238-
c-compare-pred * compar);
239-
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
240-
compare-pred * compar);
241-
void qsort(void* base, size_t nmemb, size_t size, c-compare-pred * compar);
242-
void qsort(void* base, size_t nmemb, size_t size, compare-pred * compar);
243-
```
244-
245251
## See also
246252
247253
[Header Files Reference](../standard-library/cpp-standard-library-header-files.md)\

0 commit comments

Comments
 (0)