atmuni31.h \
ethertype.h \
extract.h \
+ funcattrs.h \
gencode.h \
ieee80211.h \
llc.h \
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.
/* 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
/* 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
{ $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
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)
--- /dev/null
+/* -*- 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 */
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#include "funcattrs.h"
+
/*
* ATM support:
*
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HAVE___ATTRIBUTE__
-#define __attribute__(x)
-#endif /* HAVE___ATTRIBUTE__ */
-
/* Address qualifiers. */
#define Q_HOST 1
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 *);
* flavors of UN*X.
*/
+#include "funcattrs.h"
+
#ifdef __cplusplus
extern "C" {
#endif
#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
#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
#include <pcap.h>
+#include "../funcattrs.h"
+
static const char *program_name;
/* Forwards */
#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 *);
#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;
#include <pcap.h>
+#include "../funcattrs.h"
+
static int ifprint(pcap_if_t *d);
static char *iptos(bpf_u_int32 in);
#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);
#include <string.h>
#include <stdarg.h>
+#include "../funcattrs.h"
+
/* Forwards */
static void error(const char *, ...);
#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 *);
#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
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);