From 18723cfbe44d2b0d1bfecc763d1a1c24c9c866ce Mon Sep 17 00:00:00 2001 From: pjrm Date: Mon, 13 Jul 2009 03:18:56 +0000 Subject: [PATCH] libnr/nr-macros.h: Change our CLAMP macro definition to provide both CLAMP and NR_CLAMP, and make it take precedence over any existing CLAMP macro (such as the one from Glib, which doesn't behave the way we want for NaN). --- src/libnr/nr-macros.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libnr/nr-macros.h b/src/libnr/nr-macros.h index 0e0307916..37a3675e6 100644 --- a/src/libnr/nr-macros.h +++ b/src/libnr/nr-macros.h @@ -30,19 +30,20 @@ #define MIN(a,b) (((a) > (b)) ? (b) : (a)) #endif -#ifndef CLAMP /** Returns v bounded to within [a, b]. If v is NaN then returns a. * * \pre \a a \<= \a b. */ -# define CLAMP(v,a,b) \ +#define NR_CLAMP(v,a,b) \ (assert (a <= b), \ ((v) >= (a)) \ ? (((v) > (b)) \ ? (b) \ : (v)) \ : (a)) -#endif + +#undef CLAMP /* get rid of glib's version, which doesn't handle NaN correctly */ +#define CLAMP(v,a,b) NR_CLAMP(v,a,b) #define NR_DF_TEST_CLOSE(a,b,e) (fabs ((a) - (b)) <= (e)) -- 2.30.2