]> The Tcpdump Group git mirrors - libpcap/commitdiff
Move all the function attributes from funcattrs.h to pcap/funcattrs.h.
authorGuy Harris <[email protected]>
Fri, 8 Sep 2017 21:04:04 +0000 (14:04 -0700)
committerGuy Harris <[email protected]>
Fri, 8 Sep 2017 21:04:04 +0000 (14:04 -0700)
That lets us use any of them in public declarations, if we ever need to.

13 files changed:
Makefile.in
funcattrs.h [deleted file]
gencode.h
pcap/funcattrs.h
portability.h
tests/can_set_rfmon_test.c
tests/capturetest.c
tests/filtertest.c
tests/findalldevstest.c
tests/opentest.c
tests/reactivatetest.c
tests/selpolltest.c
tests/valgrindtest.c

index 535b7de919c604097b380572dd6841e57d7100ea..08825f0d65b46bef4b8ca1a18e005f3949d7c821 100644 (file)
@@ -120,7 +120,6 @@ HDR = $(PUBHDR) \
        ethertype.h \
        extract.h \
        ftmacros.h \
-       funcattrs.h \
        gencode.h \
        ieee80211.h \
        llc.h \
diff --git a/funcattrs.h b/funcattrs.h
deleted file mode 100644 (file)
index bd6ba9f..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/* -*- 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, before a function declaration, means "this function
- * never returns".  (It must go before the function declaration, e.g.
- * "extern PCAP_NORETURN func(...)" rather than after the function
- * declaration, as the MSVC version has to go before the declaration.)
- */
-#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 __attribute((noreturn)), 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)
-  /*
-   * MSVC.
-   */
-  #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 */
index 085b6fd7cad40c5688b39b824e27da0bf7317c84..a494932589bbd5256a1570337c9a3f4a11feb138 100644 (file)
--- a/gencode.h
+++ b/gencode.h
@@ -19,7 +19,7 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#include "funcattrs.h"
+#include "pcap/funcattrs.h"
 
 /*
  * ATM support:
index f7e950461e03b2ba4d2becaa1d54ec55371ab506..eec5e7880d6dba0a84c27d84c68f0834e5a3e7e5 100644 (file)
 #ifndef lib_pcap_funcattrs_h
 #define lib_pcap_funcattrs_h
 
+/*
+ * Attributes to apply to functions and their arguments, using various
+ * compiler-specific extensions.
+ */
+
 /*
  * PCAP_API_DEF must be used when defining *data* exported from
  * libpcap.  It can be used when defining *functions* exported
  * exported from libpcap; PCAP_API_DEF won't work on all platforms.
  */
 
+/*
+ * 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
+
 /*
  * Check whether this is GCC major.minor or a later release, or some
  * compiler that claims to be "just like GCC" of that version or a
      * shared library by default, so we might have to explicitly mark
      * functions as exported.
      */
-    #if IS_AT_LEAST_GNUC_VERSION(3, 4)
+    #if IS_AT_LEAST_GNUC_VERSION(3, 4) \
+        || (defined(__xlC__) && __xlC__ >= 0x0C00)
       /*
        * GCC 3.4 or later, or some compiler asserting compatibility with
-       * GCC 3.4 or later, so we have __attribute__((visibility()).
+       * GCC 3.4 or later, or XL C 13.0 or later, so we have
+       * __attribute__((visibility()).
        */
       #define PCAP_API_DEF     __attribute__((visibility("default")))
     #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
 
 #define PCAP_API       PCAP_API_DEF extern
 
+/*
+ * PCAP_NORETURN, before a function declaration, means "this function
+ * never returns".  (It must go before the function declaration, e.g.
+ * "extern PCAP_NORETURN func(...)" rather than after the function
+ * declaration, as the MSVC version has to go before the declaration.)
+ */
+#if __has_attribute(noreturn) \
+    || IS_AT_LEAST_GNUC_VERSION(2, 5) \
+    || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) \
+    || (defined(__xlC__) && __xlC__ >= 0x0A01) \
+    || (defined(__HP_aCC) && __HP_aCC >= 61000)
+  /*
+   * Compiler with support for __attribute((noreturn)), 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)
+  /*
+   * MSVC.
+   */
+  #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__) \
+    || IS_AT_LEAST_GNUC_VERSION(2, 3) \
+    || (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_pcap_funcattrs_h */
index 21445bd54d94c0bd726b0b9e0f9cb5099d496731..862ae706997eae0cb90f1f8b6d3ead768a8d1b80 100644 (file)
@@ -39,7 +39,7 @@
  * flavors of UN*X.
  */
 
-#include "funcattrs.h"
+#include "pcap/funcattrs.h"
 
 #ifdef __cplusplus
 extern "C" {
index 53a7f3663ea53b98f4b581f804eeb0979da52e71..88661d63f6cd6811a43fba656022e81e245c4ab4 100644 (file)
@@ -32,7 +32,7 @@ The Regents of the University of California.  All rights reserved.\n";
 
 #include <pcap.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 static const char *program_name;
 
index 09a73b40c4160b7b4a0af4f8e4931dc36e9acb10..8e859c0515b396c5063cabf0cf53a5486ccd1b5d 100644 (file)
@@ -40,7 +40,7 @@ The Regents of the University of California.  All rights reserved.\n";
 
 #include <pcap.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 static char *program_name;
 
index 314cc7ae31611046e81b7cb32ee3f234bc0da424..a79fb25f95121942cdb0a03df0065ca44e150ce3 100644 (file)
@@ -50,7 +50,7 @@ The Regents of the University of California.  All rights reserved.\n";
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 static char *program_name;
 
index 2d4086205cf3426ea5d7d865dfd744ecd54b5486..95abd644a0015495484554eb56f107d2d5e98f78 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <pcap.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 static int ifprint(pcap_if_t *d);
 static char *iptos(bpf_u_int32 in);
index 5874d048507267859d0dba3c5a0863d164c3242a..59a11e71af2e489541a4abf13659353bbd155f9e 100644 (file)
@@ -37,7 +37,7 @@ The Regents of the University of California.  All rights reserved.\n";
 #endif
 #include <errno.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 #define MAXIMUM_SNAPLEN                65535
 
index c90de155d7c9458aaff2216962125d180c99a6fc..f3485cbda81bd9c97c5bba546715956d2bc19687 100644 (file)
@@ -31,7 +31,7 @@ The Regents of the University of California.  All rights reserved.\n";
 #include <string.h>
 #include <stdarg.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 /* Forwards */
 static void error(const char *, ...);
index 9b1ca25e086a2e4825ad45ddad742baba0f9d56f..cf46f37aa5fb9d589e37ea8db50720e9ea0ef151 100644 (file)
@@ -48,7 +48,7 @@ The Regents of the University of California.  All rights reserved.\n";
 #endif
 #include <poll.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 char *program_name;
 
index 9d9e9a29e0fe96fd7dd13fe57a34e450f0b10459..d90c69aed904929e440477231c7f25dfaa21bb98 100644 (file)
@@ -64,7 +64,7 @@ The Regents of the University of California.  All rights reserved.\n";
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include "../funcattrs.h"
+#include "pcap/funcattrs.h"
 
 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
 /* BSD-flavored OS - use BPF */