#include #include #define s32_t int32_t #define u32_t uint32_t const uint32_t c1 = 0x00000001; const uint32_t c2 = 0x00000102; const uint32_t c3 = 0x80000002; const uint32_t c4 = 0x80000012; #define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) #define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) #define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) #define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) static void test(uint32_t x1, uint32_t x2) { printf ("testing 0x%08x %c 0x%08x\n", (int)x1, TCP_SEQ_LT(x1, x2)?'<':'>', (int)x2); } int main(int argc, char *argv[]) { test (c1, c2); test (c2, c3); test (c3, c4); test (c4, c1); test (c2, c1); test (c3, c2); test (c4, c3); test (c1, c4); return 0; }