summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-06-16 18:22:45 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:05 +0200
commit56f09fa03da99cc34620c9d3569a3d06e5c95c11 (patch)
treeb98737a8c87f923cbe031d31538f6ab29f609eeb
parent4291329d563c12dedca4b911accb7cae077225da (diff)
downloadmpv-56f09fa03da99cc34620c9d3569a3d06e5c95c11.tar.bz2
mpv-56f09fa03da99cc34620c9d3569a3d06e5c95c11.tar.xz
common: add macro for checking whether a value is a power of two
I think I repeated this inline in some places (or maybe not), and some experimental but discarded code used it. Add it anyway, maybe it'll be useful. Or it'll give someone a chance to get a contribution into mpv by removing an unused macro.
-rw-r--r--common/common.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/common/common.h b/common/common.h
index f5392fc575..16e1ec4cfd 100644
--- a/common/common.h
+++ b/common/common.h
@@ -44,6 +44,7 @@
#define MP_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
#define MP_ALIGN_DOWN(x, align) ((x) & ~((align) - 1))
#define MP_IS_ALIGNED(x, align) (!((x) & ((align) - 1)))
+#define MP_IS_POWER_OF_2(x) ((x) > 0 && !((x) & ((x) - 1)))
// Return "a", or if that is NOPTS, return "def".
#define MP_PTS_OR_DEF(a, def) ((a) == MP_NOPTS_VALUE ? (def) : (a))