X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fmisc.h;h=c2f865d90c95512d7ec4d3517c68dff96e0181d4;hb=ad05a0285feaa0faa4e1329b8ee985c2ce17b1c9;hp=69d3dc4f64043ef9e8929b703c3cd711c1e11d98;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp-builds.git diff --git a/src/libpspp/misc.h b/src/libpspp/misc.h index 69d3dc4f..c2f865d9 100644 --- a/src/libpspp/misc.h +++ b/src/libpspp/misc.h @@ -14,32 +14,14 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#if !math_misc_h -#define math_misc_h 1 +#if !libpspp_misc_h +#define libpspp_misc_h 1 #include #include #define EPSILON (10 * DBL_EPSILON) -/* HUGE_VAL is traditionally defined as positive infinity, or - alternatively, DBL_MAX. */ -#if !HAVE_ISINF && !defined isinf -#define isinf(X) (fabs (X) == HUGE_VAL) -#endif - -/* A Not a Number is not equal to itself. */ -#if !HAVE_ISNAN && !defined isnan -#define isnan(X) ((X) != (X)) -#endif - -/* Finite numbers are not infinities or NaNs. */ -#if !HAVE_FINITE && !defined finite -#define finite(X) (!isinf (X) && !isnan (X)) -#elif HAVE_IEEEFP_H -#include /* Declares finite() under Solaris. */ -#endif - /* Divides nonnegative X by positive Y, rounding up. */ #define DIV_RND_UP(X, Y) (((X) + ((Y) - 1)) / (Y)) @@ -78,4 +60,40 @@ pow4 (double x) return y; } -#endif /* math/misc.h */ +/* Set *DEST to the lower of *DEST and SRC */ +static inline void +minimize (double *dest, double src) +{ + if (src < *dest) + *dest = src; +} + + +/* Set *DEST to the greater of *DEST and SRC */ +static inline void +maximize (double *dest, double src) +{ + if (src > *dest) + *dest = src; +} + + +/* Set *DEST to the lower of *DEST and SRC */ +static inline void +minimize_int (int *dest, int src) +{ + if (src < *dest) + *dest = src; +} + + +/* Set *DEST to the greater of *DEST and SRC */ +static inline void +maximize_int (int *dest, int src) +{ + if (src > *dest) + *dest = src; +} + + +#endif /* libpspp/misc.h */