Make the SF_MIN and SF_MAX macros at least partially type safe.

This commit is contained in:
Erik de Castro Lopo 2006-09-02 01:12:54 +00:00
parent b51bab566c
commit 2b06fbb022
2 changed files with 19 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2006-09-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h
Make the SF_MIN and SF_MAX macros at least partially type safe.
2006-08-31 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac docs/*.html

View File

@ -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. */