ACE 8.0.2
Loading...
Searching...
No Matches
Macros | Typedefs
OS_Memory.h File Reference
#include "ace/OS_Errno.h"
#include "ace/Basic_Types.h"
#include "ace/os_include/os_stddef.h"
#include "ace/OS_NS_stdlib.h"

Macros

#define ACE_MALLOC_FUNC   ::malloc
 
#define ACE_CALLOC_FUNC   ::calloc
 
#define ACE_FREE_FUNC   ::free
 
#define ACE_REALLOC_FUNC   ::realloc
 
#define ACE_bad_alloc   std::bad_alloc
 
#define ACE_nothrow   std::nothrow
 
#define ACE_nothrow_t   std::nothrow_t
 
#define ACE_del_bad_alloc
 
#define ACE_throw_bad_alloc   throw std::bad_alloc ()
 
#define ACE_NEW_RETURN(POINTER, CONSTRUCTOR, RET_VAL)
 
#define ACE_NEW(POINTER, CONSTRUCTOR)
 
#define ACE_NEW_NORETURN(POINTER, CONSTRUCTOR)
 

Typedefs

typedef voidACE_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.
 
charACE_ptr_align_binary (char const *ptr, uintptr_t alignment)
 Return the next address aligned to a required boundary.
 
charACE_ptr_align_binary (unsigned char const *ptr, uintptr_t alignment)
 Return the next address aligned to a required boundary.
 

Detailed Description

Author
Doug Schmidt d.sch.nosp@m.midt.nosp@m.@vand.nosp@m.erbi.nosp@m.lt.ed.nosp@m.u
Jesper S. M|llerstoph.nosp@m.ph@d.nosp@m.iku.d.nosp@m.k
and a cast of thousands...

Macro Definition Documentation

◆ ACE_bad_alloc

#define ACE_bad_alloc   std::bad_alloc

◆ ACE_CALLOC_FUNC

#define ACE_CALLOC_FUNC   ::calloc

◆ ACE_del_bad_alloc

#define ACE_del_bad_alloc

◆ ACE_FREE_FUNC

#define ACE_FREE_FUNC   ::free

◆ ACE_MALLOC_FUNC

#define ACE_MALLOC_FUNC   ::malloc

◆ ACE_NEW

#define ACE_NEW ( POINTER,
CONSTRUCTOR )
Value:
do { POINTER = new(std::nothrow) CONSTRUCTOR; \
if (POINTER == nullptr) { errno = ENOMEM; return; } \
} while (0)
This class inherits the interface of the abstract ACE_Dumpable class and is instantiated with the imp...
Definition Dump_T.h:39

◆ ACE_NEW_NORETURN

#define ACE_NEW_NORETURN ( POINTER,
CONSTRUCTOR )
Value:
do { POINTER = new(std::nothrow) CONSTRUCTOR; \
if (POINTER == nullptr) { errno = ENOMEM; } \
} while (0)

◆ ACE_NEW_RETURN

#define ACE_NEW_RETURN ( POINTER,
CONSTRUCTOR,
RET_VAL )
Value:
do { POINTER = new (std::nothrow) CONSTRUCTOR; \
if (POINTER == nullptr) { errno = ENOMEM; return RET_VAL; } \
} while (0)

◆ ACE_nothrow

#define ACE_nothrow   std::nothrow

◆ ACE_nothrow_t

#define ACE_nothrow_t   std::nothrow_t

◆ ACE_REALLOC_FUNC

#define ACE_REALLOC_FUNC   ::realloc

◆ ACE_throw_bad_alloc

#define ACE_throw_bad_alloc   throw std::bad_alloc ()

Typedef Documentation

◆ ACE_MALLOC_T

Function Documentation

◆ ACE_align_binary()

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.

Parameters
ptrthe base pointer
alignmentthe required alignment

◆ ACE_ptr_align_binary() [1/2]

char * ACE_ptr_align_binary ( char const * ptr,
uintptr_t alignment )
inline

Return the next address aligned to a required boundary.

◆ ACE_ptr_align_binary() [2/2]

char * ACE_ptr_align_binary ( unsigned char const * ptr,
uintptr_t alignment )
inline

Return the next address aligned to a required boundary.