diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2008-02-21 20:42:43 +0000 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2008-02-21 20:42:43 +0000 |
commit | fca3078db2ccba41e2c435d6b66375b54877e699 (patch) | |
tree | 57e869841521182c5fe0b145c5f6fc019f373ecb | |
parent | ec2222d9df64e105529ef16a34ff00014d342fd6 (diff) | |
download | fbtest-fca3078db2ccba41e2c435d6b66375b54877e699.tar.gz |
Add absolute value
-rw-r--r-- | include/util.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/util.h b/include/util.h index 864ddbd..64d8104 100644 --- a/include/util.h +++ b/include/util.h @@ -46,7 +46,7 @@ extern void Debug(const char *fmt, ...) /* - * Minimum and maximum + * Minimum, maximum, and absolute value */ #undef min @@ -65,6 +65,13 @@ extern void Debug(const char *fmt, ...) _a > _b ? _a : _b; \ } ) +#undef abs +#define abs(x) \ + ( { \ + typeof(x) _x = (x); \ + _x >= 0 ? _x : -_x; \ + } ) + /* * Wait |