From b00da61eab03df2268a2c9946e03385a7d38a5fb Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Thu, 15 Dec 2016 02:27:53 -0800 Subject: [PATCH] Preliminary support for DragonFly BSD - It builds but no further testing has been done. --- CMakeLists.txt | 16 +++++++++++----- external/miniupnpc/CMakeLists.txt | 4 ++-- src/crypto/crypto.cpp | 2 +- src/crypto/oaes_lib.c | 3 ++- src/crypto/slow-hash.c | 3 ++- src/crypto/tree-hash.c | 2 +- tests/performance_tests/performance_utils.h | 4 ++-- tests/unit_tests/slow_memmem.cpp | 3 ++- 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4b680e84..87a53c368 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,12 +149,15 @@ message(STATUS "Building for a ${ARCH_WIDTH}-bit system") # Check if we're on FreeBSD so we can exclude the local miniupnpc (it should be installed from ports instead) # CMAKE_SYSTEM_NAME checks are commonly known, but specifically taken from libsdl's CMakeLists -if(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*") - set(FREEBSD TRUE) -elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD") +if(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*|FreeBSD") set(FREEBSD TRUE) endif() +# Check if we're on DragonFly BSD. See the README.md for build instructions. +if(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*") + set(DRAGONFLY TRUE) +endif() + # Check if we're on OpenBSD. See the README.md for build instructions. if(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*") set(OPENBSD TRUE) @@ -519,7 +522,7 @@ else() set(RELEASE_FLAGS "${RELEASE_FLAGS} -ffat-lto-objects") endif() # Since gcc 4.9 the LTO format is non-standard (slim), so we need the gcc-specific ar and ranlib binaries - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0) AND NOT OPENBSD) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0) AND NOT OPENBSD AND NOT DRAGONFLY) # When invoking cmake on distributions on which gcc's binaries are prefixed # with an arch-specific triplet, the user must specify -DCHOST= if (DEFINED CHOST) @@ -544,7 +547,7 @@ else() # On Windows, this is as close to fully-static as we get: # this leaves only deps on /c/Windows/system32/*.dll set(STATIC_FLAGS "-static") - elseif (NOT (APPLE OR FREEBSD OR OPENBSD)) + elseif (NOT (APPLE OR FREEBSD OR OPENBSD OR DRAGONFLY)) # On Linux, we don't support fully static build, but these can be static set(STATIC_FLAGS "-static-libgcc -static-libstdc++") endif() @@ -579,6 +582,9 @@ if(MINGW) set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi) elseif(APPLE OR FREEBSD OR OPENBSD) set(EXTRA_LIBRARIES "") +elseif(DRAGONFLY) + find_library(COMPAT compat) + set(EXTRA_LIBRARIES ${COMPAT}) elseif(NOT MSVC) find_library(RT rt) set(EXTRA_LIBRARIES ${RT}) diff --git a/external/miniupnpc/CMakeLists.txt b/external/miniupnpc/CMakeLists.txt index 1d6572ba6..4c01b6d06 100644 --- a/external/miniupnpc/CMakeLists.txt +++ b/external/miniupnpc/CMakeLists.txt @@ -32,10 +32,10 @@ endif (NO_GETADDRINFO) if (NOT WIN32) add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT) add_definitions (-D_BSD_SOURCE -D_DEFAULT_SOURCE) - if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + if (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "DragonFly") # add_definitions (-D_POSIX_C_SOURCE=200112L) add_definitions (-D_XOPEN_SOURCE=600) - endif (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + endif (NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_NAME STREQUAL "DragonFly") else (NOT WIN32) add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends endif (NOT WIN32) diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index 250779ac3..6ceb944cd 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -42,7 +42,7 @@ #include "crypto.h" #include "hash.h" -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) #include #else #include diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index 2cf598e05..f054a16f4 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -34,7 +34,8 @@ #include // OS X, FreeBSD, and OpenBSD don't need malloc.h -#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) \ + && !defined(__DragonFly__) #include #endif diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 2ac303a36..66d9ca5d9 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -442,7 +442,8 @@ void slow_hash_allocate_state(void) hp_state = (uint8_t *) VirtualAlloc(hp_state, MEMORY, MEM_LARGE_PAGES | MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #else -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__) hp_state = mmap(0, MEMORY, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0); #else diff --git a/src/crypto/tree-hash.c b/src/crypto/tree-hash.c index 7a128e4b0..d73f0d959 100644 --- a/src/crypto/tree-hash.c +++ b/src/crypto/tree-hash.c @@ -34,7 +34,7 @@ #include "hash-ops.h" -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) #include #else #include diff --git a/tests/performance_tests/performance_utils.h b/tests/performance_tests/performance_utils.h index ba2b71740..487caa676 100644 --- a/tests/performance_tests/performance_utils.h +++ b/tests/performance_tests/performance_utils.h @@ -40,7 +40,7 @@ void set_process_affinity(int core) { -#if defined (__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined (__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) return; #elif defined(BOOST_WINDOWS) DWORD_PTR mask = 1; @@ -62,7 +62,7 @@ void set_process_affinity(int core) void set_thread_high_priority() { -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) return; #elif defined(BOOST_WINDOWS) ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); diff --git a/tests/unit_tests/slow_memmem.cpp b/tests/unit_tests/slow_memmem.cpp index a14e01885..d36b9f532 100644 --- a/tests/unit_tests/slow_memmem.cpp +++ b/tests/unit_tests/slow_memmem.cpp @@ -36,7 +36,8 @@ #include "gtest/gtest.h" // OS X, FreeBSD, and OpenBSD don't need malloc.h -#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) +#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && \ + !defined(__DragonFly__) #include #endif