22 lines
440 B
C
22 lines
440 B
C
#ifndef SEQ_H_
|
|
#define SEQ_H_
|
|
#include <stdint.h>
|
|
|
|
// Check if a is before b, taking care of wrap arounds
|
|
static inline int seq_before(uint32_t a, uint32_t b)
|
|
{
|
|
return (int32_t)(a - b) < 0;
|
|
}
|
|
|
|
// check if a is before b, taking care of wrap arounds
|
|
#define seq_after(a, b) before(b, a)
|
|
|
|
//check if a is between b or c
|
|
static inline int seqbetween(uint32_t a, uint32_t b, uint32_t c)
|
|
{
|
|
return c - b >= a - b;
|
|
}
|
|
|
|
|
|
#endif
|