summaryrefslogtreecommitdiffstats
path: root/src/H5Vprivate.h
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-09-15 20:20:39 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-09-15 20:20:39 (GMT)
commitb047710a9577cb381308f30b67e81f2974029333 (patch)
tree5888c6f563bc2946d91a590ac5f7b76f5a66812b /src/H5Vprivate.h
parent24725d64aa4e944c4be4e0dcefa0880cb8ac627c (diff)
downloadhdf5-b047710a9577cb381308f30b67e81f2974029333.zip
hdf5-b047710a9577cb381308f30b67e81f2974029333.tar.gz
hdf5-b047710a9577cb381308f30b67e81f2974029333.tar.bz2
[svn-r12669] Description:
Use a slightly less efficient method of computing the log2() on SGI IRIX64, in order to avoid a compiler bug when optimizations are turned on. Tested on: SGI IRIX64 6.5 (atlantia)
Diffstat (limited to 'src/H5Vprivate.h')
-rw-r--r--src/H5Vprivate.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index 5848a57..0554c47 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -346,19 +346,28 @@ static const char LogTable256[] =
static H5_inline unsigned UNUSED
H5V_log2_gen(hsize_t n)
{
- unsigned r = 0; /* r will be log2(n) */
+ unsigned r; /* r will be log2(n) */
register unsigned int t, tt, ttt; /* temporaries */
- if((ttt = (unsigned)(n >> 32)))
- if((tt = (unsigned)(n >> 48)))
- r = (t = (unsigned)(n >> 56)) ? 56 + LogTable256[t] : 48 + LogTable256[tt & 0xFF];
+#ifdef H5_BAD_LOG2_CODE_GENERATED
+ if(n > (uint64_t)0x7fffffffffffffff)
+ r = 63;
+ else {
+ n &= (uint64_t)0x7fffffffffffffff;
+#endif /* H5_BAD_LOG2_CODE_GENERATED */
+ if((ttt = (unsigned)(n >> 32)))
+ if((tt = (unsigned)(n >> 48)))
+ r = (t = (unsigned)(n >> 56)) ? 56 + LogTable256[t] : 48 + LogTable256[tt & 0xFF];
+ else
+ r = (t = (unsigned)(n >> 40)) ? 40 + LogTable256[t] : 32 + LogTable256[ttt & 0xFF];
else
- r = (t = (unsigned)(n >> 40)) ? 40 + LogTable256[t] : 32 + LogTable256[ttt & 0xFF];
- else
- if((tt = (unsigned)(n >> 16)))
- r = (t = (unsigned)(n >> 24)) ? 24 + LogTable256[t] : 16 + LogTable256[tt & 0xFF];
- else
- r = (t = (unsigned)(n >> 8)) ? 8 + LogTable256[t] : LogTable256[n];
+ if((tt = (unsigned)(n >> 16)))
+ r = (t = (unsigned)(n >> 24)) ? 24 + LogTable256[t] : 16 + LogTable256[tt & 0xFF];
+ else
+ r = (t = (unsigned)(n >> 8)) ? 8 + LogTable256[t] : LogTable256[n];
+#ifdef H5_BAD_LOG2_CODE_GENERATED
+ } /* end else */
+#endif /* H5_BAD_LOG2_CODE_GENERATED */
return(r);
} /* H5V_log2_gen() */