From a02afe6d4ffca18c3b0b04d14328f25fcf57ad95 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Fri, 16 Dec 2022 15:26:37 +0100 Subject: [PATCH] Added ifdefs for DragonflyBSD Possible fix for #3179 --- src/backend/cpu/platform/BasicCpuInfo_arm.cpp | 4 ++-- src/base/kernel/Platform_unix.cpp | 4 ++-- src/crypto/common/VirtualMemory_unix.cpp | 6 +++--- src/hw/dmi/DmiReader_unix.cpp | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/cpu/platform/BasicCpuInfo_arm.cpp b/src/backend/cpu/platform/BasicCpuInfo_arm.cpp index c21642ec6..f6edd503c 100644 --- a/src/backend/cpu/platform/BasicCpuInfo_arm.cpp +++ b/src/backend/cpu/platform/BasicCpuInfo_arm.cpp @@ -27,7 +27,7 @@ #if __ARM_FEATURE_CRYPTO && !defined(__APPLE__) # include -# ifndef __FreeBSD__ +# if !defined(__FreeBSD__) && !defined(__DragonFly__) # include # else # include @@ -71,7 +71,7 @@ xmrig::BasicCpuInfo::BasicCpuInfo() : # if __ARM_FEATURE_CRYPTO # if defined(__APPLE__) m_flags.set(FLAG_AES, true); -# elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) || defined(__DragonFly__) uint64_t isar0 = READ_SPECIALREG(id_aa64isar0_el1); m_flags.set(FLAG_AES, ID_AA64ISAR0_AES_VAL(isar0) >= ID_AA64ISAR0_AES_BASE); # else diff --git a/src/base/kernel/Platform_unix.cpp b/src/base/kernel/Platform_unix.cpp index f5bbc1931..4c4fe92e9 100644 --- a/src/base/kernel/Platform_unix.cpp +++ b/src/base/kernel/Platform_unix.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__DragonFly__) # include # include # include @@ -41,7 +41,7 @@ #include "version.h" -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__DragonFly__) typedef cpuset_t cpu_set_t; #endif diff --git a/src/crypto/common/VirtualMemory_unix.cpp b/src/crypto/common/VirtualMemory_unix.cpp index 12f4f25f8..1f3be36ba 100644 --- a/src/crypto/common/VirtualMemory_unix.cpp +++ b/src/crypto/common/VirtualMemory_unix.cpp @@ -65,7 +65,7 @@ #endif -#if defined(XMRIG_OS_LINUX) || (!defined(XMRIG_OS_APPLE) && !defined(__FreeBSD__)) +#if defined(XMRIG_OS_LINUX) || (!defined(XMRIG_OS_APPLE) && !defined(__FreeBSD__) && !defined(__DragonFly__)) static inline int hugePagesFlag(size_t size) { return (static_cast(log2(size)) & MAP_HUGE_MASK) << MAP_HUGE_SHIFT; @@ -135,7 +135,7 @@ void *xmrig::VirtualMemory::allocateExecutableMemory(size_t size, bool hugePages # ifdef XMRIG_ARM pthread_jit_write_protect_np(false); # endif -# elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) || defined(__DragonFly__) void *mem = nullptr; if (hugePages) { @@ -168,7 +168,7 @@ void *xmrig::VirtualMemory::allocateLargePagesMemory(size_t size) { # if defined(XMRIG_OS_APPLE) void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0); -# elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) || defined(__DragonFly__) void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0); # else void *mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE | hugePagesFlag(hugePageSize()), 0, 0); diff --git a/src/hw/dmi/DmiReader_unix.cpp b/src/hw/dmi/DmiReader_unix.cpp index e01e22624..2f7030fa2 100644 --- a/src/hw/dmi/DmiReader_unix.cpp +++ b/src/hw/dmi/DmiReader_unix.cpp @@ -31,7 +31,7 @@ #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__DragonFly__) # include #endif @@ -288,7 +288,7 @@ static off_t address_from_efi() const char *filename; char linebuf[64]; off_t address = 0; -# elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) || defined(__DragonFly__) char addrstr[KENV_MVALLEN + 1]; # endif @@ -310,7 +310,7 @@ static off_t address_from_efi() fclose(efi_systab); return address; -# elif defined(__FreeBSD__) +# elif defined(__FreeBSD__) || defined(__DragonFly__) if (kenv(KENV_GET, "hint.smbios.0.mem", addrstr, sizeof(addrstr)) == -1) { return EFI_NOT_FOUND; }