def alignto(alignment_value: int, bitposition: int) -> int:
    """
    Aligns the bit size to the given alignment value.

    :param alignment_value: Value to align.
    :param bitposition: Current bit position where to apply alignment.
    :returns: Aligned bit position.
    """

    if bitposition <= 0 or alignment_value == 0:
        return bitposition

    return (((bitposition - 1) // alignment_value) + 1) * alignment_value