@staticmethod
def diffWithOverflowCheck(new, old):
    """
        do a difference with overflow check and repair
        the counter is unsigned 32 or 64 bit
        """
    if new >= old:
        return new - old
    else:
        maxv = (1 << 31) * 2
        if old >= maxv:
            maxv = (1 << 63) * 2
        return new - old + maxv
