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:
Willy Tarreau
2025-07-05 21:57:33 +02:00
parent 3dda813d54
commit fef4cfbd21
6 changed files with 35 additions and 26 deletions

View File

@@ -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 *