]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
support building on NetBSD
authorG.E. <gregory.economou@vectorcamp.gr>
Wed, 6 Mar 2024 09:48:56 +0000 (10:48 +0100)
committerG.E. <gregory.economou@vectorcamp.gr>
Wed, 6 Mar 2024 09:48:56 +0000 (10:48 +0100)
README.md
cmake/osdetection.cmake
examples/patbench.cc
examples/pcapscan.cc
src/util/popcount.h

index 7f7c2f531075fdf5d7f3695c5192c625ec842520..cf2e5f408f3afbae144cdde283d9345525ff45d2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -113,6 +113,17 @@ Assuming an existing HomeBrew installation:
 % brew install boost cmake gcc libpcap pkg-config ragel sqlite
 ```
 
+### NetBSD
+In NetBSD you will almost certainly need to have a newer compiler installed. 
+Using the example of gcc12 from pkgsrc, one will need to set three
+environment variables before starting: 
+export CC="/usr/pkg/gcc12/bin/cc"
+export CXX="/usr/pkg/gcc12/bin/g++"
+export CXXFLAGS="-gdwarf-4"
+
+Then continue with the build as below. 
+
+
 ## Configure & build
 
 In order to configure with `cmake` first create and cd into a build directory:
index 59f2b342e511dc7feadf189733df76eaea163b8e..0e730fe38315f882b6f4d33bac95127fb90bae23 100644 (file)
@@ -6,7 +6,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
     set(FREEBSD true)
 endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
 
-if (ARCH_IA32 OR ARCH_X86_64)
+if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+    set(NETBSD true)
+endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+
+if (LINUX AND (ARCH_IA32 OR ARCH_X86_64))
   option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" ON)
 else()
   option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" OFF)
index 8180d2a9ddf0ca05d57d1693b8521bf6f90df17e..7bb5020a945f3f72bbd580e7f7a2b2e934aa65fb 100644 (file)
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
 #include <netinet/ip_icmp.h>
+#ifdef __NetBSD__
+#include <net/ethertypes.h>
+#include <net/if_ether.h>
+#else
 #include <net/ethernet.h>
+#endif /* __NetBSD__ */
 #include <arpa/inet.h>
 
 #include <pcap.h>
index 12b944388e594c7663c068a017dadecb9345e65c..349ef6a9c57c84523cf5576cd39eae820083a807 100644 (file)
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
 #include <netinet/ip_icmp.h>
+#ifdef __NetBSD__
+#include <net/ethertypes.h>
+#include <net/if_ether.h>
+#else
 #include <net/ethernet.h>
+#endif /* __NetBSD__ */
 #include <arpa/inet.h>
 
 #include <pcap.h>
index d90a0d50d075f5c56dd72d8561201583dc0d8fba..e9f689e900172b281b2b84cca702cd63ce0205a2 100644 (file)
 
 #include "ue2common.h"
 #include "util/arch.h"
+#ifdef __NetBSD__
+#include <strings.h>
+#endif
 
+
+#ifndef __NetBSD__
 static really_inline
 u32 popcount32(u32 x) {
     return __builtin_popcount(x);
@@ -51,6 +56,7 @@ u32 popcount32(u32 x) {
 //     return (((x + (x >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;
 // #endif
 }
+#endif /* __NetBSD__ */
 
 static really_inline
 u32 popcount32x4(u32 const *x) {
@@ -61,6 +67,7 @@ u32 popcount32x4(u32 const *x) {
     return sum;
 }
 
+#ifndef __NetBSD__
 static really_inline
 u32 popcount64(u64a x) {
     return __builtin_popcountll(x);
@@ -81,6 +88,7 @@ u32 popcount64(u64a x) {
 //     return popcount32(x >> 32) + popcount32(x);
 // #endif
 }
+#endif /* __NetBSD__ */
 
 static really_inline
 u32 popcount64x4(u64a const *x) {