diff --git a/ChangeLog b/ChangeLog index 60ce33ee..64a84a1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-09-02 Erik de Castro Lopo + + * src/common.h + Make the SF_MIN and SF_MAX macros at least partially type safe. + 2006-08-31 Erik de Castro Lopo * configure.ac docs/*.html diff --git a/src/common.h b/src/common.h index 30367fbb..7c35b1cc 100644 --- a/src/common.h +++ b/src/common.h @@ -72,8 +72,22 @@ #define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0]))) +#if (COMPILER_IS_GCC == 1) +#define SF_MAX(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +#define SF_MIN(x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) +#else #define SF_MAX(a,b) ((a) > (b) ? (a) : (b)) #define SF_MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif enum { /* PEAK chunk location. */