X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fmisc.h;h=1698297dc4cc51a2694f55d831c740d4eb601694;hb=2c6814f86fdade89b4b615b0d5b7c6c9c8d1bc1a;hp=69d3dc4f64043ef9e8929b703c3cd711c1e11d98;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp diff --git a/src/libpspp/misc.h b/src/libpspp/misc.h index 69d3dc4f64..1698297dc4 100644 --- a/src/libpspp/misc.h +++ b/src/libpspp/misc.h @@ -14,32 +14,15 @@ 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 #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 +61,42 @@ 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; +} + +int c_dtoastr (char *buf, size_t bufsize, int flags, int width, double x); + + +#endif /* libpspp/misc.h */