Skip to content

Commit

Permalink
support openbsd // make code buildable
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto-ape committed Aug 16, 2019
1 parent 96e3177 commit 9d0c0c7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,19 @@ else( WIN32 ) # Apple AND Linux
message( STATUS "Configuring BitShares on OS X" )
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++ -Wall" )
else( APPLE )
# Linux Specific Options Here
message( STATUS "Configuring BitShares on Linux" )
if ( "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD" )
# OpenBSD Specific Options
message( STATUS "Configuring BitShares on OpenBSD" )
else()
# Linux Specific Options Here
message( STATUS "Configuring BitShares on Linux" )
set( rt_library rt )
endif()
# Common Linux & OpenBSD Options
set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall" )
if(USE_PROFILER)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" )
endif( USE_PROFILER )
set( rt_library rt )
set( pthread_library pthread)
if ( NOT DEFINED crypto_library )
# I'm not sure why this is here, I guess someone has openssl and can't detect it with find_package()?
Expand Down
13 changes: 13 additions & 0 deletions libraries/app/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@ using boost::multiprecision::uint256_t;

static fc::uint128_t to_capped_128( const uint256_t& t )
{
#if defined(__OpenBSD__)
const fc::uint128_t max = std::numeric_limits<fc::uint128_t>::max();
boost::multiprecision::uint128_t helper;
helper += fc::uint128_hi64(max) << 64;
helper += fc::uint128_lo64(max);
if (t >= helper)
return max;
helper = static_cast<boost::multiprecision::uint128_t>(t);
fc::uint128_t capped = static_cast<uint64_t>(helper >> 64);
capped += static_cast<uint64_t>(helper && std::numeric_limits<uint64_t>::max());
return capped;
#else
if( t >= std::numeric_limits<fc::uint128_t>::max() )
return std::numeric_limits<fc::uint128_t>::max();
return static_cast<fc::uint128_t>(t);
#endif
}

std::string uint128_amount_to_string( const fc::uint128_t& amount, const uint8_t precision )
Expand Down
2 changes: 2 additions & 0 deletions libraries/net/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,8 @@ namespace graphene { namespace net { namespace detail {
user_data["fc_git_revision_unix_timestamp"] = fc::git_revision_unix_timestamp;
#if defined( __APPLE__ )
user_data["platform"] = "osx";
#elif defined( __OpenBSD__ )
user_data["platform"] = "obsd";
#elif defined( __linux__ )
user_data["platform"] = "linux";
#elif defined( _MSC_VER )
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@
#include <winsock2.h>
#include <WS2tcpip.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <sys/types.h>
#endif
#include <thread>

Expand Down
17 changes: 8 additions & 9 deletions tests/performance/performance_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <boost/test/unit_test.hpp>

#include <boost/test/included/unit_test.hpp>

boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
return nullptr;
}

#include <graphene/chain/database.hpp>

Expand Down Expand Up @@ -208,11 +215,3 @@ BOOST_AUTO_TEST_CASE( one_hundred_k_benchmark )
} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_SUITE_END()

#include <boost/test/included/unit_test.hpp>

boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
std::srand(time(NULL));
std::cout << "Random number generator seeded to " << time(NULL) << std::endl;
return nullptr;
}

0 comments on commit 9d0c0c7

Please sign in to comment.