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:
parent
af6060a987
commit
85ece84b1c
9 changed files with 12 additions and 22 deletions
|
@ -58,9 +58,6 @@ int strcmp(const char *, const char *);
|
|||
|
||||
void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
|
||||
|
||||
#define abs(x) ((x)>0?(x):-(x))
|
||||
#define labs(x) abs(x)
|
||||
|
||||
/*MDCT library functions*/
|
||||
|
||||
extern void mdct_backward(int n, int32_t *in, int32_t *out);
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#include "speex/speex_types.h"
|
||||
#endif
|
||||
|
||||
#undef ABS
|
||||
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
|
||||
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
|
||||
#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h> /* for ABS() */
|
||||
#include "config.h"
|
||||
#include "sprintf.h"
|
||||
#include "action.h"
|
||||
|
@ -42,8 +43,6 @@
|
|||
#include "tdspeed.h"
|
||||
#endif
|
||||
|
||||
#define ABS(x) ((x) > 0 ? (x) : -(x))
|
||||
|
||||
#define ICON_BORDER 12 /* icons are currently 7x8, so add ~2 pixels */
|
||||
/* on both sides when drawing */
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ PLUGIN_HEADER
|
|||
#define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */
|
||||
|
||||
#define SIGN(x) ((x)<0?-1:1)
|
||||
#define ABS(x) ((x)<0?-(x):(x))
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#define maxdepth 30
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define absv(x) ((x) < 0 ? -(x) : (x))
|
||||
#define absv(x) (ABS(x))
|
||||
#define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b]))
|
||||
|
||||
/* ---- Chess datatypes and variables ---- */
|
||||
|
|
|
@ -167,11 +167,6 @@ PLUGIN_HEADER
|
|||
#define UNUSED __attribute__ ((unused))
|
||||
#endif
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(x) (((x) < 0) ? (-(x)) : (x))
|
||||
#endif
|
||||
|
||||
|
||||
/* Defines common to all models */
|
||||
#define UFO_Y (SCORENUM_Y + FONT_HEIGHT + ALIEN_HEIGHT)
|
||||
#define PLAYFIELD_Y (LCD_HEIGHT - SHIP_HEIGHT - 2)
|
||||
|
|
|
@ -40,13 +40,6 @@
|
|||
* case that use a predefined context.
|
||||
*/
|
||||
|
||||
#define ABS(x) \
|
||||
({ \
|
||||
typeof(x) xtmp_abs_ = x; \
|
||||
xtmp_abs_ = xtmp_abs_ < 0 ? -xtmp_abs_ : xtmp_abs_; \
|
||||
xtmp_abs_; \
|
||||
})
|
||||
|
||||
/* Initialize buffer manager */
|
||||
void
|
||||
buflib_init(struct buflib_context *ctx, void *buf, size_t size)
|
||||
|
|
|
@ -246,8 +246,6 @@ PLUGIN_HEADER
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#define ABS(x) ((x)>0?(x):-(x))
|
||||
|
||||
#define RES MAX(LCD_WIDTH, LCD_HEIGHT)
|
||||
#define LARGE_LCD RES >= 200
|
||||
#define ENEMY_MISSILE_SURVIVAL_LENGTH RES/2
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue