Linus Lüssing wrote:
Sorry still does not seem to work :). Despite testing it on a setup in batman itself I also tested it with a small c program (which does not work as expected either):
But your version works? I would really doubt that when we do the same. The macro will only replace the thing and we would have the same formular in that situation.
#include <stdio.h> #include <stdint.h>
#define seq_before(x,y) ((x - y) > 1 << 7 + 8 * (sizeof(x) - 1)) #define seq_after(x,y) ((y - x) >= 1 << 7 + 8 * (sizeof(x) - 1))
int main() { uint8_t old = 0; uint8_t new = 1; if (!seq_after(new,old)) printf("foobar\n");
return 0;
}
$ ./test foobar $
Now it gets real cruel, but who cares... C++ wasn't accept in the kernel, so we have to deal with it using some GNUish stuff.
#define seq_before(x,y) ({typeof(x) _dummy = (x - y); \ _dummy > 1u << (7u + 8u * (sizeof(_dummy) - 1u));}) #define seq_after(x,y) ({typeof(x) _dummy = (y - x); \ _dummy >= 1u << (7u + 8u * (sizeof(_dummy) - 1u));})
Thanks for testing (I never did it :) ) and please test that one.
Best regards, Sven