BDE 4.14.0 Production release
|
#include <bsls_alignment.h>
Classes | |
struct | Align |
Public Types | |
enum | Strategy { BSLS_MAXIMUM = 0 , BSLS_NATURAL = 1 , BSLS_BYTEALIGNED = 2 } |
Types of alignment strategy. More... | |
enum | { MAX_ALIGNMENT = AlignmentUtil::BSLS_MAX_ALIGNMENT } |
typedef AlignmentUtil::MaxAlignedType | MaxAlignedType |
Static Public Member Functions | |
static const char * | toAscii (Alignment::Strategy value) |
static int | calculateAlignmentFromSize (int size) |
static int | calculateAlignmentOffset (const void *address, int alignment) |
static bool | is2ByteAligned (const void *address) |
static bool | is4ByteAligned (const void *address) |
static bool | is8ByteAligned (const void *address) |
This struct
provides a namespace for enumerating the set of strategies for aligning arbitrary blocks of memory.
Primitive type with most stringent alignment requirement.
anonymous enum |
Define the minimum alignment that satisfies all types.
enum
is deprecated. Use AlignmentUtil::BSLS_MAX_ALIGNMENT
instead. Enumerator | |
---|---|
MAX_ALIGNMENT |
Enumerator | |
---|---|
BSLS_MAXIMUM | Align memory block based on the most restrictive alignment requirements of the host platform. |
BSLS_NATURAL | Align memory block on an address that is the largest power of two that evenly divides the size (in bytes) of the block. |
BSLS_BYTEALIGNED | Align memory block based on the least restrictive alignment requirements of the host platform (1-byte aligned). |
|
inlinestatic |
Calculate a usable alignment for an object of specified size
bytes in the absence of compile-time knowledge of the object's alignment requirements. Return the largest power of two that evenly divides size, up to a maximum of MAX_ALIGNMENT
. It is guaranteed that an object of size
bytes can be safely aligned on this return value. Depending on the machine architecture and compiler options, the returned alignment may be more than required for two reasons:
The behavior is undefined unless 0 < size
.
|
inlinestatic |
Return the smallest non-negative offset in bytes that, when added to the specified address
, yields the specified alignment
. The behavior is undefined unless 0 < alignment
and alignment
is a power of 2.
|
inlinestatic |
Return true
if the specified address
is aligned on a 2-byte boundary (i.e., the integer value of address
is divisible by 2), and false
otherwise.
|
inlinestatic |
Return true
if the specified address
is aligned on a 4-byte boundary (i.e., the integer value of address
is divisible by 4), and false
otherwise.
|
inlinestatic |
Return true
if the specified address
is aligned on an 8-byte boundary (i.e., the integer value of address
is divisible by 8), and false
otherwise.
|
static |
Return the string representation of the specified enumerator value
. The string representation of value
matches its corresponding enumerator name with the "BSLS_" prefix elided. For example:
will print the following on standard output: