Add some `pragma`s to handle errors that the C/C++ extension is not able
to understand.
Move `TRANSPARENT_UNION` to `lib/compiler.h` for consistency.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
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>
These hoops to get warnings for mis-printing `uint64_t` are apparently
breaking some C++ bits...
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Accept macros without ; for LabN CI *only*. This is a bit hairy since
we can't generate warnings for this, so it's very limited in both scope
and duration.
Signed-off-by: David Lamparter <equinox@diac24.net>
Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet. Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition. And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...
With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.
Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.
Signed-off-by: David Lamparter <equinox@diac24.net>
This version of container_of() should work on C++, by ditching the
unavailable builtins (at the cost of no longer checking for "const"
violations.)
Signed-off-by: David Lamparter <equinox@diac24.net>
Passing the struct route_table *ptr as const doesn't really help; if
anything it semantically would imply that the returned route_node is
const too since constness should propagate (but it doesn't in C.)
The right thing to do here - which actually helps the compiler optimize
the code too - is to tag functions with __attribute__((pure)). The
compiler does this automatically if it has the function body (and the
body of all called functions) available. That should cover most "static
inline" functions in headers, as well as functions in the same file.
However, this doesn't work (at least without LTO) for extern functions.
Hence, add "ext_pure" for this case. (Built-in "extern" to make lines
shorter.)
Signed-off-by: David Lamparter <equinox@diac24.net>
These two are lock-free linked list implementations, the plain one is
primarily intended for queues while the sorted one is for general data
storage.
Signed-off-by: David Lamparter <equinox@diac24.net>
These are necessary to use functions defined in these headers from C++.
Signed-off-by: David Lamparter <equinox@diac24.net>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
On old compilers CPP_NOTICE should be a macro evaluating to an empty
statement, instead of being undefined.
Signed-off-by: Christian Franke <chris@opensourcerouting.org>