Skip to content

Detect the overflow of relocation counter #4

@francis0407

Description

@francis0407

Currently, we detect the overflow by checking if the latest counter is less than before:

        let (c00, c01, c10, c11) = (
            c00_u8.cast::<u16>(),
            c01_u8.cast::<u16>(),
            c10_u8.cast::<u16>(),
            c11_u8.cast::<u16>(),
        );
        (c10 < c00)
            || (c11 < c01)
            || (c10 >= c00.overflow_add(2)
                && c11 >= c01.overflow_add(2)
                && c11 >= c00.overflow_add(3))

But if the relocation happens more than once, this method does not work.

One solution is to leverage the highest bit of the counter as a overflow flag. We can check and reset the flag in this method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions