Merge commit 'origin/stable'
[pspp-builds.git] / src / libpspp / misc.h
index f3afb1fb91a88b8d91fd7835a1ab754d95fa06c4..c2f865d90c95512d7ec4d3517c68dff96e0181d4 100644 (file)
@@ -35,8 +35,6 @@
 /* Rounds X down to the previous multiple of Y. */
 #define ROUND_DOWN(X, Y) ((X) / (Y) * (Y))
 
-#define SQR(X) ((X) * (X))
-
 int intlog10 (unsigned);
 
 /* Returns the square of X. */
@@ -79,4 +77,23 @@ maximize (double *dest, double src)
     *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 */