mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 13:21:29 +02:00
IMPORT: ebtree: only use __builtin_prefetch() when supported
It looks like __builtin_prefetch() appeared in gcc-3.1 as there's no mention of it in 3.0's doc. Let's replace it with eb_prefetch() which maps to __builtin_prefetch() on supported compilers and falls back to the usual do{}while(0) on other ones. It was tested to properly build with tcc as well as gcc-2.95. This is ebtree commit 7ee6ede56a57a046cb552ed31302b93ff1a21b1a.
This commit is contained in:
parent
3dda813d54
commit
fef4cfbd21
@ -137,8 +137,8 @@ static forceinline struct eb32_node *__eb32_lookup(struct eb_root *root, u32 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb32_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key ^ x;
|
||||
z = 1U << (node->node.bit & 31);
|
||||
@ -191,8 +191,8 @@ static forceinline struct eb32_node *__eb32i_lookup(struct eb_root *root, s32 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb32_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key ^ x;
|
||||
z = 1U << (node->node.bit & 31);
|
||||
@ -271,8 +271,8 @@ __eb32_insert(struct eb_root *root, struct eb32_node *new) {
|
||||
old = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb32_node, node.branches);
|
||||
|
||||
__builtin_prefetch(old->node.branches.b[0], 0);
|
||||
__builtin_prefetch(old->node.branches.b[1], 0);
|
||||
eb_prefetch(old->node.branches.b[0], 0);
|
||||
eb_prefetch(old->node.branches.b[1], 0);
|
||||
|
||||
old_node_bit = old->node.bit;
|
||||
|
||||
@ -408,8 +408,8 @@ __eb32i_insert(struct eb_root *root, struct eb32_node *new) {
|
||||
old = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb32_node, node.branches);
|
||||
|
||||
__builtin_prefetch(old->node.branches.b[0], 0);
|
||||
__builtin_prefetch(old->node.branches.b[1], 0);
|
||||
eb_prefetch(old->node.branches.b[0], 0);
|
||||
eb_prefetch(old->node.branches.b[1], 0);
|
||||
|
||||
old_node_bit = old->node.bit;
|
||||
|
||||
|
@ -137,8 +137,8 @@ static forceinline struct eb64_node *__eb64_lookup(struct eb_root *root, u64 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb64_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key ^ x;
|
||||
z = 1ULL << (node->node.bit & 63);
|
||||
@ -191,8 +191,8 @@ static forceinline struct eb64_node *__eb64i_lookup(struct eb_root *root, s64 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb64_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key ^ x;
|
||||
z = 1ULL << (node->node.bit & 63);
|
||||
@ -317,8 +317,8 @@ __eb64_insert(struct eb_root *root, struct eb64_node *new) {
|
||||
old = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb64_node, node.branches);
|
||||
|
||||
__builtin_prefetch(old->node.branches.b[0], 0);
|
||||
__builtin_prefetch(old->node.branches.b[1], 0);
|
||||
eb_prefetch(old->node.branches.b[0], 0);
|
||||
eb_prefetch(old->node.branches.b[1], 0);
|
||||
|
||||
old_node_bit = old->node.bit;
|
||||
|
||||
@ -503,8 +503,8 @@ __eb64i_insert(struct eb_root *root, struct eb64_node *new) {
|
||||
old = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb64_node, node.branches);
|
||||
|
||||
__builtin_prefetch(old->node.branches.b[0], 0);
|
||||
__builtin_prefetch(old->node.branches.b[1], 0);
|
||||
eb_prefetch(old->node.branches.b[0], 0);
|
||||
eb_prefetch(old->node.branches.b[1], 0);
|
||||
|
||||
old_node_bit = old->node.bit;
|
||||
|
||||
|
@ -240,8 +240,8 @@ static forceinline struct ebmb_node *__ebmb_lookup(struct eb_root *root, const v
|
||||
b = *(unsigned char *)x;
|
||||
side = 1 << node_bit;
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
k = node->key[pos];
|
||||
b0 = node->node.branches.b[0];
|
||||
|
@ -499,6 +499,15 @@ __eb_insert_dup(struct eb_node *sub, struct eb_node *new)
|
||||
}
|
||||
}
|
||||
|
||||
/* __builtin_prefetch() appears in gcc-3.1 documentation */
|
||||
#if !defined(eb_prefetch)
|
||||
# if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||
# define eb_prefetch(a,b) __builtin_prefetch(a,b)
|
||||
# else
|
||||
# define eb_prefetch(a,b) do { } while (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/**************************************\
|
||||
* Public functions, for the end-user *
|
||||
|
@ -73,8 +73,8 @@ struct eb32_node *eb32_lookup_le(struct eb_root *root, u32 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb32_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key;
|
||||
z = 1U << (node->node.bit & 31);
|
||||
@ -168,8 +168,8 @@ struct eb32_node *eb32_lookup_ge(struct eb_root *root, u32 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb32_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key;
|
||||
z = 1U << (node->node.bit & 31);
|
||||
|
@ -73,8 +73,8 @@ struct eb64_node *eb64_lookup_le(struct eb_root *root, u64 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb64_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key;
|
||||
z = 1ULL << (node->node.bit & 63);
|
||||
@ -168,8 +168,8 @@ struct eb64_node *eb64_lookup_ge(struct eb_root *root, u64 x)
|
||||
node = container_of(eb_untag(troot, EB_NODE),
|
||||
struct eb64_node, node.branches);
|
||||
|
||||
__builtin_prefetch(node->node.branches.b[0], 0);
|
||||
__builtin_prefetch(node->node.branches.b[1], 0);
|
||||
eb_prefetch(node->node.branches.b[0], 0);
|
||||
eb_prefetch(node->node.branches.b[1], 0);
|
||||
|
||||
y = node->key;
|
||||
z = 1ULL << (node->node.bit & 63);
|
||||
|
Loading…
x
Reference in New Issue
Block a user