summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aclocal.m441
-rw-r--r--config.h.in4
-rwxr-xr-xconfigure51
-rw-r--r--configure.in1
-rw-r--r--netdissect-stdinc.h6
5 files changed, 103 insertions, 0 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index 637054fd..cfd59afd 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1323,6 +1323,47 @@ fi
AC_MSG_RESULT($ac_cv___attribute___noreturn_function_pointer)
])
+dnl
+dnl Test whether __attribute__((fallthrough)) can be used without warnings
+dnl
+
+AC_DEFUN(AC_C___ATTRIBUTE___FALLTHROUGH, [
+AC_MSG_CHECKING([whether __attribute__((fallthrough)) can be used without warnings])
+AC_CACHE_VAL(ac_cv___attribute___fallthrough, [
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ int x = 1;
+ switch (x)
+ {
+ case 1:
+ printf ("x == %d\n", x);
+ __attribute__ ((fallthrough));
+ case 2:
+ printf ("x == %d\n", x);
+ break;
+ default:
+ return 0;
+ }
+ return x;
+}
+ ]])],
+ac_cv___attribute___fallthrough=yes,
+ac_cv___attribute___fallthrough=no)])
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___fallthrough" = "yes"; then
+ AC_DEFINE(__ATTRIBUTE___FALLTHROUGH_OK, 1,
+ [define if your compiler allows __attribute__((fallthrough)) without a warning])
+fi
+AC_MSG_RESULT($ac_cv___attribute___fallthrough)
+])
+
AC_DEFUN(AC_LBL_SSLEAY,
[
#
diff --git a/config.h.in b/config.h.in
index bbe1811b..6388afdc 100644
--- a/config.h.in
+++ b/config.h.in
@@ -331,6 +331,10 @@
#define below would cause a syntax error. */
#undef _UINT8_T
+/* define if your compiler allows __attribute__((fallthrough)) without a
+ warning */
+#undef __ATTRIBUTE___FALLTHROUGH_OK
+
/* define if your compiler allows __attribute__((format)) without a warning */
#undef __ATTRIBUTE___FORMAT_OK
diff --git a/configure b/configure
index 3eba815e..a369590d 100755
--- a/configure
+++ b/configure
@@ -3794,6 +3794,57 @@ fi
$as_echo "$ac_cv___attribute___format_function_pointer" >&6; }
fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((fallthrough)) can be used without warnings" >&5
+$as_echo_n "checking whether __attribute__((fallthrough)) can be used without warnings... " >&6; }
+if ${ac_cv___attribute___fallthrough+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ int x = 1;
+ switch (x)
+ {
+ case 1:
+ printf ("x == %d\n", x);
+ __attribute__ ((fallthrough));
+ case 2:
+ printf ("x == %d\n", x);
+ break;
+ default:
+ return 0;
+ }
+ return x;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute___fallthrough=yes
+else
+ ac_cv___attribute___fallthrough=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___fallthrough" = "yes"; then
+
+$as_echo "#define __ATTRIBUTE___FALLTHROUGH_OK 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___fallthrough" >&5
+$as_echo "$ac_cv___attribute___fallthrough" >&6; }
+
fi
ac_ext=c
diff --git a/configure.in b/configure.in
index 9b06fd92..a7b879fc 100644
--- a/configure.in
+++ b/configure.in
@@ -30,6 +30,7 @@ if test "$ac_cv___attribute__" = "yes"; then
if test "$ac_cv___attribute___format" = "yes"; then
AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
fi
+ AC_C___ATTRIBUTE___FALLTHROUGH
fi
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
diff --git a/netdissect-stdinc.h b/netdissect-stdinc.h
index c7070f0a..fb385fb9 100644
--- a/netdissect-stdinc.h
+++ b/netdissect-stdinc.h
@@ -401,4 +401,10 @@ struct in6_addr {
#define max(a,b) ((b)>(a)?(b):(a))
#endif
+#ifdef __ATTRIBUTE___FALLTHROUGH_OK
+# define ND_FALL_THROUGH __attribute__ ((fallthrough))
+#else
+# define ND_FALL_THROUGH
+#endif /* __ATTRIBUTE___FALLTHROUGH_OK */
+
#endif /* netdissect_stdinc_h */