Skip to content

PgAlign

Namespace: Ankus

Assembly: Ankus.Runtime.dll

PostgreSQL’s alignment macros from c.h, such as MAXALIGN, for sizes and offsets of structures PostgreSQL lays out, as pgrx’s pg_sys::align functions provide them.

public static class PgAlign

The constants are the ALIGNOF_* values every supported platform’s PostgreSQL defines; each is a power of two.

Inheritance: object

Rounds a length up to BufferAlignment, as BUFFERALIGN does.

public static nuint BufferAlign(nuint length)

Parameters:

length — nuint

The length to round.

Returns: nuint

The aligned length.

Rounds a length up to the alignment of C double, as DOUBLEALIGN does.

public static nuint DoubleAlign(nuint length)

Parameters:

length — nuint

The length to round.

Returns: nuint

The aligned length.

Rounds a length up to the alignment of C int, as INTALIGN does.

public static nuint IntAlign(nuint length)

Parameters:

length — nuint

The length to round.

Returns: nuint

The aligned length.

Rounds a length up to MaximumAlignment, as MAXALIGN does.

public static nuint MaxAlign(nuint length)

Parameters:

length — nuint

The length to round.

Returns: nuint

The aligned length.

Rounds a length down to a multiple of MaximumAlignment, as MAXALIGN_DOWN does.

public static nuint MaxAlignDown(nuint length)

Parameters:

length — nuint

The length to round.

Returns: nuint

The aligned length.

Rounds a length up to the alignment of C short, as SHORTALIGN does.

public static nuint ShortAlign(nuint length)

Parameters:

length — nuint

The length to round.

Returns: nuint

The aligned length.

Rounds a length up to a multiple of an alignment, as TYPEALIGN(alignval, len) does.

public static nuint TypeAlign(nuint alignment, nuint length)

Parameters:

alignment — nuint

The alignment, a power of two.

length — nuint

The length to round.

Returns: nuint

The smallest multiple of the alignment that is at least the length.

Exceptions:

Rounds a length down to a multiple of an alignment, as TYPEALIGN_DOWN(alignval, len) does.

public static nuint TypeAlignDown(nuint alignment, nuint length)

Parameters:

alignment — nuint

The alignment, a power of two.

length — nuint

The length to round.

Returns: nuint

The largest multiple of the alignment that is at most the length.

Exceptions:

The alignment of shared buffers, ALIGNOF_BUFFER.

public const int BufferAlignment = 32

The alignment of C double, ALIGNOF_DOUBLE.

public const int DoubleAlignment = 8

The alignment of C int, ALIGNOF_INT.

public const int IntAlignment = 4

The alignment PostgreSQL gives every palloc’d chunk and on-disk tuple, MAXIMUM_ALIGNOF.

public const int MaximumAlignment = 8

The alignment of C short, ALIGNOF_SHORT.

public const int ShortAlignment = 2