aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2023-07-08 14:35:10 -0700
committerGuy Harris <gharris@sonic.net>2023-07-08 14:35:10 -0700
commitff91e1b1270d99cceab96eb851ea98510e9981d4 (patch)
treeb35274a9ff4422deb96e7e0f450d99251f104a5e
parenta32cc7511fe9d7ffa5f91bcd4e0023505e886754 (diff)
Redo the availability macros.
Apple appears to have tweaked their pcap/funcattrs.h to do the right thing at some point, so 1) there's no need to urge them to do so any more and 2) they only seem to export libpcap APIs in macOS, so redo the PCAP_AVAILABLE() stuff to be more like what they've done. We remove the include of <Availability.h>, as we don't need it ourselves (we don't do the availability stuff in our releases, for reasons given in the comment before the availability stuff), and Apple uses <os/availability.h> - we leave it up to them to modify the header, just as they do with, for example, ZLib's zlib.h. (Many thanks to the Apple people who picked this up!)
-rw-r--r--pcap/funcattrs.h50
1 files changed, 22 insertions, 28 deletions
diff --git a/pcap/funcattrs.h b/pcap/funcattrs.h
index 37409499..8699c76d 100644
--- a/pcap/funcattrs.h
+++ b/pcap/funcattrs.h
@@ -152,7 +152,7 @@
* APIs to be designated as "first available in this release" to do so
* by appropriately defining them.
*
- * Yes, that's you, Apple. :-) Please define PCAP_AVAILABLE_MACOS()
+ * On macOS, Apple can tweak this to define PCAP_AVAILABLE_MACOS()
* as necessary to make various APIs "weak exports" to make it easier
* for software that's distributed in binary form and that uses libpcap
* to run on multiple macOS versions and use new APIs when available.
@@ -161,15 +161,6 @@
* provided by Apple, so each release can come with a version compiled
* to use the APIs present in that release.)
*
- * The non-macOS versioning is based on
- *
- * https://en.wikipedia.org/wiki/Darwin_(operating_system)#Release_history
- *
- * If there are any corrections, please submit it upstream to the
- * libpcap maintainers, preferably as a pull request on
- *
- * https://github.com/the-tcpdump-group/libpcap
- *
* We don't define it ourselves because, if you're building and
* installing libpcap on macOS yourself, the APIs will be available
* no matter what OS version you're installing it on.
@@ -181,31 +172,34 @@
* I've never seen earlier releases.
*/
#ifdef __APPLE__
-#include <Availability.h>
/*
- * When building as part of macOS, define this as __API_AVAILABLE(__VA_ARGS__).
+ * Apple - insert #include <os/availability.h> here, and define
+ * PCAP_AVAILABLE(v) as
+ *
+ * API_AVAILABLE(macos(v)) API_UNAVAILABLE(ios, tvos, watchos)
*
- * XXX - if there's some #define to indicate that this is being built
- * as part of the macOS build process, we could make that Just Work.
+ * and add any other OSes to the list as appropriate (visionOS?
+ * Surely being able to watch packet traffic through your Apple Vision
+ * Pro would be k00l as heck.... :-))
*/
-#define PCAP_AVAILABLE(...)
-#define PCAP_AVAILABLE_0_4 PCAP_AVAILABLE(macos(10.0)) /* Did any version of Mac OS X ship with this? */
-#define PCAP_AVAILABLE_0_5 PCAP_AVAILABLE(macos(10.0)) /* Did any version of Mac OS X ship with this? */
-#define PCAP_AVAILABLE_0_6 PCAP_AVAILABLE(macos(10.1))
-#define PCAP_AVAILABLE_0_7 PCAP_AVAILABLE(macos(10.4))
-#define PCAP_AVAILABLE_0_8 PCAP_AVAILABLE(macos(10.4))
-#define PCAP_AVAILABLE_0_9 PCAP_AVAILABLE(macos(10.5), ios(1.0))
-#define PCAP_AVAILABLE_1_0 PCAP_AVAILABLE(macos(10.6), ios(4.0))
+#define PCAP_AVAILABLE_MACOS(v)
+#define PCAP_AVAILABLE_0_4 PCAP_AVAILABLE_MACOS(10.0) /* Did any version of Mac OS X ship with this? */
+#define PCAP_AVAILABLE_0_5 PCAP_AVAILABLE_MACOS(10.0) /* Did any version of Mac OS X ship with this? */
+#define PCAP_AVAILABLE_0_6 PCAP_AVAILABLE_MACOS(10.1)
+#define PCAP_AVAILABLE_0_7 PCAP_AVAILABLE_MACOS(10.4)
+#define PCAP_AVAILABLE_0_8 PCAP_AVAILABLE_MACOS(10.4)
+#define PCAP_AVAILABLE_0_9 PCAP_AVAILABLE_MACOS(10.5)
+#define PCAP_AVAILABLE_1_0 PCAP_AVAILABLE_MACOS(10.6)
/* #define PCAP_AVAILABLE_1_1 no routines added to the API */
-#define PCAP_AVAILABLE_1_2 PCAP_AVAILABLE(macos(10.9), ios(6.0))
+#define PCAP_AVAILABLE_1_2 PCAP_AVAILABLE_MACOS(10.9)
/* #define PCAP_AVAILABLE_1_3 no routines added to the API */
/* #define PCAP_AVAILABLE_1_4 no routines added to the API */
-#define PCAP_AVAILABLE_1_5 PCAP_AVAILABLE(macos(10.10), ios(7.0), watchos(1.0))
+#define PCAP_AVAILABLE_1_5 PCAP_AVAILABLE_MACOS(10.10)
/* #define PCAP_AVAILABLE_1_6 no routines added to the API */
-#define PCAP_AVAILABLE_1_7 PCAP_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
-#define PCAP_AVAILABLE_1_8 PCAP_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) /* only Windows adds routines to the API; XXX - what version first had it? */
-#define PCAP_AVAILABLE_1_9 PCAP_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0))
-#define PCAP_AVAILABLE_1_10 /* not in macOS yet */
+#define PCAP_AVAILABLE_1_7 PCAP_AVAILABLE_MACOS(10.12)
+#define PCAP_AVAILABLE_1_8 PCAP_AVAILABLE_MACOS(10.13)
+#define PCAP_AVAILABLE_1_9 PCAP_AVAILABLE_MACOS(10.13)
+#define PCAP_AVAILABLE_1_10 PCAP_AVAILABLE_MACOS(12.1)
#define PCAP_AVAILABLE_1_11 /* not released yet, so not in macOS yet */
#else /* __APPLE__ */
#define PCAP_AVAILABLE_0_4