OpenBSD support for Monero.
This commit is contained in:
parent
e75cfe088f
commit
28f95eb001
|
@ -139,12 +139,16 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
|
||||||
set(FREEBSD TRUE)
|
set(FREEBSD TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO: check bsdi, NetBSD, OpenBSD, to see if they need the same FreeBSD changes
|
# Check if we're on OpenBSD. Compile with gcc 4.9 from packages.
|
||||||
|
# Use "env CC=egcc CXX=eg++ CPP=ecpp make release-static-64" or similar.
|
||||||
|
if(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
|
||||||
|
set(OPENBSD TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# TODO: check bsdi, NetBSD, to see if they need the same FreeBSD changes
|
||||||
#
|
#
|
||||||
# elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
|
# elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
|
||||||
# set(NETBSD TRUE)
|
# set(NETBSD TRUE)
|
||||||
# elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
|
|
||||||
# set(OPENBSD TRUE)
|
|
||||||
# elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
|
# elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
|
||||||
# set(BSDI TRUE)
|
# set(BSDI TRUE)
|
||||||
|
|
||||||
|
@ -385,11 +389,18 @@ else()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(OPENBSD)
|
||||||
|
# This works around some bugs in the gcc 4.9 package as well as forces Boost to use the multithreaded libs
|
||||||
|
set(CMAKE_AR "ar")
|
||||||
|
set(CMAKE_RANLIB "ranlib")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS}")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${DEBUG_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}")
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}")
|
||||||
if(STATIC AND NOT APPLE AND NOT FREEBSD)
|
if(STATIC AND NOT APPLE AND NOT FREEBSD AND NOT OPENBSD)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -421,7 +432,7 @@ endif()
|
||||||
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi)
|
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi)
|
||||||
elseif(APPLE OR FREEBSD)
|
elseif(APPLE OR FREEBSD OR OPENBSD)
|
||||||
set(EXTRA_LIBRARIES "")
|
set(EXTRA_LIBRARIES "")
|
||||||
elseif(NOT MSVC)
|
elseif(NOT MSVC)
|
||||||
find_library(RT rt)
|
find_library(RT rt)
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
|
@ -129,7 +132,11 @@ namespace epee
|
||||||
bool wait_stdin_data()
|
bool wait_stdin_data()
|
||||||
{
|
{
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
int stdin_fileno = fileno(stdin);
|
||||||
|
#else
|
||||||
int stdin_fileno = ::fileno(stdin);
|
int stdin_fileno = ::fileno(stdin);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (m_run.load(std::memory_order_relaxed))
|
while (m_run.load(std::memory_order_relaxed))
|
||||||
{
|
{
|
||||||
|
|
|
@ -784,8 +784,10 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags)
|
||||||
m_env->set_lk_max_lockers(DB_MAX_LOCKS);
|
m_env->set_lk_max_lockers(DB_MAX_LOCKS);
|
||||||
m_env->set_lk_max_objects(DB_MAX_LOCKS);
|
m_env->set_lk_max_objects(DB_MAX_LOCKS);
|
||||||
|
|
||||||
|
#ifndef __OpenBSD__ //OpenBSD's DB package is too old to support this feature
|
||||||
if(m_auto_remove_logs)
|
if(m_auto_remove_logs)
|
||||||
m_env->log_set_config(DB_LOG_AUTO_REMOVE, 1);
|
m_env->log_set_config(DB_LOG_AUTO_REMOVE, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
// last parameter left 0, files will be created with default rw access
|
// last parameter left 0, files will be created with default rw access
|
||||||
m_env->open(filename.c_str(), db_env_open_flags, 0);
|
m_env->open(filename.c_str(), db_env_open_flags, 0);
|
||||||
|
|
|
@ -137,6 +137,7 @@ static inline uint32_t div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uin
|
||||||
static inline uint32_t ident32(uint32_t x) { return x; }
|
static inline uint32_t ident32(uint32_t x) { return x; }
|
||||||
static inline uint64_t ident64(uint64_t x) { return x; }
|
static inline uint64_t ident64(uint64_t x) { return x; }
|
||||||
|
|
||||||
|
#ifndef __OpenBSD__
|
||||||
static inline uint32_t swap32(uint32_t x) {
|
static inline uint32_t swap32(uint32_t x) {
|
||||||
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
|
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
|
||||||
return (x << 16) | (x >> 16);
|
return (x << 16) | (x >> 16);
|
||||||
|
@ -146,6 +147,7 @@ static inline uint64_t swap64(uint64_t x) {
|
||||||
x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
|
x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
|
||||||
return (x << 32) | (x >> 32);
|
return (x << 32) | (x >> 32);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#define UNUSED __attribute__((unused))
|
#define UNUSED __attribute__((unused))
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
#ifndef __FreeBSD__
|
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -37,13 +37,13 @@ static const char _NR[] = {
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
// Both OS X and FreeBSD don't need malloc.h
|
// OS X, FreeBSD, and OpenBSD don't need malloc.h
|
||||||
#if !defined(__APPLE__) && !defined(__FreeBSD__)
|
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FreeBSD also doesn't need timeb.h
|
// FreeBSD, and OpenBSD also don't need timeb.h
|
||||||
#ifndef __FreeBSD__
|
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -470,7 +470,7 @@ OAES_RET oaes_sprintf(
|
||||||
#ifdef OAES_HAVE_ISAAC
|
#ifdef OAES_HAVE_ISAAC
|
||||||
static void oaes_get_seed( char buf[RANDSIZ + 1] )
|
static void oaes_get_seed( char buf[RANDSIZ + 1] )
|
||||||
{
|
{
|
||||||
#ifndef __FreeBSD__
|
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||||
struct timeb timer;
|
struct timeb timer;
|
||||||
struct tm *gmTimer;
|
struct tm *gmTimer;
|
||||||
char * _test = NULL;
|
char * _test = NULL;
|
||||||
|
@ -502,7 +502,7 @@ static void oaes_get_seed( char buf[RANDSIZ + 1] )
|
||||||
#else
|
#else
|
||||||
static uint32_t oaes_get_seed(void)
|
static uint32_t oaes_get_seed(void)
|
||||||
{
|
{
|
||||||
#ifndef __FreeBSD__
|
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||||
struct timeb timer;
|
struct timeb timer;
|
||||||
struct tm *gmTimer;
|
struct tm *gmTimer;
|
||||||
char * _test = NULL;
|
char * _test = NULL;
|
||||||
|
|
|
@ -421,7 +421,7 @@ void slow_hash_allocate_state(void)
|
||||||
hp_state = (uint8_t *) VirtualAlloc(hp_state, MEMORY, MEM_LARGE_PAGES |
|
hp_state = (uint8_t *) VirtualAlloc(hp_state, MEMORY, MEM_LARGE_PAGES |
|
||||||
MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
#else
|
#else
|
||||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
hp_state = mmap(0, MEMORY, PROT_READ | PROT_WRITE,
|
hp_state = mmap(0, MEMORY, PROT_READ | PROT_WRITE,
|
||||||
MAP_PRIVATE | MAP_ANON, 0, 0);
|
MAP_PRIVATE | MAP_ANON, 0, 0);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#include "hash-ops.h"
|
#include "hash-ops.h"
|
||||||
|
|
||||||
#ifndef __FreeBSD__
|
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
void set_process_affinity(int core)
|
void set_process_affinity(int core)
|
||||||
{
|
{
|
||||||
#if defined (__APPLE__) || defined(__FreeBSD__)
|
#if defined (__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
return;
|
return;
|
||||||
#elif defined(BOOST_WINDOWS)
|
#elif defined(BOOST_WINDOWS)
|
||||||
DWORD_PTR mask = 1;
|
DWORD_PTR mask = 1;
|
||||||
|
@ -62,7 +62,7 @@ void set_process_affinity(int core)
|
||||||
|
|
||||||
void set_thread_high_priority()
|
void set_thread_high_priority()
|
||||||
{
|
{
|
||||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
return;
|
return;
|
||||||
#elif defined(BOOST_WINDOWS)
|
#elif defined(BOOST_WINDOWS)
|
||||||
::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
// Both OS X and FreeBSD don't need malloc.h
|
// OS X, FreeBSD, and OpenBSD don't need malloc.h
|
||||||
#if !defined(__APPLE__) && !defined(__FreeBSD__)
|
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue