Serial Number Arithmetic

Serial Number Arithmetic (RFC 1982) More...

Detailed Description

Serial Number Arithmetic (RFC 1982)

Files

file  seq.h
 Serial Number Arithmetic (RFC 1982)
 

Macros

#define SEQ_LIMIT(X)   (X >> 1)
 Maximum for the addition of a positive integer. More...
 

Typedefs

typedef uint8_t seq8_t
 A 8 bit sequence number.
 
typedef uint16_t seq16_t
 A 16 bit sequence number.
 
typedef uint32_t seq32_t
 A 32 bit sequence number.
 
typedef uint64_t seq64_t
 A 64 bit sequence number.
 

Functions

seq8_t seq8_adds (seq8_t s, uint8_t n, uint8_t space)
 Addition of a 8 bit sequence number s and a positive integer n in the serial number space. More...
 
static seq8_t seq8_add (seq8_t s, uint8_t n)
 Addition of a 8 bit sequence number s and a positive integer n in the serial number space UINT8_MAX. More...
 
static seq8_t seq8_incs (seq8_t s, uint8_t space)
 Increment a sequence number s by 1 in the serial number space. More...
 
static seq8_t seq8_inc (seq8_t s)
 Increment a sequence number s by 1 in the serial number space UINT8_MAX. More...
 
int seq8_compares (seq8_t s1, seq8_t s2, uint8_t space)
 Compare sequence numbers s1, s2 in the serial number space. More...
 
static int seq8_compare (seq8_t s1, seq8_t s2)
 Compare sequence numbers s1, s2 in the serial number space UINT8_MAX. More...
 
seq16_t seq16_adds (seq16_t s, uint16_t n, uint16_t space)
 Addition of a 16 bit sequence number s and a positive integer n in the serial number space. More...
 
static seq16_t seq16_add (seq16_t s, uint16_t n)
 Addition of a 16 bit sequence number s and a positive integer n in the serial number space UINT16_MAX. More...
 
static seq16_t seq16_incs (seq16_t s, uint16_t space)
 Increment a sequence number s by 1 in the serial number space. More...
 
static seq16_t seq16_inc (seq16_t s)
 Increment a sequence number s by 1 in the serial number space UINT16_MAX. More...
 
int seq16_compares (seq16_t s1, seq16_t s2, uint16_t space)
 Compare sequence numbers s1, s2 in the serial number space. More...
 
static int seq16_compare (seq16_t s1, seq16_t s2)
 Compare sequence numbers s1, s2 in the serial number space UINT16_MAX. More...
 
seq32_t seq32_adds (seq32_t s, uint32_t n, uint32_t space)
 Addition of a 32 bit sequence number s and a positive integer n in the serial number space. More...
 
static seq32_t seq32_add (seq32_t s, uint32_t n)
 Addition of a 32 bit sequence number s and a positive integer n in the serial number space UINT32_MAX. More...
 
static seq32_t seq32_incs (seq32_t s, uint32_t space)
 Increment a sequence number s by 1 in the serial number space. More...
 
static seq32_t seq32_inc (seq32_t s)
 Increment a sequence number s by 1 in the serial number space UINT32_MAX. More...
 
int seq32_compares (seq32_t s1, seq32_t s2, uint32_t space)
 Compare sequence numbers s1, s2 in the serial number space. More...
 
static int seq32_compare (seq32_t s1, seq32_t s2)
 Compare sequence numbers s1, s2 in the serial number space UINT32_MAX. More...
 
seq64_t seq64_adds (seq64_t s, uint64_t n, uint64_t space)
 Addition of a 64 bit sequence number s and a positive integer n in the serial number space. More...
 
static seq64_t seq64_add (seq64_t s, uint64_t n)
 Addition of a 64 bit sequence number s and a positive integer n in the serial number space UINT64_MAX. More...
 
static seq64_t seq64_incs (seq64_t s, uint64_t space)
 Increment a sequence number s by 1 in the serial number space. More...
 
static seq64_t seq64_inc (seq64_t s)
 Increment a sequence number s by 1 in the serial number space UINT64_MAX. More...
 
int seq64_compares (seq64_t s1, seq64_t s2, uint64_t space)
 Compare sequence numbers s1, s2 in the serial number space. More...
 
static int seq64_compare (seq64_t s1, seq64_t s2)
 Compare sequence numbers s1, s2 in the serial number space UINT64_MAX. More...
 

Macro Definition Documentation

◆ SEQ_LIMIT

#define SEQ_LIMIT (   X)    (X >> 1)

Maximum for the addition of a positive integer.

X denotes the size of the space

Definition at line 37 of file seq.h.

Function Documentation

◆ seq16_add()

static seq16_t seq16_add ( seq16_t  s,
uint16_t  n 
)
inlinestatic

Addition of a 16 bit sequence number s and a positive integer n in the serial number space UINT16_MAX.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. 127]
Returns
s + n, if valid
s, if n is out of range

Definition at line 167 of file seq.h.

◆ seq16_adds()

seq16_t seq16_adds ( seq16_t  s,
uint16_t  n,
uint16_t  space 
)

Addition of a 16 bit sequence number s and a positive integer n in the serial number space.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. ((space / 2) - 1)]
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + n, if valid
s, if n is out of range

◆ seq16_compare()

static int seq16_compare ( seq16_t  s1,
seq16_t  s2 
)
inlinestatic

Compare sequence numbers s1, s2 in the serial number space UINT16_MAX.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

Definition at line 220 of file seq.h.

◆ seq16_compares()

int seq16_compares ( seq16_t  s1,
seq16_t  s2,
uint16_t  space 
)

Compare sequence numbers s1, s2 in the serial number space.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

◆ seq16_inc()

