diff options
author | David Lamparter <equinox@diac24.net> | 2021-02-21 05:48:48 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2021-03-17 06:18:17 +0100 |
commit | 15c05f1edf079bc03b277e44426a8af8616bb10b (patch) | |
tree | 07eba7a6ffc9e4c1caaabbb572632bd921082dc6 | |
parent | snmp: change -std=gnu99 to -std=gnu11 (diff) | |
download | frr-15c05f1edf079bc03b277e44426a8af8616bb10b.tar.xz frr-15c05f1edf079bc03b277e44426a8af8616bb10b.zip |
*: require ISO C11 (or C++11)
It's 2021... time to drop some 10yo compat stuff.
Signed-off-by: David Lamparter <equinox@diac24.net>
-rw-r--r-- | babeld/babeld.h | 14 | ||||
-rw-r--r-- | babeld/util.h | 15 | ||||
-rw-r--r-- | lib/compiler.h | 17 | ||||
-rw-r--r-- | lib/strlcat.c | 2 | ||||
-rw-r--r-- | lib/zassert.h | 7 | ||||
-rw-r--r-- | lib/zebra.h | 15 | ||||
-rw-r--r-- | nhrpd/debug.h | 18 | ||||
-rwxr-xr-x | vtysh/extract.pl.in | 2 |
8 files changed, 16 insertions, 74 deletions
diff --git a/babeld/babeld.h b/babeld/babeld.h index 752cc8620..4487aae99 100644 --- a/babeld/babeld.h +++ b/babeld/babeld.h @@ -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) diff --git a/babeld/util.h b/babeld/util.h index 931004057..8b1b6fbfc 100644 --- a/babeld/util.h +++ b/babeld/util.h @@ -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 */ diff --git a/lib/compiler.h b/lib/compiler.h index 70ef8e9bc..b5cfbefeb 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -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 diff --git a/lib/strlcat.c b/lib/strlcat.c index 39773d9ac..a046822a9 100644 --- a/lib/strlcat.c +++ b/lib/strlcat.c @@ -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 */ diff --git a/lib/zassert.h b/lib/zassert.h index e6b254ee8..527282c4f 100644 --- a/lib/zassert.h +++ b/lib/zassert.h @@ -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__, \ diff --git a/lib/zebra.h b/lib/zebra.h index ded44ac63..5c3d91ba7 100644 --- a/lib/zebra.h +++ b/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> diff --git a/nhrpd/debug.h b/nhrpd/debug.h index db4bac791..e9428fa90 100644 --- a/nhrpd/debug.h +++ b/nhrpd/debug.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 diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index 81c9770e5..4855c23f4 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -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)) { |