diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-03-04 22:56:44 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-03-04 22:56:44 (GMT) |
commit | dfbf976509bea0b4d598716d0dd73be494efacdd (patch) | |
tree | 891886081cf2ed280788eb2a33c609c55dfe2391 /src/H5Vprivate.h | |
parent | 0e708b387c78f5a286ab82eda55214fddf6c2127 (diff) | |
download | hdf5-dfbf976509bea0b4d598716d0dd73be494efacdd.zip hdf5-dfbf976509bea0b4d598716d0dd73be494efacdd.tar.gz hdf5-dfbf976509bea0b4d598716d0dd73be494efacdd.tar.bz2 |
[svn-r12004] Purpose:
New feature & code cleanup
Description:
Update fractal heap to be able to insert objects into a direct block
hanging off the header.
Extract "octal dump" code into separate routine so that both the local
heaps & fractal heaps can use it.
Other code cleanups & support to get this far.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Linux 2.4
Diffstat (limited to 'src/H5Vprivate.h')
-rw-r--r-- | src/H5Vprivate.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h index 52f9d6b..55047cb 100644 --- a/src/H5Vprivate.h +++ b/src/H5Vprivate.h @@ -300,4 +300,35 @@ H5V_vector_inc(int n, hsize_t *v1, const hsize_t *v2) while (n--) *v1++ += *v2++; } -#endif + +/*------------------------------------------------------------------------- + * Function: H5V_power_of_two + * + * Purpose: Determines the log base two of a number (i.e. log2(n)). + * + * Note: N must be a power of two and is limited to 32-bit quantities. + + * This is from the "Bit Twiddling Hacks" at: + * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn + * + * Return: log2(n) (always - no failure condition) + * + * Programmer: Quincey Koziol + * Monday, Febraury 27, 2006 + * + *------------------------------------------------------------------------- + */ +static H5_inline unsigned +H5V_log2(unsigned n) +{ + static const unsigned MultiplyDeBruijnBitPosition[32] = + { + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 + }; + + return(MultiplyDeBruijnBitPosition[(n * 0x077CB531UL) >> 27]); +} /* H5V_log2() */ + +#endif /* H5Vprivate_H */ + |