V2: Use a single definition of MIN and MAX in sources

This commit is contained in:
Cristian Rodríguez
2012-04-05 19:39:37 -03:00
committed by Erik de Castro Lopo
parent d30fe60fc6
commit f029625591
11 changed files with 77 additions and 91 deletions

View File

@@ -0,0 +1,29 @@
#ifndef FLAC__PRIVATE__MACROS_H
#define FLAC__PRIVATE__MACROS_H
#if defined(__GNUC__)
#define flac_max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#define flac_min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
/* Whatever other unix that has sys/param.h */
#elif defined(HAVE_SYS_PARAM_H)
#include <sys/param.h>
#define flac_max(a,b) MAX(a,b)
#define flac_min(a,b) MIN(a,b)
/* Windows VS has them in stdlib.h.. XXX:Untested */
#elif defined(_MSC_VER)
#include <stdlib.h>
#define flac_max(a,b) __max(a,b)
#define flac_min(a,b) __min(a,b)
#endif
#endif