summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in1
-rw-r--r--aclocal.m432
-rw-r--r--cmakeconfig.h.in3
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure42
-rw-r--r--configure.ac1
-rw-r--r--funcattrs.h116
-rw-r--r--gencode.h14
-rw-r--r--portability.h23
-rw-r--r--tests/can_set_rfmon_test.c2
-rw-r--r--tests/capturetest.c51
-rw-r--r--tests/filtertest.c49
-rw-r--r--tests/findalldevstest.c2
-rw-r--r--tests/opentest.c51
-rw-r--r--tests/reactivatetest.c2
-rw-r--r--tests/selpolltest.c51
-rw-r--r--tests/valgrindtest.c51
17 files changed, 140 insertions, 354 deletions
diff --git a/Makefile.in b/Makefile.in
index bf10bf97..cc383fcc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -119,6 +119,7 @@ HDR = $(PUBHDR) \
atmuni31.h \
ethertype.h \
extract.h \
+ funcattrs.h \
gencode.h \
ieee80211.h \
llc.h \
diff --git a/aclocal.m4 b/aclocal.m4
index 83f5761f..a06e2174 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1143,38 +1143,6 @@ AC_MSG_RESULT($ac_cv___attribute___unused)
])
dnl
-dnl Test whether __attribute__((format)) can be used without warnings
-dnl
-
-AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [
-AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings])
-AC_CACHE_VAL(ac_cv___attribute___format, [
-save_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
-AC_COMPILE_IFELSE([
- AC_LANG_SOURCE([[
-#include <stdlib.h>
-
-extern int foo(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-int
-main(int argc, char **argv)
-{
- foo("%s", "test");
-}
- ]])],
-ac_cv___attribute___format=yes,
-ac_cv___attribute___format=no)])
-CFLAGS="$save_CFLAGS"
-if test "$ac_cv___attribute___format" = "yes"; then
- AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1,
- [define if your compiler allows __attribute__((format)) without a warning])
-fi
-AC_MSG_RESULT($ac_cv___attribute___format)
-])
-
-dnl
dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
dnl If so then pcap-linux.c can use this to report proper statistics.
dnl
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
index b4f946d0..566afde3 100644
--- a/cmakeconfig.h.in
+++ b/cmakeconfig.h.in
@@ -312,9 +312,6 @@
/* define on AIX to get certain functions */
#cmakedefine _SUN 1
-/* define if your compiler allows __attribute__((format)) without a warning */
-#cmakedefine __ATTRIBUTE___FORMAT_OK 1
-
#if 0
/* to handle Ultrix compilers that don't support const in prototypes */
#cmakedefine const 1
diff --git a/config.h.in b/config.h.in
index 290aba28..d901c750 100644
--- a/config.h.in
+++ b/config.h.in
@@ -316,9 +316,6 @@
/* define on AIX to get certain functions */
#undef _SUN
-/* define if your compiler allows __attribute__((format)) without a warning */
-#undef __ATTRIBUTE___FORMAT_OK
-
/* to handle Ultrix compilers that don't support const in prototypes */
#undef const
diff --git a/configure b/configure
index 8071ecff..a4904572 100755
--- a/configure
+++ b/configure
@@ -3906,48 +3906,6 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___unused" >&5
$as_echo "$ac_cv___attribute___unused" >&6; }
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((format)) can be used without warnings" >&5
-$as_echo_n "checking whether __attribute__((format)) can be used without warnings... " >&6; }
-if ${ac_cv___attribute___format+:} 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 <stdlib.h>
-
-extern int foo(const char *fmt, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-int
-main(int argc, char **argv)
-{
- foo("%s", "test");
-}
-
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv___attribute___format=yes
-else
- ac_cv___attribute___format=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-CFLAGS="$save_CFLAGS"
-if test "$ac_cv___attribute___format" = "yes"; then
-
-$as_echo "#define __ATTRIBUTE___FORMAT_OK 1" >>confdefs.h
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___format" >&5
-$as_echo "$ac_cv___attribute___format" >&6; }
-
fi
ac_ext=c
diff --git a/configure.ac b/configure.ac
index d275bcaf..4ae1f0bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,7 +27,6 @@ AC_LBL_C_INLINE
AC_C___ATTRIBUTE__
if test "$ac_cv___attribute__" = "yes"; then
AC_C___ATTRIBUTE___UNUSED
- AC_C___ATTRIBUTE___FORMAT
fi
AC_CHECK_HEADERS(sys/bitypes.h)
diff --git a/funcattrs.h b/funcattrs.h
new file mode 100644
index 00000000..b9866b75
--- /dev/null
+++ b/funcattrs.h
@@ -0,0 +1,116 @@
+/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
+/*
+ * Copyright (c) 1993, 1994, 1995, 1996, 1997
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the Computer Systems
+ * Engineering Group at Lawrence Berkeley Laboratory.
+ * 4. Neither the name of the University nor of the Laboratory may be used
+ * to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lib_funcattrs_h
+#define lib_funcattrs_h
+
+/*
+ * Attributes to apply to functions and their arguments, using various
+ * compiler-specific extensions.
+ */
+
+/*
+ * This was introduced by Clang:
+ *
+ * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
+ *
+ * in some version (which version?); it has been picked up by GCC 5.0.
+ */
+#ifndef __has_attribute
+ /*
+ * It's a macro, so you can check whether it's defined to check
+ * whether it's supported.
+ *
+ * If it's not, define it to always return 0, so that we move on to
+ * the fallback checks.
+ */
+ #define __has_attribute(x) 0
+#endif
+
+/*
+ * PCAP_NORETURN, after a function declaration, means "this function
+ * never returns".
+ */
+#if __has_attribute(noreturn) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
+ || (defined(__xlC__) && __xlC__ >= 0x0A01) \
+ || (defined(__HP_aCC) && __HP_aCC >= 61000)
+ /*
+ * Compiler with support for it, or GCC 2.5 and later, or Solaris Studio 12
+ * (Sun C 5.9) and later, or IBM XL C 10.1 and later (do any earlier
+ * versions of XL C support this?), or HP aCC A.06.10 and later.
+ */
+ #define PCAP_NORETURN __attribute((noreturn))
+#elif defined(_MSC_VER)
+ #define PCAP_NORETURN __declspec(noreturn)
+#else
+ #define PCAP_NORETURN
+#endif
+
+/*
+ * PCAP_PRINTFLIKE(x,y), after a function declaration, means "this function
+ * does printf-style formatting, with the xth argument being the format
+ * string and the yth argument being the first argument for the format
+ * string".
+ */
+#if __has_attribute(__format__) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
+ || (defined(__xlC__) && __xlC__ >= 0x0A01) \
+ || (defined(__HP_aCC) && __HP_aCC >= 61000)
+ /*
+ * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
+ * and later (do any earlier versions of XL C support this?),
+ * or HP aCC A.06.10 and later.
+ */
+ #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
+#else
+ #define PCAP_PRINTFLIKE(x,y)
+#endif
+
+/*
+ * For flagging arguments as format strings in MSVC.
+ */
+#if _MSC_VER >= 1400
+ #include <sal.h>
+ #if _MSC_VER > 1400
+ #define PCAP_FORMAT_STRING(p) _Printf_format_string_ p
+ #else
+ #define PCAP_FORMAT_STRING(p) __format_string p
+ #endif
+#else
+ #define PCAP_FORMAT_STRING(p) p
+#endif
+
+#endif /* lib_funcattrs_h */
diff --git a/gencode.h b/gencode.h
index 2b089d21..bd9aeda9 100644
--- a/gencode.h
+++ b/gencode.h
@@ -19,6 +19,8 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#include "funcattrs.h"
+
/*
* ATM support:
*
@@ -53,10 +55,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HAVE___ATTRIBUTE__
-#define __attribute__(x)
-#endif /* HAVE___ATTRIBUTE__ */
-
/* Address qualifiers. */
#define Q_HOST 1
@@ -367,12 +365,8 @@ struct icode {
void bpf_optimize(compiler_state_t *, struct icode *ic);
void bpf_syntax_error(compiler_state_t *, const char *);
-void bpf_error(compiler_state_t *, const char *, ...)
- __attribute__((noreturn))
-#ifdef __ATTRIBUTE___FORMAT_OK
- __attribute__((format (printf, 2, 3)))
-#endif /* __ATTRIBUTE___FORMAT_OK */
- ;
+void bpf_error(compiler_state_t *, const char *, ...) PCAP_NORETURN
+ PCAP_PRINTFLIKE(2, 3);
void finish_parse(compiler_state_t *, struct block *);
char *sdup(compiler_state_t *, const char *);
diff --git a/portability.h b/portability.h
index ce075500..d4343e62 100644
--- a/portability.h
+++ b/portability.h
@@ -39,6 +39,8 @@
* flavors of UN*X.
*/
+#include "funcattrs.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -85,20 +87,6 @@ extern "C" {
#endif
#endif
-/*
- * For flagging arguments as format strings in MSVC.
- */
-#if _MSC_VER >= 1400
- #include <sal.h>
- #if _MSC_VER > 1400
- #define FORMAT_STRING(p) _Printf_format_string_ p
- #else
- #define FORMAT_STRING(p) __format_string p
- #endif
-#else
- #define FORMAT_STRING(p) p
-#endif
-
#ifdef _MSC_VER
#define strdup _strdup
#define sscanf sscanf_s
@@ -146,11 +134,8 @@ extern "C" {
#ifdef HAVE_SNPRINTF
#define pcap_snprintf snprintf
#else
-extern int pcap_snprintf(char *, size_t, FORMAT_STRING(const char *), ...)
-#ifdef __ATTRIBUTE___FORMAT_OK
- __attribute__((format (printf, 3, 4)))
-#endif /* __ATTRIBUTE___FORMAT_OK */
- ;
+extern int pcap_snprintf(char *, size_t, PCAP_FORMAT_STRING(const char *), ...)
+ PCAP_PRINTFLIKE(3, 4);
#endif
#ifdef HAVE_VSNPRINTF
diff --git a/tests/can_set_rfmon_test.c b/tests/can_set_rfmon_test.c
index f1644e66..53a7f366 100644
--- a/tests/can_set_rfmon_test.c
+++ b/tests/can_set_rfmon_test.c
@@ -32,6 +32,8 @@ The Regents of the University of California. All rights reserved.\n";
#include <pcap.h>
+#include "../funcattrs.h"
+
static const char *program_name;
/* Forwards */
diff --git a/tests/capturetest.c b/tests/capturetest.c
index 14b1554b..09a73b40 100644
--- a/tests/capturetest.c
+++ b/tests/capturetest.c
@@ -40,56 +40,9 @@ The Regents of the University of California. All rights reserved.\n";
#include <pcap.h>
-static char *program_name;
-
-/*
- * This was introduced by Clang:
- *
- * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
- *
- * in some version (which version?); it has been picked up by GCC 5.0.
- */
-#ifndef __has_attribute
- /*
- * It's a macro, so you can check whether it's defined to check
- * whether it's supported.
- *
- * If it's not, define it to always return 0, so that we move on to
- * the fallback checks.
- */
- #define __has_attribute(x) 0
-#endif
+#include "../funcattrs.h"
-#if __has_attribute(noreturn) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
- || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.5 and later, or Solaris Studio 12
- * (Sun C 5.9) and later, or IBM XL C 10.1 and later (do any earlier
- * versions of XL C support this?), or HP aCC A.06.10 and later.
- */
- #define PCAP_NORETURN __attribute((noreturn))
-#elif defined( _MSC_VER )
- #define PCAP_NORETURN __declspec(noreturn)
-#else
- #define PCAP_NORETURN
-#endif
-
-#if __has_attribute(__format__) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
- * and later (do any earlier versions of XL C support this?),
- * or HP aCC A.06.10 and later.
- */
- #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
-#else
- #define PCAP_PRINTFLIKE(x,y)
-#endif
+static char *program_name;
/* Forwards */
static void countme(u_char *, const struct pcap_pkthdr *, const u_char *);
diff --git a/tests/filtertest.c b/tests/filtertest.c
index d4440eb0..e9a74c6c 100644
--- a/tests/filtertest.c
+++ b/tests/filtertest.c
@@ -50,54 +50,7 @@ The Regents of the University of California. All rights reserved.\n";
#include <sys/types.h>
#include <sys/stat.h>
-/*
- * This was introduced by Clang:
- *
- * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
- *
- * in some version (which version?); it has been picked up by GCC 5.0.
- */
-#ifndef __has_attribute
- /*
- * It's a macro, so you can check whether it's defined to check
- * whether it's supported.
- *
- * If it's not, define it to always return 0, so that we move on to
- * the fallback checks.
- */
- #define __has_attribute(x) 0
-#endif
-
-#if __has_attribute(noreturn) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
- || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.5 and later, or Solaris Studio 12
- * (Sun C 5.9) and later, or IBM XL C 10.1 and later (do any earlier
- * versions of XL C support this?), or HP aCC A.06.10 and later.
- */
- #define PCAP_NORETURN __attribute((noreturn))
-#elif defined( _MSC_VER )
- #define PCAP_NORETURN __declspec(noreturn)
-#else
- #define PCAP_NORETURN
-#endif
-
-#if __has_attribute(__format__) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
- * and later (do any earlier versions of XL C support this?),
- * or HP aCC A.06.10 and later.
- */
- #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
-#else
- #define PCAP_PRINTFLIKE(x,y)
-#endif
+#include "../funcattrs.h"
static char *program_name;
diff --git a/tests/findalldevstest.c b/tests/findalldevstest.c
index cbd3dad7..88bc3496 100644
--- a/tests/findalldevstest.c
+++ b/tests/findalldevstest.c
@@ -19,6 +19,8 @@
#include <pcap.h>
+#include "../funcattrs.h"
+
static int ifprint(pcap_if_t *d);
static char *iptos(bpf_u_int32 in);
diff --git a/tests/opentest.c b/tests/opentest.c
index b6d634f0..5874d048 100644
--- a/tests/opentest.c
+++ b/tests/opentest.c
@@ -37,59 +37,12 @@ The Regents of the University of California. All rights reserved.\n";
#endif
#include <errno.h>
+#include "../funcattrs.h"
+
#define MAXIMUM_SNAPLEN 65535
static char *program_name;
-/*
- * This was introduced by Clang:
- *
- * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
- *
- * in some version (which version?); it has been picked up by GCC 5.0.
- */
-#ifndef __has_attribute
- /*
- * It's a macro, so you can check whether it's defined to check
- * whether it's supported.
- *
- * If it's not, define it to always return 0, so that we move on to
- * the fallback checks.
- */
- #define __has_attribute(x) 0
-#endif
-
-#if __has_attribute(noreturn) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
- || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.5 and later, or Solaris Studio 12
- * (Sun C 5.9) and later, or IBM XL C 10.1 and later (do any earlier
- * versions of XL C support this?), or HP aCC A.06.10 and later.
- */
- #define PCAP_NORETURN __attribute((noreturn))
-#elif defined( _MSC_VER )
- #define PCAP_NORETURN __declspec(noreturn)
-#else
- #define PCAP_NORETURN
-#endif
-
-#if __has_attribute(__format__) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
- * and later (do any earlier versions of XL C support this?),
- * or HP aCC A.06.10 and later.
- */
- #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
-#else
- #define PCAP_PRINTFLIKE(x,y)
-#endif
-
/* Forwards */
static void PCAP_NORETURN usage(void);
static void PCAP_NORETURN error(const char *, ...) PCAP_PRINTFLIKE(1, 2);
diff --git a/tests/reactivatetest.c b/tests/reactivatetest.c
index 2e1b7b67..c90de155 100644
--- a/tests/reactivatetest.c
+++ b/tests/reactivatetest.c
@@ -31,6 +31,8 @@ The Regents of the University of California. All rights reserved.\n";
#include <string.h>
#include <stdarg.h>
+#include "../funcattrs.h"
+
/* Forwards */
static void error(const char *, ...);
diff --git a/tests/selpolltest.c b/tests/selpolltest.c
index 4c1415b6..9b1ca25e 100644
--- a/tests/selpolltest.c
+++ b/tests/selpolltest.c
@@ -48,56 +48,9 @@ The Regents of the University of California. All rights reserved.\n";
#endif
#include <poll.h>
-char *program_name;
-
-/*
- * This was introduced by Clang:
- *
- * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
- *
- * in some version (which version?); it has been picked up by GCC 5.0.
- */
-#ifndef __has_attribute
- /*
- * It's a macro, so you can check whether it's defined to check
- * whether it's supported.
- *
- * If it's not, define it to always return 0, so that we move on to
- * the fallback checks.
- */
- #define __has_attribute(x) 0
-#endif
+#include "../funcattrs.h"
-#if __has_attribute(noreturn) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
- || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.5 and later, or Solaris Studio 12
- * (Sun C 5.9) and later, or IBM XL C 10.1 and later (do any earlier
- * versions of XL C support this?), or HP aCC A.06.10 and later.
- */
- #define PCAP_NORETURN __attribute((noreturn))
-#elif defined( _MSC_VER )
- #define PCAP_NORETURN __declspec(noreturn)
-#else
- #define PCAP_NORETURN
-#endif
-
-#if __has_attribute(__format__) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
- * and later (do any earlier versions of XL C support this?),
- * or HP aCC A.06.10 and later.
- */
- #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
-#else
- #define PCAP_PRINTFLIKE(x,y)
-#endif
+char *program_name;
/* Forwards */
static void countme(u_char *, const struct pcap_pkthdr *, const u_char *);
diff --git a/tests/valgrindtest.c b/tests/valgrindtest.c
index 011fe117..86bef7de 100644
--- a/tests/valgrindtest.c
+++ b/tests/valgrindtest.c
@@ -64,6 +64,8 @@ The Regents of the University of California. All rights reserved.\n";
#include <sys/types.h>
#include <sys/stat.h>
+#include "../funcattrs.h"
+
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
/* BSD-flavored OS - use BPF */
#define USE_BPF
@@ -99,55 +101,6 @@ The Regents of the University of California. All rights reserved.\n";
static char *program_name;
-/*
- * This was introduced by Clang:
- *
- * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
- *
- * in some version (which version?); it has been picked up by GCC 5.0.
- */
-#ifndef __has_attribute
- /*
- * It's a macro, so you can check whether it's defined to check
- * whether it's supported.
- *
- * If it's not, define it to always return 0, so that we move on to
- * the fallback checks.
- */
- #define __has_attribute(x) 0
-#endif
-
-#if __has_attribute(noreturn) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
- || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.5 and later, or Solaris Studio 12
- * (Sun C 5.9) and later, or IBM XL C 10.1 and later (do any earlier
- * versions of XL C support this?), or HP aCC A.06.10 and later.
- */
- #define PCAP_NORETURN __attribute((noreturn))
-#elif defined( _MSC_VER )
- #define PCAP_NORETURN __declspec(noreturn)
-#else
- #define PCAP_NORETURN
-#endif
-
-#if __has_attribute(__format__) \
- || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)) \
- || (defined(__xlC__) && __xlC__ >= 0x0A01) \
- || (defined(__HP_aCC) && __HP_aCC >= 61000)
- /*
- * Compiler with support for it, or GCC 2.3 and later, or IBM XL C 10.1
- * and later (do any earlier versions of XL C support this?),
- * or HP aCC A.06.10 and later.
- */
- #define PCAP_PRINTFLIKE(x,y) __attribute__((__format__(__printf__,x,y)))
-#else
- #define PCAP_PRINTFLIKE(x,y)
-#endif
-
/* Forwards */
static void PCAP_NORETURN usage(void);
static void PCAP_NORETURN error(const char *, ...) PCAP_PRINTFLIKE(1, 2);