|
From: <jsa...@us...> - 2008-10-09 15:04:36
|
Revision: 1264
http://como.svn.sourceforge.net/como/?rev=1264&view=rev
Author: jsanjuas
Date: 2008-10-09 15:04:34 +0000 (Thu, 09 Oct 2008)
Log Message:
-----------
bitmaps can now clear bits
Modified Paths:
--------------
src/branches/2.0/lib/bitmap.c
Modified: src/branches/2.0/lib/bitmap.c
===================================================================
--- src/branches/2.0/lib/bitmap.c 2008-08-20 16:48:58 UTC (rev 1263)
+++ src/branches/2.0/lib/bitmap.c 2008-10-09 15:04:34 UTC (rev 1264)
@@ -179,6 +179,40 @@
}
/*
+ * -- clear_bit
+ *
+ * Clear a bit in the bitmap, and maintain the counter of zeros.
+ */
+void
+clear_bit(bitmap_t *bm, uint32_t key)
+{
+ int bit = key & (bm->nbits - 1);
+ int where = which_byte(bit);
+ int what = which_bit(bit);
+
+#ifndef BUILD_FOR_ARM
+ int old;
+
+ /*
+ * x86 asm test and clear operation
+ */
+ asm volatile("btrl %2, %1\n\tsbbl %0, %0\n\t"
+ : "=r" (old), "=m" (bm->map[where])
+ : "r" (what));
+
+ if (old)
+ bm->zeros++;
+#else
+ XXX untested
+ if (1 == (map[where] & (1 << what))) {
+ bm->zeros++;
+ map[where] &= ~(1 << what);
+ }
+#endif
+}
+
+
+/*
* -- get_bit
*
* Get a bit of the bitmap.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|