Runtime functions. More...
#include <ucommon/platform.h>

Go to the source code of this file.
Functions | |
| __EXPORT void * | cpr_memalloc (size_t size) __MALLOC |
| Portable memory allocation helper function. | |
| __EXPORT void * | cpr_memassign (size_t size, caddr_t address, size_t known) __MALLOC |
| Portable memory placement helper function. | |
| __EXPORT void | cpr_memswap (void *mem1, void *mem2, size_t size) |
| Portable swap code. | |
| __EXPORT void | cpr_runtime_error (const char *text) |
| Function to handle runtime errors. | |
| __EXPORT uint32_t | lsb_getlong (uint8_t *b) |
| __EXPORT uint16_t | lsb_getshort (uint8_t *b) |
| __EXPORT void | lsb_setlong (uint8_t *b, uint32_t v) |
| __EXPORT void | lsb_setshort (uint8_t *b, uint16_t v) |
| __EXPORT uint32_t | msb_getlong (uint8_t *b) |
| __EXPORT uint16_t | msb_getshort (uint8_t *b) |
| __EXPORT void | msb_setlong (uint8_t *b, uint32_t v) |
| __EXPORT void | msb_setshort (uint8_t *b, uint16_t v) |
| void | operator delete (void *object) |
| Delete an object from the heap. | |
| void | operator delete[] (void *array) |
| Delete an array from the heap. | |
| void * | operator new (size_t size, caddr_t address, size_t known) |
| A placement new operator where we know the allocated size. | |
| void * | operator new (size_t size, caddr_t address) |
| A placement new operator where we assume the size of memory is good. | |
| void * | operator new (size_t size, size_t extra) |
| Overdraft new to allocate extra memory for object from heap. | |
| void * | operator new (size_t size) |
| Our generic new operator. | |
| void * | operator new[] (size_t size, caddr_t address, size_t known) |
| A placement new array operator where we know the allocated size. | |
| void * | operator new[] (size_t size, caddr_t address) |
| A placement new array operator where we assume the size of memory is good. | |
| void * | operator new[] (size_t size) |
| Our generic new array operator. | |
Runtime functions.
This includes common runtime library functions we may need portably.
Definition in file cpr.h.
| __EXPORT void* cpr_memalloc | ( | size_t | size | ) |
Portable memory allocation helper function.
Handles out of heap error as a runtime error.
| size | of memory block to allocate from heap. |
| __EXPORT void* cpr_memassign | ( | size_t | size, | |
| caddr_t | address, | |||
| size_t | known | |||
| ) |
Portable memory placement helper function.
This is used to process "placement" new operators where a new object is constructed over a pre-allocated area of memory. This handles invalid values through runtime error.
| size | of object being constructed. | |
| address | where the object is being placed. | |
| known | size of the location we are constructing the object in. |
| __EXPORT void cpr_memswap | ( | void * | mem1, | |
| void * | mem2, | |||
| size_t | size | |||
| ) |
Portable swap code.
| mem1 | to swap. | |
| mem2 | to swap. | |
| size | of swap area. |
| __EXPORT void cpr_runtime_error | ( | const char * | text | ) |
Function to handle runtime errors.
When using the standard C library, runtime errors are handled by a simple abort. When using the stdc++ library with stdexcept, then std::runtime_error will be thrown.
| text | of runtime error. |
| void operator delete | ( | void * | object | ) | [inline] |
| void operator delete[] | ( | void * | array | ) | [inline] |
| void* operator new | ( | size_t | size, | |
| caddr_t | address, | |||
| size_t | known | |||
| ) | [inline] |
A placement new operator where we know the allocated size.
We find out how much memory is needed by the new and can prevent the object from exceeding the available space we are placing the object.
| size | of memory needed for object. | |
| address | where to place object. | |
| known | size of location we are placing object. |
Definition at line 155 of file cpr.h.

| void* operator new | ( | size_t | size, | |
| caddr_t | address | |||
| ) | [inline] |
A placement new operator where we assume the size of memory is good.
We construct the object at a specified place in memory which we assume is valid for our needs.
| size | of memory needed for object. | |
| address | where to place object. |
Definition at line 142 of file cpr.h.

| void* operator new | ( | size_t | size, | |
| size_t | extra | |||
| ) | [inline] |
Overdraft new to allocate extra memory for object from heap.
This is used for objects that must have a known class size but store extra data behind the class. The last member might be an unsized or 0 element array, and the actual size needed from the heap is hence not the size of the class itself but is known by the routine allocating the object.
| size | of object. | |
| extra | heap space needed for data. |
Definition at line 131 of file cpr.h.

| void* operator new | ( | size_t | size | ) | [inline] |
| void* operator new[] | ( | size_t | size, | |
| caddr_t | address, | |||
| size_t | known | |||
| ) | [inline] |
A placement new array operator where we know the allocated size.
We find out how much memory is needed by the new and can prevent arrayed objects from exceeding the available space we are placing the object.
| size | of memory needed for object array. | |
| address | where to place object array. | |
| known | size of location we are placing array. |
Definition at line 118 of file cpr.h.

| void* operator new[] | ( | size_t | size, | |
| caddr_t | address | |||
| ) | [inline] |
A placement new array operator where we assume the size of memory is good.
We construct the array at a specified place in memory which we assume is valid for our needs.
| size | of memory needed for object array. | |
| address | where to place object array. |
Definition at line 106 of file cpr.h.

1.6.1