BloombergLP::bsls::AlignmentUtil::calculateAlignmentOffset

Return the offset needed to align the specified address.

Synopsis

Declared in <bsls_alignmentutil.h>

static
int
calculateAlignmentOffset(
    void const* address,
    int alignment);

Description

Return the minimum non-negative integer that, when added to the numerical value of the specified address, yields the specified alignment. The behavior is undefined unless alignment is a positive, integral power of 2.

Return Value

minimum non-negative offset in bytes

Parameters

NameDescription
addressmemory address from which the offset is measured
alignmentalignment boundary, a positive power of 2