aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcathook <cat.hook31894@gmail.com>2013-11-26 14:31:33 +0800
committercathook <cat.hook31894@gmail.com>2013-11-26 14:31:33 +0800
commitde1d5e2e0935df9b9458222ffdbc1d257ffc5c24 (patch)
tree67b56525143c3da98473a6b333ad8732fd6716f7
parent7b3aa8f64a7ecaeb3411bf215cd2c842ff929ff1 (diff)
downloadctl-de1d5e2e0935df9b9458222ffdbc1d257ffc5c24.tar.gz
ctl-de1d5e2e0935df9b9458222ffdbc1d257ffc5c24.tar.zst
ctl-de1d5e2e0935df9b9458222ffdbc1d257ffc5c24.zip
add max(), min() functions
-rw-r--r--include/utility.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/utility.h b/include/utility.h
index f51a646..2e2de7e 100644
--- a/include/utility.h
+++ b/include/utility.h
@@ -36,6 +36,8 @@
/* ctl_free like free(), but will return NULL */
/* ctl_die print some message and exit() */
/* ctl_swap swap two elements with given type */
+/* ctl_max return the max of the two arguments */
+/* ctl_min return the min of the two arguments */
/* */
/**********************************************************/
@@ -104,5 +106,7 @@ pvoid ctl_free (pvoid ptr);
void ctl_die (ErrorType e);
#define ctl_swap(X,Y,Z) do{X zzzztmp=(Y);(Y)=(Z);(Z)=zzzztmp;}while(0)
+#define ctl_max(X,Y) ((X) > (Y) ? (X) : (Y))
+#define ctl_min(X,Y) ((X) < (Y) ? (X) : (Y))
#endif /* __utility_h__ */