projects
/
cacao.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4def30f
)
Fixed a bug (wrong constant) in the lowest function causing a wrong path to be taken...
author
phil
<none@none>
Mon, 9 Nov 1998 13:35:51 +0000
(13:35 +0000)
committer
phil
<none@none>
Mon, 9 Nov 1998 13:35:51 +0000
(13:35 +0000)
mm/bitmap2.c
patch
|
blob
|
history
mm/bitmap2.h
patch
|
blob
|
history
diff --git
a/mm/bitmap2.c
b/mm/bitmap2.c
index 30527cb6c29bb29ec554e779b4506323ba53469b..9a257e27eedb9ca91cd2d10d7c8c3d8d02aded45 100644
(file)
--- a/
mm/bitmap2.c
+++ b/
mm/bitmap2.c
@@
-6,7
+6,7
@@
*
* Authors: Philipp Tomsich EMAIL: cacao@complang.tuwien.ac.at
*
*
* Authors: Philipp Tomsich EMAIL: cacao@complang.tuwien.ac.at
*
- * $Id: bitmap2.c
37 1998-11-04 12:39:19
Z phil $
+ * $Id: bitmap2.c
45 1998-11-09 13:35:51
Z phil $
*/
/*
*/
/*
@@
-37,6
+37,12
@@
* if the addr argument is out of range.
*/
* if the addr argument is out of range.
*/
+/* TODO:
+ * Rewrite bitmap_find_next_setbit and bitmap_find_next_combination_set_unset
+ * to use more pointer arithmetic and less indexed accesses. --phil.
+ * Reason: Most compilers are simply dumb, while some programmers are not!
+ */
+
#include <assert.h> /* assert */
#include <stdio.h> /* printf, fprintf */
#include <stdlib.h> /* malloc, free */
#include <assert.h> /* assert */
#include <stdio.h> /* printf, fprintf */
#include <stdlib.h> /* malloc, free */
@@
-136,10
+142,9
@@
void bitmap_boundscheck(bitmap_t* bitmap,
{
/* check the lower bound */
assert((void*)&bitmap->bitmap[ADDR_TO_BLOCK(addr)] >= bitmap->bitmap_memory);
{
/* check the lower bound */
assert((void*)&bitmap->bitmap[ADDR_TO_BLOCK(addr)] >= bitmap->bitmap_memory);
+
/* check the upper bound */
/* check the upper bound */
- assert(&bitmap->bitmap[
- ADDR_TO_BLOCK(addr)]
- <= &bitmap->bitmap[bitmap->bitmap_top_block]);
+ assert(&bitmap->bitmap[ADDR_TO_BLOCK(addr)] <= &bitmap->bitmap[bitmap->bitmap_top_block]);
assert(addr < bitmap->bitmap_beyond_addr); /* a stricter way to check the upper bound */
}
assert(addr < bitmap->bitmap_beyond_addr); /* a stricter way to check the upper bound */
}
@@
-263,7
+268,7
@@
int offset_for_lowest(BITBLOCK i)
};
#if U8_AVAILABLE
};
#if U8_AVAILABLE
- if (i & 0xffffffff
ff
ULL)
+ if (i & 0xffffffffULL)
#endif
if (i & 0xffffUL)
if (i & 0xffUL)
#endif
if (i & 0xffffUL)
if (i & 0xffUL)
@@
-329,6
+334,9
@@
bitmap_find_next_combination_set_unset(bitmap_t* bitmap,
BITBLOCK pattern;
bitmap_boundscheck(bitmap, addr);
BITBLOCK pattern;
bitmap_boundscheck(bitmap, addr);
+ bitmap_boundscheck(invertedmap, addr);
+
+ // fprintf(stderr, "bitmap_find_next_combination_set_unset(0x%lx, 0x%lx. 0x%lx);\n", bitmap, invertedmap, addr);
/* 1. check the current block, starting from the bit indicated by addr */
pattern = (bitmap->bitmap[block] & ~invertedmap->bitmap[block]) >> offset;
/* 1. check the current block, starting from the bit indicated by addr */
pattern = (bitmap->bitmap[block] & ~invertedmap->bitmap[block]) >> offset;
@@
-337,10
+345,16
@@
bitmap_find_next_combination_set_unset(bitmap_t* bitmap,
/* 2. iteratively check block by block until the end of the bitmap */
while (block < bitmap->bitmap_top_block) {
/* 2. iteratively check block by block until the end of the bitmap */
while (block < bitmap->bitmap_top_block) {
- pattern = bitmap->bitmap[++block] & ~invertedmap->bitmap[block];
+ ++block;
+ pattern = bitmap->bitmap[block] & ~invertedmap->bitmap[block];
+
+ if (pattern) {
+ // fprintf(stderr, "\tbitmap->bitmap[block] = 0x%lx, ~invertedmap->bitmap[block] = 0x%lx\n",
+ // bitmap->bitmap[block], ~invertedmap->bitmap[block]);
+ // fprintf(stderr, "\tpattern = 0x%lx, BLOCK_TO_ADDR(block) = 0x%lx\n", pattern, BLOCK_TO_ADDR(block));
- if (pattern)
return (void*)(BLOCK_TO_ADDR(block) + offset_for_lowest(pattern));
return (void*)(BLOCK_TO_ADDR(block) + offset_for_lowest(pattern));
+ }
}
/* 3. failed to find a combination... */
}
/* 3. failed to find a combination... */
diff --git
a/mm/bitmap2.h
b/mm/bitmap2.h
index 4f4b1014984686fa933db18caa7ca720c8e2a038..7505e44bb6bf22fdca0b5e29b8602d60ec8290ab 100644
(file)
--- a/
mm/bitmap2.h
+++ b/
mm/bitmap2.h
@@
-1,6
+1,6
@@
/*
* cacao/mm/bitmap.h
/*
* cacao/mm/bitmap.h
- * $Id: bitmap2.h
37 1998-11-04 12:39:19
Z phil $
+ * $Id: bitmap2.h
45 1998-11-09 13:35:51
Z phil $
*/
#ifndef __mm_bitmap_h_
*/
#ifndef __mm_bitmap_h_
@@
-8,8
+8,14
@@
#include "mm.h"
#include "mm.h"
+#ifndef CACAO_NO_INLINE
+#define __cacao_inline__ inline
+#else
+#define __cacao_inline__
+#endif
+
#ifdef __GNUC__
#ifdef __GNUC__
-#define __inline__
inline
+#define __inline__
__cacao_inline__
#else
#define __inline__
#endif
#else
#define __inline__
#endif