mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-26 15:33:00 +00:00
BUG/MINOR: ebtree: remove dependency on incorrect macro for bits per long
The code used to rely on BITS_PER_LONG to decide on the most efficient way to perform a 64-bit shift, but this macro is not defined (at best it's __BITS_PER_LONG) and it's likely that it's been like this since the early implementation of ebtrees designed on i386. Let's remove the test on this macro and rely on sizeof(long) instead, it also has the benefit of letting the compiler validate the two branches. This can be backported to all versions. Thanks to Ezequiel Garcia for reporting this one in issue #1369.
This commit is contained in:
parent
fe456c581f
commit
cbdc74b4b3
@ -375,17 +375,21 @@ __eb64_insert(struct eb_root *root, struct eb64_node *new) {
|
||||
|
||||
/* walk down */
|
||||
root = &old->node.branches;
|
||||
#if BITS_PER_LONG >= 64
|
||||
side = (newkey >> old_node_bit) & EB_NODE_BRANCH_MASK;
|
||||
#else
|
||||
side = newkey;
|
||||
side >>= old_node_bit;
|
||||
if (old_node_bit >= 32) {
|
||||
side = newkey >> 32;
|
||||
side >>= old_node_bit & 0x1F;
|
||||
|
||||
if (sizeof(long) >= 8) {
|
||||
side = newkey >> old_node_bit;
|
||||
} else {
|
||||
/* note: provides the best code on low-register count archs
|
||||
* such as i386.
|
||||
*/
|
||||
side = newkey;
|
||||
side >>= old_node_bit;
|
||||
if (old_node_bit >= 32) {
|
||||
side = newkey >> 32;
|
||||
side >>= old_node_bit & 0x1F;
|
||||
}
|
||||
}
|
||||
side &= EB_NODE_BRANCH_MASK;
|
||||
#endif
|
||||
troot = root->b[side];
|
||||
}
|
||||
|
||||
@ -553,17 +557,21 @@ __eb64i_insert(struct eb_root *root, struct eb64_node *new) {
|
||||
|
||||
/* walk down */
|
||||
root = &old->node.branches;
|
||||
#if BITS_PER_LONG >= 64
|
||||
side = (newkey >> old_node_bit) & EB_NODE_BRANCH_MASK;
|
||||
#else
|
||||
side = newkey;
|
||||
side >>= old_node_bit;
|
||||
if (old_node_bit >= 32) {
|
||||
side = newkey >> 32;
|
||||
side >>= old_node_bit & 0x1F;
|
||||
|
||||
if (sizeof(long) >= 8) {
|
||||
side = newkey >> old_node_bit;
|
||||
} else {
|
||||
/* note: provides the best code on low-register count archs
|
||||
* such as i386.
|
||||
*/
|
||||
side = newkey;
|
||||
side >>= old_node_bit;
|
||||
if (old_node_bit >= 32) {
|
||||
side = newkey >> 32;
|
||||
side >>= old_node_bit & 0x1F;
|
||||
}
|
||||
}
|
||||
side &= EB_NODE_BRANCH_MASK;
|
||||
#endif
|
||||
troot = root->b[side];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user