]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: require ISO C11 (or C++11)
authorDavid Lamparter <equinox@diac24.net>
Sun, 21 Feb 2021 04:48:48 +0000 (05:48 +0100)
committerDavid Lamparter <equinox@diac24.net>
Wed, 17 Mar 2021 05:18:17 +0000 (06:18 +0100)
It's 2021... time to drop some 10yo compat stuff.

Signed-off-by: David Lamparter <equinox@diac24.net>
babeld/babeld.h
babeld/util.h
lib/compiler.h
lib/strlcat.c
lib/zassert.h
lib/zebra.h
nhrpd/debug.h
vtysh/extract.pl.in

index 752cc8620a84708dc5189d5c53d9fca6907dacf6..4487aae99f4c74e23ff43a8c208e1d942ecc4aae 100644 (file)
@@ -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)
index 93100405713466830534d5f6bb72953fe6793d1b..8b1b6fbfc912d36b34f8e027df397da5446cd512 100644 (file)
@@ -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 */
 
index 70ef8e9bc80255eb3a4996a2464d0fdf611de2ed..b5cfbefeb59a39d554bd0b097f8863e34f25e449 100644 (file)
 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
index 39773d9ac89ef7cfe022cc444266eea243b9eee5..a046822a94389b5f9f003a18054a9edd94c10858 100644 (file)
@@ -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 */
index e6b254ee8d43e62d128c158e272dbde9894335bc..527282c4f283e289925135a35a0d1a593683d131 100644 (file)
@@ -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__,       \
index ded44ac63669f91ecaaf64ff62fe3af0637ea8de..5c3d91ba74bca34aefb5871f3863e4583294e19b 100644 (file)
 
 /* 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>
index db4bac79162cd5b1cf59dafc3222e064ef5e1a8d..e9428fa90a0e9fbb1aab5ce8236fa45b0cccdce9 100644 (file)
 
 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
index 81c9770e55867b99bfc2452ed3ac60637454aa96..4855c23f4b15ab837b37614c9b2278bb1a981c5a 100755 (executable)
@@ -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)) {