OS_Memory.h File Reference

Go to the source code of this file.

Classes

class  ACE_bad_alloc_class

Functions

Efficiently compute aligned pointers to powers of 2 boundaries.



unsigned int ACE_align_binary (unsigned int ptr, unsigned int alignment)
 Return the next integer aligned to a required boundary.
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, unsigned int alignment)
 Return the next address aligned to a required boundary.
char * ACE_ptr_align_binary (unsigned char const *ptr, unsigned int alignment)
 Return the next address 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.

Variables

ACE_BEGIN_VERSIONED_NAMESPACE_DECL
typedef char * 
ACE_MALLOC_T

Detailed Description

Id
OS_Memory.h 86400 2009-08-06 13:52:28Z schmidt
Author:
Doug Schmidt <schmidt@cs.wustl.edu>
Jesper S. M|ller<stophph@diku.dk>
and a cast of thousands...

Definition in file OS_Memory.h.


Function Documentation

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:
ptr the base pointer
alignment the required alignment

Definition at line 296 of file OS_Memory.h.

00297 {
00298   uintptr_t const tmp = alignment - 1;
00299   return (ptr + tmp) & (~tmp);
00300 }

unsigned int ACE_align_binary ( unsigned int  ptr,
unsigned int  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:
ptr the base pointer
alignment the required alignment

Definition at line 289 of file OS_Memory.h.

00290 {
00291   unsigned int const tmp = alignment - 1;
00292   return (ptr + tmp) & (~tmp);
00293 }

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.

00333 {
00334   return
00335     ACE_ptr_align_binary (reinterpret_cast<char const *> (ptr), alignment);
00336 }

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.

00324 {
00325   return
00326     reinterpret_cast<char *> (
00327       ACE_align_binary (reinterpret_cast<uintptr_t> (ptr), alignment));
00328 }

char* ACE_ptr_align_binary ( unsigned char const *  ptr,
unsigned int  alignment 
) [inline]

Return the next address aligned to a required boundary.

Definition at line 315 of file OS_Memory.h.

00316 {
00317   return
00318     ACE_ptr_align_binary (reinterpret_cast<char const *> (ptr), alignment);
00319 }

char* ACE_ptr_align_binary ( char const *  ptr,
unsigned int  alignment 
) [inline]

Return the next address aligned to a required boundary.

Definition at line 306 of file OS_Memory.h.

00307 {
00308   return
00309     reinterpret_cast<char *> (
00310       ACE_align_binary (reinterpret_cast<unsigned int> (ptr), alignment));
00311 }


Variable Documentation

typedef void * ACE_MALLOC_T

Definition at line 62 of file OS_Memory.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sat Nov 21 23:13:11 2009 for ACE by  doxygen 1.6.1