mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-25 20:17:12 +00:00
*: require ISO C11 (or C++11)
It's 2021... time to drop some 10yo compat stuff. Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
parent
247c7e27a9
commit
15c05f1edf
@ -41,20 +41,6 @@ THE SOFTWARE.
|
||||
#define MAX(x,y) ((x)<=(y)?(y):(x))
|
||||
#define MIN(x,y) ((x)<=(y)?(x):(y))
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
/* nothing */
|
||||
#elif defined(__GNUC__)
|
||||
#define inline __inline
|
||||
#if (__GNUC__ >= 3)
|
||||
#define restrict __restrict
|
||||
#else
|
||||
#define restrict /**/
|
||||
#endif
|
||||
#else
|
||||
#define inline /**/
|
||||
#define restrict /**/
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
#define ATTRIBUTE(x) __attribute__ (x)
|
||||
#define LIKELY(_x) __builtin_expect(!!(_x), 1)
|
||||
|
||||
@ -129,13 +129,7 @@ extern const unsigned char v4prefix[16];
|
||||
vararg macros are not portable. */
|
||||
#if defined NO_DEBUG
|
||||
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
||||
#define debugf(...) do {} while(0)
|
||||
#elif defined __GNUC__
|
||||
#define debugf(_args...) do {} while(0)
|
||||
#else
|
||||
static inline void debugf(int level, const char *format, ...) { return; }
|
||||
#endif
|
||||
|
||||
#else /* NO_DEBUG */
|
||||
|
||||
@ -148,19 +142,10 @@ static inline void debugf(int level, const char *format, ...) { return; }
|
||||
#define BABEL_DEBUG_ROUTE (1 << 5)
|
||||
#define BABEL_DEBUG_ALL (0xFFFF)
|
||||
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
||||
#define debugf(level, ...) \
|
||||
do { \
|
||||
if(UNLIKELY(debug & level)) zlog_debug(__VA_ARGS__); \
|
||||
} while(0)
|
||||
#elif defined __GNUC__
|
||||
#define debugf(level, _args...) \
|
||||
do { \
|
||||
if(UNLIKELY(debug & level)) zlog_debug(_args); \
|
||||
} while(0)
|
||||
#else
|
||||
static inline void debugf(int level, const char *format, ...) { return; }
|
||||
#endif
|
||||
|
||||
#endif /* NO_DEBUG */
|
||||
|
||||
|
||||
@ -21,6 +21,21 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# if __cplusplus < 201103L
|
||||
# error FRRouting headers must be compiled in C++11 mode or newer
|
||||
# endif
|
||||
/* C++ defines static_assert(), but not _Static_assert(). C defines
|
||||
* _Static_assert() and has static_assert() in <assert.h>. However, we mess
|
||||
* with assert() in zassert.h so let's not include <assert.h> here.
|
||||
*/
|
||||
# define _Static_assert static_assert
|
||||
#else
|
||||
# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
|
||||
# error FRRouting must be compiled with min. -std=gnu11 (GNU ISO C11 dialect)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* function attributes, use like
|
||||
* void prototype(void) __attribute__((_CONSTRUCTOR(100)));
|
||||
*/
|
||||
@ -357,10 +372,8 @@ typedef signed long long _int64_t;
|
||||
/* if this breaks, 128-bit machines may have entered reality (or <long long>
|
||||
* is something weird)
|
||||
*/
|
||||
#if __STDC_VERSION__ >= 201112L
|
||||
_Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8,
|
||||
"nobody expects the spanish intquisition");
|
||||
#endif
|
||||
|
||||
/* since we redefined int64_t, we also need to redefine PRI*64 */
|
||||
#undef PRIu64
|
||||
|
||||
@ -64,10 +64,8 @@ size_t strlcat(char *__restrict dest,
|
||||
(which the static_assert checks), then by the pigeonhole
|
||||
principle, the two input strings must overlap, which is
|
||||
undefined. */
|
||||
#if __STDC_VERSION__ >= 201112L
|
||||
_Static_assert(sizeof(uintptr_t) == sizeof(size_t),
|
||||
"theoretical maximum object size covers address space");
|
||||
#endif
|
||||
return dest_length + src_length;
|
||||
}
|
||||
#endif /* HAVE_STRLCAT */
|
||||
|
||||
@ -28,14 +28,7 @@ extern void _zlog_assert_failed(const char *assertion, const char *file,
|
||||
__attribute__((noreturn));
|
||||
|
||||
#undef __ASSERT_FUNCTION
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#define __ASSERT_FUNCTION __func__
|
||||
#elif defined(__GNUC__)
|
||||
#define __ASSERT_FUNCTION __FUNCTION__
|
||||
#else
|
||||
#define __ASSERT_FUNCTION NULL
|
||||
#endif
|
||||
|
||||
#define zassert(EX) \
|
||||
((void)((EX) ? 0 : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
|
||||
|
||||
15
lib/zebra.h
15
lib/zebra.h
@ -80,21 +80,6 @@
|
||||
|
||||
/* misc include group */
|
||||
#include <stdarg.h>
|
||||
#if !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
||||
/* Not C99; do we need to define va_copy? */
|
||||
#ifndef va_copy
|
||||
#ifdef __va_copy
|
||||
#define va_copy(DST,SRC) __va_copy(DST,SRC)
|
||||
#else
|
||||
/* Now we are desperate; this should work on many typical platforms.
|
||||
But this is slightly dangerous, because the standard does not require
|
||||
va_copy to be a macro. */
|
||||
#define va_copy(DST,SRC) memcpy(&(DST), &(SRC), sizeof(va_list))
|
||||
#warning "Not C99 and no va_copy macro available, falling back to memcpy"
|
||||
#endif /* __va_copy */
|
||||
#endif /* !va_copy */
|
||||
#endif /* !C99 */
|
||||
|
||||
|
||||
#ifdef HAVE_LCAPS
|
||||
#include <sys/capability.h>
|
||||
|
||||
@ -18,26 +18,8 @@
|
||||
|
||||
extern unsigned int debug_flags;
|
||||
|
||||
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
||||
|
||||
#define debugf(level, ...) \
|
||||
do { \
|
||||
if (unlikely(debug_flags & level)) \
|
||||
zlog_debug(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#elif defined __GNUC__
|
||||
|
||||
#define debugf(level, _args...) \
|
||||
do { \
|
||||
if (unlikely(debug_flags & level)) \
|
||||
zlog_debug(_args); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
static inline void debugf(int level, const char *format, ...)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -42,7 +42,7 @@ sub scan_file {
|
||||
|
||||
$cppadd = $fabricd ? "-DFABRICD=1" : "";
|
||||
|
||||
open (FH, "@CPP@ -P -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -Ivtysh/@top_builddir@ -Ivtysh/@top_srcdir@ -Ivtysh/@top_srcdir@/lib -Ivtysh/@top_builddir@/lib -Ivtysh/@top_srcdir@/bgpd -Ivtysh/@top_srcdir@/bgpd/rfapi @LUA_INCLUDE@ @CPPFLAGS@ $cppadd $file |");
|
||||
open (FH, "@CPP@ -P -std=gnu11 -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -Ivtysh/@top_builddir@ -Ivtysh/@top_srcdir@ -Ivtysh/@top_srcdir@/lib -Ivtysh/@top_builddir@/lib -Ivtysh/@top_srcdir@/bgpd -Ivtysh/@top_srcdir@/bgpd/rfapi @LUA_INCLUDE@ @CPPFLAGS@ $cppadd $file |");
|
||||
local $/; undef $/;
|
||||
$line = <FH>;
|
||||
if (!close (FH)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user