1
0
Fork 0
forked from len0rd/rockbox

Remove various ABS() definitions with a single one using typeof (if using gcc) to avoid multiple evaluations of the input expressions. Speex still uses its own as I didn't want to change this imported code too much.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22129 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-08-03 01:38:58 +00:00
parent af6060a987
commit 85ece84b1c
9 changed files with 12 additions and 22 deletions

View file

@ -35,7 +35,15 @@ void *realloc(void *, size_t);
void srand(unsigned int seed);
int rand(void);
#define abs(x) ((x)>0?(x):-(x))
#ifndef ABS
#if defined(__GNUC__)
#define ABS(a) ({typeof (a) ___a = (a); ___a < 0 ? -___a: ___a; })
#else
#define ABS(a) (((a) < 0) ? -(a) : (a))
#endif /* __GNUC__ */
#endif
#define abs(x) (ABS(x))
#define labs(x) abs(x)
#ifdef SIMULATOR