summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2010-10-27 20:51:45 +0900
committertmk <nobody@nowhere>2010-10-27 22:56:01 +0900
commit2f80e790c6310ad24a4cb3d4a72c31314364fef7 (patch)
treeaad001abdb61ff736e580f98184ab7cd9e870648 /util.c
parent461e0d3d8c82cc78d29d3115af3c417bb51bb50f (diff)
new build method for macway
Diffstat (limited to 'util.c')
-rw-r--r--util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000000..b02d077cc3
--- /dev/null
+++ b/util.c
@@ -0,0 +1,18 @@
+#include "util.h"
+
+int bitpop(uint8_t bits)
+{
+ int c;
+ for (c = 0; bits; c++)
+ bits &= bits -1;
+ return c;
+}
+
+int biton(uint8_t bits)
+{
+ int n = 0;
+ if (bits >> 4) { bits >>= 4; n += 4;}
+ if (bits >> 2) { bits >>= 2; n += 2;}
+ if (bits >> 1) { bits >>= 1; n += 1;}
+ return n;
+}