summaryrefslogtreecommitdiffstats
path: root/lib/compiler.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib: temporary workaround for LabN CIDavid Lamparter2021-03-171-0/+15
| | | | | | | | 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>
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-0/+3
| | | | | | | | | | | | | | | | | 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>
* *: require ISO C11 (or C++11)David Lamparter2021-03-171-2/+15
| | | | | | It's 2021... time to drop some 10yo compat stuff. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: add macros to count variadic argsQuentin Young2020-12-021-0/+23
| | | | | | | Magical macro used to compute the number of arguments passed to a variadic macro. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
* lib: prepare for plugin-based frr_format checkDavid Lamparter2020-03-291-1/+8
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: add some macro helpersDavid Lamparter2019-09-031-0/+43
| | | | | | Macro soup, now with 50% more macros. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: fix prefix_cmp() return valuesDavid Lamparter2019-07-281-0/+7
| | | | | | OMGWTFBBQ Signed-off-by: David Lamparter <equinox@diac24.net>
* Merge pull request #4509 from opensourcerouting/spanish-intquisitionQuentin Young2019-06-131-0/+62
|\ | | | | lib: make printfrr int64_t usable
| * lib: make "%Ld" work for int64_tDavid Lamparter2019-06-121-0/+62
| | | | | | | | | | | | ... without compiler plugins. Signed-off-by: David Lamparter <equinox@diac24.net>
* | lib: const-unaware container_of for C++David Lamparter2019-06-111-3/+14
|/ | | | | | | | 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>
* lib: add OPTIMIZE + assume() to compiler.hDavid Lamparter2019-06-061-0/+22
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* lib/printf: rename & private __find_argumentsDavid Lamparter2019-06-031-0/+10
| | | | | | | These are internal to printf(), and symbols starting with __ are reserved for the compiler/libc. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib/table: remove nonsensical const, add pureDavid Lamparter2019-05-211-0/+9
| | | | | | | | | | | | | | | | | | 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>
* lib: atomlist & atomsortDavid Lamparter2019-04-271-0/+7
| | | | | | | | 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>
* lib: move/redo some macrosDavid Lamparter2019-04-181-0/+78
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: add extern "C" {} blocks to all libfrr headersRenato Westphal2019-02-121-0/+8
| | | | | | | 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>
* build: wrap "fallthrough" attrDavid Lamparter2018-08-211-0/+9
| | | | | | This generates a warning on gcc versions before 7.0. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib/compiler.h: Always define CPP_NOTICEChristian Franke2018-07-191-0/+1
| | | | | | | 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>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-8/+8
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* lib: split off compiler magic into its own fileDavid Lamparter2017-08-241-0/+81
Also make timed notices available via CONFDATE. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>