about summary refs log tree commit diff
path: root/lib/util/pm_c_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/pm_c_util.h')
-rw-r--r--lib/util/pm_c_util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/util/pm_c_util.h b/lib/util/pm_c_util.h
index f21a2f82..07913f30 100644
--- a/lib/util/pm_c_util.h
+++ b/lib/util/pm_c_util.h
@@ -15,6 +15,16 @@
 #define ROUND(X) (((X) >= 0) ? (int)((X)+0.5) : (int)((X)-0.5))
 #undef ROUNDU
 #define ROUNDU(X) ((unsigned int)((X)+0.5))
+
+/* ROUNDUP rounds up to a specified multiple.  E.g. ROUNDUP(22, 8) == 24 */
+
+#undef ROUNDUP
+#define ROUNDUP(X,M) (((X)+(M)-1)/(M)*(M))
+#undef ROUNDDN
+#define ROUNDDN(X,M) ((X)/(M)*(M))
+
+#define ROUNDDIV(DIVIDEND,DIVISOR) (((DIVIDEND) + (DIVISOR)/2)/(DIVISOR))
+
 #undef SQR
 #define SQR(a) ((a)*(a))