diff --git a/libgimpmath/gimpmath.h b/libgimpmath/gimpmath.h index b7f5d6a81a..c26acc3710 100644 --- a/libgimpmath/gimpmath.h +++ b/libgimpmath/gimpmath.h @@ -117,6 +117,20 @@ G_BEGIN_DECLS **/ #define CLAMP0255(a) CLAMP(a,0,255) +/** + * SAFE_CLAMP: + * @x: the value to be limited. + * @low: the lower limit. + * @high: the upper limit. + * + * Ensures that @x is between the limits set by @low and @high, + * even if @x is NaN. If @low is greater than @high, or if either + * of them is NaN, the result is undefined. + * + * Since: 2.10 + **/ +#define SAFE_CLAMP(x, low, high) ((x) > (low) ? (x) < (high) ? (x) : (high) : (low)) + /** * gimp_deg_to_rad: * @angle: the angle to be converted.