Missed from previus commit

This commit is contained in:
Nils O. Selåsdal
2013-04-25 23:08:39 +02:00
parent 4e1bd8a5a7
commit 88baa855a7
3 changed files with 20 additions and 9 deletions
+17 -8
View File
@@ -2,19 +2,28 @@
#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)
// Check if a is less than b, taking care of wrap arounds
static inline int uc_seq_lt(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)
// check if a is greather than b, taking care of wrap arounds
static inline int uc_seq_gt(uint32_t a, uint32_t b)
{
return c - b >= a - b;
return (int32_t)(a - b) > 0;
}
//
// Check if a is less than or equal to b, taking care of wrap arounds
static inline int uc_seq_leq(uint32_t a, uint32_t b)
{
return (int32_t)(a - b) <= 0;
}
// check if a is greather than or equal b, taking care of wrap arounds
static inline int uc_seq_geq(uint32_t a, uint32_t b)
{
return (int32_t)(a - b) >= 0;
}