aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt15
-rw-r--r--README.md15
-rw-r--r--contrib/epee/include/console_handler.h7
-rw-r--r--external/db_drivers/liblmdb/mdb.c4
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.cpp4
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp10
-rw-r--r--src/common/int-util.h2
-rw-r--r--src/crypto/crypto.cpp2
-rw-r--r--src/crypto/oaes_lib.c12
-rw-r--r--src/crypto/slow-hash.c2
-rw-r--r--src/crypto/tree-hash.c2
-rw-r--r--src/wallet/wallet2.cpp2
-rw-r--r--tests/performance_tests/performance_utils.h4
-rw-r--r--tests/unit_tests/hardfork.cpp1
-rw-r--r--tests/unit_tests/slow_memmem.cpp4
15 files changed, 59 insertions, 27 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64b9f3e62..c032bbee0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -139,12 +139,15 @@ elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
set(FREEBSD TRUE)
endif()
-# TODO: check bsdi, NetBSD, OpenBSD, to see if they need the same FreeBSD changes
+# Check if we're on OpenBSD. See the README.md for build instructions.
+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.*")
# set(NETBSD TRUE)
-# elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
-# set(OPENBSD TRUE)
# elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
# set(BSDI TRUE)
@@ -379,7 +382,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))
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0) AND NOT OPENBSD)
set(CMAKE_AR "gcc-ar")
set(CMAKE_RANLIB "gcc-ranlib")
endif()
@@ -389,7 +392,7 @@ else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEBUG_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_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++")
endif()
endif()
@@ -421,7 +424,7 @@ endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi)
-elseif(APPLE OR FREEBSD)
+elseif(APPLE OR FREEBSD OR OPENBSD)
set(EXTRA_LIBRARIES "")
elseif(NOT MSVC)
find_library(RT rt)
diff --git a/README.md b/README.md
index ecd57e596..bd4b66878 100644
--- a/README.md
+++ b/README.md
@@ -162,6 +162,21 @@ The project can be built from scratch by following instructions for Unix and Lin
We expect to add Monero into the ports tree in the near future, which will aid in managing installations using ports or packages.
+### On OpenBSD:
+
+This has been tested on OpenBSD 5.8.
+
+You will need to add a few packages to your system. `pkg_add db cmake gcc gcc-libs g++ miniupnpc gtest`.
+
+The doxygen and graphviz packages are optional and require the xbase set.
+
+The Boost package has a bug that will prevent librpc.a from building correctly. In order to fix this, you will have to Build boost yourself from scratch. Follow the directions here (under "Building Boost"):
+https://github.com/bitcoin/bitcoin/blob/master/doc/build-openbsd.md
+
+You will have to add the serialization, date_time, and regex modules to Boost when building as they are needed by Monero.
+
+To build: `env CC=egcc CXX=eg++ CPP=ecpp DEVELOPER_LOCAL_TOOLS=1 BOOST_ROOT=/path/to/the/boost/you/built make release-static-64`
+
## Building Documentation
Monero developer documentation uses Doxygen, and is currently a work-in-progress.
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index 685f0cc7b..5c63556ae 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -33,6 +33,9 @@
#include <mutex>
#include <thread>
#include <iostream>
+#ifdef __OpenBSD__
+#include <stdio.h>
+#endif
namespace epee
{
@@ -129,7 +132,11 @@ namespace epee
bool wait_stdin_data()
{
#if !defined(WIN32)
+ #ifdef __OpenBSD__
+ int stdin_fileno = fileno(stdin);
+ #else
int stdin_fileno = ::fileno(stdin);
+ #endif
while (m_run.load(std::memory_order_relaxed))
{
diff --git a/external/db_drivers/liblmdb/mdb.c b/external/db_drivers/liblmdb/mdb.c
index ae32c9896..4c9e22388 100644
--- a/external/db_drivers/liblmdb/mdb.c
+++ b/external/db_drivers/liblmdb/mdb.c
@@ -35,7 +35,7 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
-#ifdef MDB_VL32
+#if defined(MDB_VL32) || defined(__WIN64__)
#define _FILE_OFFSET_BITS 64
#endif
#ifdef _WIN32
@@ -2429,7 +2429,7 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp)
goto fail;
}
#ifdef _WIN32
- if (env->me_flags & MDB_WRITEMAP) {
+ if (!(env->me_flags & MDB_RDONLY)) {
void *p;
p = (MDB_page *)(env->me_map + env->me_psize * pgno);
p = VirtualAlloc(p, env->me_psize * num, MEM_COMMIT,
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp
index 1ccb6be12..02fdaba2f 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.cpp
+++ b/src/blockchain_db/berkeleydb/db_bdb.cpp
@@ -783,9 +783,11 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags)
m_env->set_lk_max_locks(DB_MAX_LOCKS);
m_env->set_lk_max_lockers(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)
m_env->log_set_config(DB_LOG_AUTO_REMOVE, 1);
+ #endif
// last parameter left 0, files will be created with default rw access
m_env->open(filename.c_str(), db_env_open_flags, 0);
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 17a0f9ec2..c18db7724 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -654,9 +654,11 @@ void BlockchainLMDB::remove_transaction_data(const crypto::hash& tx_hash, const
remove_tx_outputs(tx_hash, tx);
- if (mdb_del(*m_write_txn, m_tx_outputs, &val_h, NULL))
- throw1(DB_ERROR("Failed to add removal of tx outputs to db transaction"));
-
+ auto result = mdb_del(*m_write_txn, m_tx_outputs, &val_h, NULL);
+ if (result == MDB_NOTFOUND)
+ LOG_PRINT_L1("tx has no outputs to remove: " << tx_hash);
+ else if (result)
+ throw1(DB_ERROR(std::string("Failed to add removal of tx outputs to db transaction: ").append(mdb_strerror(result)).c_str()));
}
void BlockchainLMDB::add_output(const crypto::hash& tx_hash, const tx_out& tx_output, const uint64_t& local_index, const uint64_t unlock_time)
@@ -718,7 +720,7 @@ void BlockchainLMDB::remove_tx_outputs(const crypto::hash& tx_hash, const transa
auto result = mdb_cursor_get(cur, &k, &v, MDB_SET);
if (result == MDB_NOTFOUND)
{
- LOG_ERROR("Attempting to remove a tx's outputs, but none found. Continuing, but...be wary, because that's weird.");
+ LOG_PRINT_L2("tx has no outputs, so no global output indices");
}
else if (result)
{
diff --git a/src/common/int-util.h b/src/common/int-util.h
index 45ee5ef70..e9eddee9c 100644
--- a/src/common/int-util.h
+++ b/src/common/int-util.h
@@ -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 uint64_t ident64(uint64_t x) { return x; }
+#ifndef __OpenBSD__
static inline uint32_t swap32(uint32_t x) {
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
return (x << 16) | (x >> 16);
@@ -146,6 +147,7 @@ static inline uint64_t swap64(uint64_t x) {
x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
return (x << 32) | (x >> 32);
}
+#endif
#if defined(__GNUC__)
#define UNUSED __attribute__((unused))
diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp
index 1e39a8b04..fa7b1b580 100644
--- a/src/crypto/crypto.cpp
+++ b/src/crypto/crypto.cpp
@@ -41,7 +41,7 @@
#include "crypto.h"
#include "hash.h"
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <alloca.h>
#else
#include <stdlib.h>
diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c
index c86b8caa0..7fbe96e4c 100644
--- a/src/crypto/oaes_lib.c
+++ b/src/crypto/oaes_lib.c
@@ -37,13 +37,13 @@ static const char _NR[] = {
#include <stdlib.h>
#include <stdio.h>
-// Both OS X and FreeBSD don't need malloc.h
-#if !defined(__APPLE__) && !defined(__FreeBSD__)
+// OS X, FreeBSD, and OpenBSD don't need malloc.h
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <malloc.h>
#endif
-// FreeBSD also doesn't need timeb.h
-#ifndef __FreeBSD__
+// FreeBSD, and OpenBSD also don't need timeb.h
+#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <sys/timeb.h>
#else
#include <sys/time.h>
@@ -470,7 +470,7 @@ OAES_RET oaes_sprintf(
#ifdef OAES_HAVE_ISAAC
static void oaes_get_seed( char buf[RANDSIZ + 1] )
{
- #ifndef __FreeBSD__
+ #if !defined(__FreeBSD__) && !defined(__OpenBSD__)
struct timeb timer;
struct tm *gmTimer;
char * _test = NULL;
@@ -502,7 +502,7 @@ static void oaes_get_seed( char buf[RANDSIZ + 1] )
#else
static uint32_t oaes_get_seed(void)
{
- #ifndef __FreeBSD__
+ #if !defined(__FreeBSD__) && !defined(__OpenBSD__)
struct timeb timer;
struct tm *gmTimer;
char * _test = NULL;
diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c
index 544083fb0..903a3792f 100644
--- a/src/crypto/slow-hash.c
+++ b/src/crypto/slow-hash.c
@@ -421,7 +421,7 @@ 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__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
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 e90b23841..7a128e4b0 100644
--- a/src/crypto/tree-hash.c
+++ b/src/crypto/tree-hash.c
@@ -34,7 +34,7 @@
#include "hash-ops.h"
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <alloca.h>
#else
#include <stdlib.h>
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 3edbaeca2..55e290c0c 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -1429,7 +1429,7 @@ void wallet2::rescan_spent()
{
LOG_PRINT_L0("Marking output " << i << "(" << td.m_key_image << ") as spent, it was marked as unspent");
}
- td.m_spent = daemon_resp.spent_status[i];
+ td.m_spent = daemon_resp.spent_status[i] != COMMAND_RPC_IS_KEY_IMAGE_SPENT::UNSPENT;
}
}
}
diff --git a/tests/performance_tests/performance_utils.h b/tests/performance_tests/performance_utils.h
index fc9f8612d..ba2b71740 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__)
+#if defined (__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
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__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
return;
#elif defined(BOOST_WINDOWS)
::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp
index 56ec155f0..d469dadec 100644
--- a/tests/unit_tests/hardfork.cpp
+++ b/tests/unit_tests/hardfork.cpp
@@ -128,6 +128,7 @@ public:
virtual uint8_t get_hard_fork_version(uint64_t height) const {
return versions[height];
}
+ virtual void check_hard_fork_info() {}
private:
std::vector<block> blocks;
diff --git a/tests/unit_tests/slow_memmem.cpp b/tests/unit_tests/slow_memmem.cpp
index 8da58eaf4..a14e01885 100644
--- a/tests/unit_tests/slow_memmem.cpp
+++ b/tests/unit_tests/slow_memmem.cpp
@@ -35,8 +35,8 @@
#include <stdint.h>
#include "gtest/gtest.h"
-// Both OS X and FreeBSD don't need malloc.h
-#if !defined(__APPLE__) && !defined(__FreeBSD__)
+// OS X, FreeBSD, and OpenBSD don't need malloc.h
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <malloc.h>
#endif