static seq16_t seq16_inc ( seq16_t  s)
inlinestatic

Increment a sequence number s by 1 in the serial number space UINT16_MAX.

Parameters
[in]ssequence number
Returns
s + 1

Definition at line 188 of file seq.h.

◆ seq16_incs()

static seq16_t seq16_incs ( seq16_t  s,
uint16_t  space 
)
inlinestatic

Increment a sequence number s by 1 in the serial number space.

Parameters
[in]ssequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + 1

Definition at line 178 of file seq.h.

◆ seq32_add()

static seq32_t seq32_add ( seq32_t  s,
uint32_t  n 
)
inlinestatic

Addition of a 32 bit sequence number s and a positive integer n in the serial number space UINT32_MAX.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. 127]
Returns
s + n, if valid
s, if n is out of range

Definition at line 250 of file seq.h.

◆ seq32_adds()

seq32_t seq32_adds ( seq32_t  s,
uint32_t  n,
uint32_t  space 
)

Addition of a 32 bit sequence number s and a positive integer n in the serial number space.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. ((space / 2) - 1)]
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + n, if valid
s, if n is out of range

◆ seq32_compare()

static int seq32_compare ( seq32_t  s1,
seq32_t  s2 
)
inlinestatic

Compare sequence numbers s1, s2 in the serial number space UINT32_MAX.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

Definition at line 303 of file seq.h.

◆ seq32_compares()

int seq32_compares ( seq32_t  s1,
seq32_t  s2,
uint32_t  space 
)

Compare sequence numbers s1, s2 in the serial number space.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

◆ seq32_inc()

static seq32_t seq32_inc ( seq32_t  s)
inlinestatic

Increment a sequence number s by 1 in the serial number space UINT32_MAX.

Parameters
[in]ssequence number
Returns
s + 1

Definition at line 271 of file seq.h.

◆ seq32_incs()

static seq32_t seq32_incs ( seq32_t  s,
uint32_t  space 
)
inlinestatic

Increment a sequence number s by 1 in the serial number space.

Parameters
[in]ssequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + 1

Definition at line 261 of file seq.h.

◆ seq64_add()

static seq64_t seq64_add ( seq64_t  s,
uint64_t  n 
)
inlinestatic

Addition of a 64 bit sequence number s and a positive integer n in the serial number space UINT64_MAX.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. 127]
Returns
s + n, if valid
s, if n is out of range

Definition at line 333 of file seq.h.

◆ seq64_adds()

seq64_t seq64_adds ( seq64_t  s,
uint64_t  n,
uint64_t  space 
)

Addition of a 64 bit sequence number s and a positive integer n in the serial number space.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. ((space / 2) - 1)]
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + n, if valid
s, if n is out of range

◆ seq64_compare()

static int seq64_compare ( seq64_t  s1,
seq64_t  s2 
)
inlinestatic

Compare sequence numbers s1, s2 in the serial number space UINT64_MAX.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

Definition at line 386 of file seq.h.

◆ seq64_compares()

int seq64_compares ( seq64_t  s1,
seq64_t  s2,
uint64_t  space 
)

Compare sequence numbers s1, s2 in the serial number space.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

◆ seq64_inc()

static seq64_t seq64_inc ( seq64_t  s)
inlinestatic

Increment a sequence number s by 1 in the serial number space UINT64_MAX.

Parameters
[in]ssequence number
Returns
s + 1

Definition at line 354 of file seq.h.

◆ seq64_incs()

static seq64_t seq64_incs ( seq64_t  s,
uint64_t  space 
)
inlinestatic

Increment a sequence number s by 1 in the serial number space.

Parameters
[in]ssequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + 1

Definition at line 344 of file seq.h.

◆ seq8_add()

static seq8_t seq8_add ( seq8_t  s,
uint8_t  n 
)
inlinestatic

Addition of a 8 bit sequence number s and a positive integer n in the serial number space UINT8_MAX.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. 127]
Returns
s + n, if valid
s, if n is out of range

Definition at line 84 of file seq.h.

◆ seq8_adds()

seq8_t seq8_adds ( seq8_t  s,
uint8_t  n,
uint8_t  space 
)

Addition of a 8 bit sequence number s and a positive integer n in the serial number space.

See also
3.1. Addition
Parameters
[in]ssequence number
[in]npositive integer in the range of [0 .. ((space / 2) - 1)]
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + n, if valid
s, if n is out of range

◆ seq8_compare()

static int seq8_compare ( seq8_t  s1,
seq8_t  s2 
)
inlinestatic

Compare sequence numbers s1, s2 in the serial number space UINT8_MAX.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

Definition at line 137 of file seq.h.

◆ seq8_compares()

int seq8_compares ( seq8_t  s1,
seq8_t  s2,
uint8_t  space 
)

Compare sequence numbers s1, s2 in the serial number space.

See also
3.2. Comparison
Parameters
[in]s1first sequence number
[in]s2second sequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
-1, if s1 < s2
0, if s1 == s2
1, if s1 > s2
-EINVAL, if comparison of the pair (s1,s2) is undefined

◆ seq8_inc()

static seq8_t seq8_inc ( seq8_t  s)
inlinestatic

Increment a sequence number s by 1 in the serial number space UINT8_MAX.

Parameters
[in]ssequence number
Returns
s + 1

Definition at line 105 of file seq.h.

◆ seq8_incs()

static seq8_t seq8_incs ( seq8_t  s,
uint8_t  space 
)
inlinestatic

Increment a sequence number s by 1 in the serial number space.

Parameters
[in]ssequence number
[in]spaceserial number space must be a power of 2 minus 1
Returns
s + 1

Definition at line 95 of file seq.h.