diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-06-18 13:06:13 +0300 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-06-18 19:54:40 +0300 |
| commit | 4f08c715db6893ff439d0a39bf4506cd26256d13 (patch) | |
| tree | 018fb2b4dc62b81d64f74b96d4c50cf1a7404008 /lib/compiler.h | |
| parent | 161b567451593a7a176bc91b5aaafc53a578be75 (diff) | |
lib: remove pure attribute from functions that modify memory
Almost all functions currently marked with pure attribute acquire a
route_node lock. By marking them pure we allow compiler to optimize the
code and not call them when it already knows the return value. This is
completely incorrect.
Only two of eleven functions can be marked as pure. And they still won't
be optimized because they are never called from the same function twice.
Let's remove the ext_pure macro completely to reduce the chance of
repeating this mistake in the future.
Fixes #8866, #8809, #8595, #6992.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/compiler.h')
| -rw-r--r-- | lib/compiler.h | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/lib/compiler.h b/lib/compiler.h index bbfe01b569..e805eb8be4 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -123,15 +123,6 @@ extern "C" { #define assume(x) #endif -/* pure = function does not modify memory & return value is the same if - * memory hasn't changed (=> allows compiler to optimize) - * - * Mostly autodetected by the compiler if function body is available (i.e. - * static inline functions in headers). Since that implies it should only be - * used in headers for non-inline functions, the "extern" is included here. - */ -#define ext_pure extern __attribute__((pure)) - /* for helper functions defined inside macros */ #define macro_inline static inline __attribute__((unused)) #define macro_pure static inline __attribute__((unused, pure)) |
