summaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-05-11 23:46:12 -0700
committerGuy Harris <gharris@sonic.net>2021-05-11 23:46:12 -0700
commit151fe13a136db5a4e5486c4f788868d6d414cb51 (patch)
tree52b63d659b74bf2859698b944e3185e3a7000b82 /pcap-linux.c
parent74765ee123734d32f23387dd776181d0c6c4c41d (diff)
downloadlibpcap-151fe13a136db5a4e5486c4f788868d6d414cb51.tar.gz
On Linux, don't assume the compiler supports __atomic builtins.
Not all compilers that are used to compile code to run on Linux have these builtins. For example, older versions of GCC don't, and at least some people are doing cross-builds for MIPS with older versions of GCC. This should fix GitHub issue #1003.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index c3929dad..878f27f0 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -117,6 +117,19 @@
# define HAVE_TPACKET3
#endif /* TPACKET3_HDRLEN */
+/*
+ * Not all compilers that are used to compile code to run on Linux have
+ * these builtins. For example, older versions of GCC don't, and at
+ * least some people are doing cross-builds for MIPS with older versions
+ * of GCC.
+ */
+#ifndef HAVE___ATOMIC_LOAD_N
+#define __atomic_load_n(ptr, memory_model) (*(ptr))
+#endif
+#ifndef HAVE___ATOMIC_STORE_N
+#define __atomic_store_n(ptr, val, memory_model) *(ptr) = (val)
+#endif
+
#define packet_mmap_acquire(pkt) \
(__atomic_load_n(&pkt->tp_status, __ATOMIC_ACQUIRE) != TP_STATUS_KERNEL)
#define packet_mmap_release(pkt) \