#include "ace/OS_Errno.h"
#include "ace/Basic_Types.h"
#include "ace/os_include/os_stddef.h"
#include "ace/OS_NS_stdlib.h"
Go to the source code of this file.
Classes | |
class | ACE_bad_alloc_class |
Defines | |
#define | ACE_MALLOC_FUNC ::malloc |
#define | ACE_CALLOC_FUNC ::calloc |
#define | ACE_FREE_FUNC ::free |
#define | ACE_REALLOC_FUNC ::realloc |
#define | ACE_del_bad_alloc |
#define | ACE_NEW_RETURN(POINTER, CONSTRUCTOR, RET_VAL) |
#define | ACE_NEW(POINTER, CONSTRUCTOR) |
#define | ACE_NEW_NORETURN(POINTER, CONSTRUCTOR) |
#define | ACE_bad_alloc ACE_bad_alloc_class |
#define | ACE_throw_bad_alloc return 0 |
Typedefs | |
typedef void * | ACE_MALLOC_T |
Functions | |
Efficiently compute aligned pointers to powers of 2 boundaries. | |
uintptr_t | ACE_align_binary (uintptr_t ptr, uintptr_t alignment) |
Return the next integer aligned to a required boundary. | |
char * | ACE_ptr_align_binary (char const *ptr, uintptr_t alignment) |
Return the next address aligned to a required boundary. | |
char * | ACE_ptr_align_binary (unsigned char const *ptr, uintptr_t alignment) |
Return the next address aligned to a required boundary. |
Definition in file OS_Memory.h.
#define ACE_bad_alloc ACE_bad_alloc_class |
Definition at line 236 of file OS_Memory.h.
#define ACE_CALLOC_FUNC ::calloc |
Definition at line 50 of file OS_Memory.h.
#define ACE_del_bad_alloc |
Definition at line 95 of file OS_Memory.h.
#define ACE_FREE_FUNC ::free |
Definition at line 53 of file OS_Memory.h.
#define ACE_MALLOC_FUNC ::malloc |
Definition at line 47 of file OS_Memory.h.
#define ACE_NEW | ( | POINTER, | ||
CONSTRUCTOR | ||||
) |
do { POINTER = new CONSTRUCTOR; \ if (POINTER == 0) { errno = ENOMEM; return; } \ } while (0)
Definition at line 225 of file OS_Memory.h.
#define ACE_NEW_NORETURN | ( | POINTER, | ||
CONSTRUCTOR | ||||
) |
do { POINTER = new CONSTRUCTOR; \ if (POINTER == 0) { errno = ENOMEM; } \ } while (0)
Definition at line 229 of file OS_Memory.h.
#define ACE_NEW_RETURN | ( | POINTER, | ||
CONSTRUCTOR, | ||||
RET_VAL | ||||
) |
do { POINTER = new CONSTRUCTOR; \ if (POINTER == 0) { errno = ENOMEM; return RET_VAL; } \ } while (0)
Definition at line 221 of file OS_Memory.h.
#define ACE_REALLOC_FUNC ::realloc |
Definition at line 56 of file OS_Memory.h.
#define ACE_throw_bad_alloc return 0 |
Definition at line 241 of file OS_Memory.h.
typedef void* ACE_MALLOC_T |
Definition at line 64 of file OS_Memory.h.
uintptr_t ACE_align_binary | ( | uintptr_t | ptr, | |
uintptr_t | alignment | |||
) | [inline] |
Return the next integer aligned to a required boundary.
Efficiently align "value" up to "alignment", knowing that all such boundaries are binary powers and that we're using two's complement arithmetic.
Since the alignment is a power of two its binary representation is:
alignment = 0...010...0
hence
alignment - 1 = 0...001...1 = T1
so the complement is:
~(alignment - 1) = 1...110...0 = T2
Notice that there is a multiple of alignment in the range [
,
+ T1], also notice that if
X = (
+ T1 ) & T2
then
<= X <=
+ T1
because the & operator only changes the last bits, and since X is a multiple of alignment (its last bits are zero) we have found the multiple we wanted.
ptr | the base pointer | |
alignment | the required alignment |
Definition at line 296 of file OS_Memory.h.
{ uintptr_t const tmp = alignment - 1; return (ptr + tmp) & (~tmp); }
char* ACE_ptr_align_binary | ( | unsigned char const * | ptr, | |
uintptr_t | alignment | |||
) | [inline] |
Return the next address aligned to a required boundary.
Definition at line 332 of file OS_Memory.h.
{ return ACE_ptr_align_binary (reinterpret_cast<char const *> (ptr), alignment); }
char* ACE_ptr_align_binary | ( | char const * | ptr, | |
uintptr_t | alignment | |||
) | [inline] |
Return the next address aligned to a required boundary.
Definition at line 323 of file OS_Memory.h.
{ return reinterpret_cast<char *> ( ACE_align_binary (reinterpret_cast<uintptr_t> (ptr), alignment)); }