summaryrefslogtreecommitdiff
path: root/lib/compiler.h
AgeCommit message (Collapse)Author
2024-03-22grpc: fix grpc for various failuresChristian Hopps
lib: don't define a `fallthrough` in c++ to avoid conflict with protobuf c++ check: add link libs required by some versions of grpc++ or it's dependent linked libs tests: don't fail the test due to known at exit memleaks Signed-off-by: Christian Hopps <chopps@labn.net> (cherry picked from commit 043a4183c2f10e6117695dec7a0373c1b0a63808)
2023-11-05lib: rename `prefixtype` to `uniontype`David Lamparter
About to use this for sockunion, which is not a prefix. `uniontype` makes more sense, the macros are for defining transparent unions after all. (clang-format off thrown in as it otherwise wrecks formatting.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-10-12build: add -Wimplicit-fallthroughIgor Ryzhov
Also: - replace all /* fallthrough */ comments with portable fallthrough; pseudo keyword to accomodate both gcc and clang - add missing break; statements as required by older versions of gcc - cleanup some code to remove unnecessary fallthrough Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-14lib: another attempt at Coverity false positivesDavid Lamparter
Typesafe hash tables do this: assume((tabshift) >= 2 && (tabshift) <= 33); (val) >> (33 - (tabshift)); Sadly, Coverity currently ignores assume() and says: [...] right shifting by more than 31 bits has undefined behavior. The shift amount, "33 - h->hh.tabshift", is 33. Let's see if Coverity understands this can't happen... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-03-23babeld, lib, nhrpd: Add likely and unlikely macrosDonald Sharp
We have 2 competing versions of likely and unlikely in babeld and nhrpd. Standardize onto lower case versions and consolidate in the code. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-11-28lib: handle visual studio code C/C++ extensionRafael Zalamena
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>
2021-07-05Merge pull request #8888 from dlqs/lua-callQuentin Young
2021-06-25lib: add comments for functionsDonald Lee
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-23Merge pull request #8656 from opensourcerouting/xref-5424-prep-2Donald Sharp
lib: preparations for RFC5424 syslog support
2021-06-22lib: Add MAP_LIST macroDonald Lee
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-06-18lib: fix printf format on NetBSDDavid Lamparter
*sigh*. It doesn't accept `%m` otherwise. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-06-18lib: remove pure attribute from functions that modify memoryIgor Ryzhov
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>
2021-06-01lib: Time to remove CONFDATE blockDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-05-02lib: fix random C++ compat problem w/ printfrrDavid Lamparter
These hoops to get warnings for mis-printing `uint64_t` are apparently breaking some C++ bits... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-03-17lib: temporary workaround for LabN CIDavid Lamparter
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>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
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>
2021-03-17*: require ISO C11 (or C++11)David Lamparter
It's 2021... time to drop some 10yo compat stuff. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-12-01lib: add macros to count variadic argsQuentin Young
Magical macro used to compute the number of arguments passed to a variadic macro. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-03-29lib: prepare for plugin-based frr_format checkDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-09-03lib: add some macro helpersDavid Lamparter
Macro soup, now with 50% more macros. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-07-28lib: fix prefix_cmp() return valuesDavid Lamparter
OMGWTFBBQ Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13Merge pull request #4509 from opensourcerouting/spanish-intquisitionQuentin Young
lib: make printfrr int64_t usable
2019-06-12lib: make "%Ld" work for int64_tDavid Lamparter
... without compiler plugins. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-11lib: const-unaware container_of for C++David Lamparter
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>
2019-06-06lib: add OPTIMIZE + assume() to compiler.hDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-03lib/printf: rename & private __find_argumentsDavid Lamparter
These are internal to printf(), and symbols starting with __ are reserved for the compiler/libc. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21lib/table: remove nonsensical const, add pureDavid Lamparter
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>
2019-04-27lib: atomlist & atomsortDavid Lamparter
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>
2019-04-18lib: move/redo some macrosDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-02-11lib: add extern "C" {} blocks to all libfrr headersRenato Westphal
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>
2018-08-21build: wrap "fallthrough" attrDavid Lamparter
This generates a warning on gcc versions before 7.0. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-07-19lib/compiler.h: Always define CPP_NOTICEChristian Franke
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>
2018-03-06*: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2017-08-24lib: split off compiler magic into its own fileDavid Lamparter
Also make timed notices available via CONFDATE. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>