mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
MINOR: compiler: rely on builtin detection for __builtin_unreachable()
Due to __builtin_unreachable() only being associated to gcc 4.5 and above, it turns out it was not enabled for clang. It's not used *that* much but still a little bit, so let's enable it now. This reduces the code size by 0.2% and makes it a bit more efficient.
This commit is contained in:
parent
96cfcb1df3
commit
41fc18b1d1
@ -191,6 +191,11 @@
|
|||||||
#define __read_mostly HA_SECTION("read_mostly")
|
#define __read_mostly HA_SECTION("read_mostly")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* __builtin_unreachable() was added in gcc 4.5 */
|
||||||
|
#if defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||||
|
#define __has_builtin___builtin_unreachable 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This allows gcc to know that some locations are never reached, for example
|
/* This allows gcc to know that some locations are never reached, for example
|
||||||
* after a longjmp() in the Lua code, hence that some errors caught by such
|
* after a longjmp() in the Lua code, hence that some errors caught by such
|
||||||
* methods cannot propagate further. This is important with gcc versions 6 and
|
* methods cannot propagate further. This is important with gcc versions 6 and
|
||||||
@ -200,7 +205,7 @@
|
|||||||
#ifdef DEBUG_USE_ABORT
|
#ifdef DEBUG_USE_ABORT
|
||||||
#define my_unreachable() abort()
|
#define my_unreachable() abort()
|
||||||
#else
|
#else
|
||||||
#if defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
#if __has_builtin(__builtin_unreachable)
|
||||||
#define my_unreachable() __builtin_unreachable()
|
#define my_unreachable() __builtin_unreachable()
|
||||||
#else
|
#else
|
||||||
#define my_unreachable() do { } while (1)
|
#define my_unreachable() do { } while (1)
|
||||||
|
Loading…
Reference in New Issue
Block a user