rfc_1982.c File Reference

This file contains functions for RFC 1982 serial number arithmetic. More...

#include "config.h"
#include "util/rfc_1982.h"

Functions

int compare_1982 (uint32_t a, uint32_t b)
 RFC 1982 comparison, uses unsigned integers, and tries to avoid compiler optimization (eg. More...
 
uint32_t subtract_1982 (uint32_t a, uint32_t b)
 RFC 1982 subtraction, uses unsigned integers, and tries to avoid compiler optimization (eg. More...
 

Detailed Description

This file contains functions for RFC 1982 serial number arithmetic.

Function Documentation

◆ compare_1982()

int compare_1982 ( uint32_t  a,
uint32_t  b 
)

RFC 1982 comparison, uses unsigned integers, and tries to avoid compiler optimization (eg.

by avoiding a-b<0 comparisons).

Parameters
avalue to compare.
bvalue to compare.
Returns
0 if equal, 1 if a > b, else -1.

Referenced by check_dates().

◆ subtract_1982()

uint32_t subtract_1982 ( uint32_t  a,
uint32_t  b 
)

RFC 1982 subtraction, uses unsigned integers, and tries to avoid compiler optimization (eg.

by avoiding a-b<0 comparisons).

Parameters
avalue to subtract from.
bvalue to subtract.
Returns
the difference between them if we know that b is larger than a, that is the distance between them in serial number arithmetic.