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_ #define SEQ_H_
#include <stdint.h> #include <stdint.h>
// Check if a is before b, taking care of wrap arounds // Check if a is less than b, taking care of wrap arounds
static inline int seq_before(uint32_t a, uint32_t b) static inline int uc_seq_lt(uint32_t a, uint32_t b)
{ {
return (int32_t)(a - b) < 0; return (int32_t)(a - b) < 0;
} }
// check if a is before b, taking care of wrap arounds // check if a is greather than b, taking care of wrap arounds
#define seq_after(a, b) before(b, a) static inline int uc_seq_gt(uint32_t a, uint32_t b)
//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; 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;
} }
+1 -1
View File
@@ -4,7 +4,7 @@
void check_before(uint32_t a, uint32_t b) void check_before(uint32_t a, uint32_t b)
{ {
printf("%lu before %lu = %d\n", a ,b, seq_before(a, b)); printf("%lu before %lu = %d\n", a ,b, seq_lt(a, b));
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
+2
View File
@@ -16,6 +16,7 @@ extern Suite *logging_suite(void);
extern Suite *threadqueue_suite(void); extern Suite *threadqueue_suite(void);
extern Suite *buffer_suite(void); extern Suite *buffer_suite(void);
extern Suite *clock_suite(void); extern Suite *clock_suite(void);
extern Suite *seq_suite(void);
static suite_func suites[] = { static suite_func suites[] = {
bitvec_suite, bitvec_suite,
@@ -28,6 +29,7 @@ static suite_func suites[] = {
threadqueue_suite, threadqueue_suite,
buffer_suite, buffer_suite,
clock_suite, clock_suite,
seq_suite,
}; };
int int