]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mathlib.c
- the Linux sound modules (ALSA and OSS) are now write-based, instead of
[xonotic/darkplaces.git] / mathlib.c
index 36e858dee589dca6c48541c8730375e5a6340db1..eaa1a765d8e05bc5c65328a808591ad5053941e1 100644 (file)
--- a/mathlib.c
+++ b/mathlib.c
@@ -254,6 +254,24 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,
               + (t0 * vr[2] + t1 * vu[2] + vf[2] * vf[2]) * point[2];
 }
 
+/*-----------------------------------------------------------------*/
+
+// returns the smallest integer greater than or equal to "value", or 0 if "value" is too big
+unsigned int CeilPowerOf2(unsigned int value)
+{
+       unsigned int ceilvalue;
+
+       if (value > (1U << (sizeof(int) * 8 - 1)))
+               return 0;
+
+       ceilvalue = 1;
+       while (ceilvalue < value)
+               ceilvalue <<= 1;
+
+       return ceilvalue;
+}
+
+
 /*-----------------------------------------------------------------*/