[Tux3] dleaf ordered check

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Daniel Phillips
Date: Wednesday, September 3, 2008 - 1:39 am

Hi Conrad,

Here's my little hack to check order.  It is _maybe_ marginally more
readable than the original dleaf dump.  I find it makes most sense to
have the dicts point at the zeroth entry for dleaf as opposed to ileaf
where pointing one higher seems to give the best code.

Do with as you will.

int dleaf_ordered(BTREE, struct dleaf *leaf)
{
	struct group *gdict = (void *)leaf + btree->sb->blocksize;
	struct entry *edict = (void *)(--gdict - leaf->groups);
	unsigned groupbase = 0;
	tuxkey_t lastkey = 0;
	for (int group = 0; group > -leaf->groups; group--) {
		tuxkey_t basekey = (tuxkey_t)gdict[group].loghi << 24;
		unsigned offset = 0;
		for (int entry = 0; entry > -gdict[group].count; entry--) {
			unsigned limit = edict[entry].limit;
			tuxkey_t key = basekey | edict[entry].loglo;
			if (key < lastkey || limit < offset)
				return 0;
			offset = limit;
			lastkey = key;
		}
		groupbase += offset;
		edict -= gdict[group].count;
	}
	return 1;
}


_______________________________________________
Tux3 mailing list
Tux3@tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[Tux3] [PATCH] Add check for valid attr encodings, Conrad Meyer, (Tue Sep 2, 11:57 am)
Re: [Tux3] [PATCH] Add check for valid attr encodings, Daniel Phillips, (Tue Sep 2, 12:02 pm)
Re: [Tux3] [PATCH] Add check for valid attr encodings, Daniel Phillips, (Tue Sep 2, 12:07 pm)
[Tux3] dleaf ordered check, Daniel Phillips, (Wed Sep 3, 1:39 am)
Re: [Tux3] dleaf ordered check, Daniel Phillips, (Wed Sep 3, 3:20 am)
[Tux3] Refactor filemap.c, Daniel Phillips, (Tue Dec 16, 2:00 am)
Re: [Tux3] Refactor filemap.c, OGAWA Hirofumi, (Tue Dec 16, 3:08 am)
Re: [Tux3] Refactor filemap.c, Daniel Phillips, (Tue Dec 16, 3:42 am)