From 67df296650a72b8769fac58787148080ec771805 Mon Sep 17 00:00:00 2001 From: mydesktop Date: Wed, 30 Apr 2014 13:52:21 -0400 Subject: [PATCH] various fixes to allow mac osx compilation --- .gitignore | 1 + CMakeLists.txt | 14 ++++++++++++-- .../keyvalue_serialization_overloads.h | 4 ++-- contrib/epee/include/storages/portable_storage.h | 2 +- src/crypto/oaes_lib.c | 1 + src/cryptonote_core/cryptonote_format_utils.h | 2 +- src/p2p/net_node.inl | 4 +++- src/p2p/p2p_protocol_defs.h | 4 ++-- src/rpc/core_rpc_server.cpp | 2 +- src/simplewallet/simplewallet.cpp | 2 +- tests/gtest/include/gtest/internal/gtest-port.h | 2 ++ tests/net_load_tests/net_load_tests.h | 14 +++++++------- tests/performance_tests/performance_utils.h | 8 ++++++-- 13 files changed, 40 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 2a68f647b..554267b09 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.DS_Store /build /tags \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b293cc78..8510b3690 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,22 @@ cmake_minimum_required(VERSION 2.8.6) set(VERSION "0.1") # $Format:Packaged from commit %H%nset(COMMIT %h)%nset(REFS "%d")$ +function(set_static_flags) +if (NOT APPLE) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") +endif() +endfunction(set_static_flags) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_CONFIGURATION_TYPES "Debug;Release") enable_testing() include_directories(src contrib/epee/include external "${CMAKE_BINARY_DIR}/version") +if(APPLE) +include_directories(SYSTEM /usr/include/malloc) +endif() + set(STATIC ${MSVC} CACHE BOOL "Link libraries statically") if(MSVC) @@ -65,7 +75,7 @@ else() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${RELEASE_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${RELEASE_FLAGS}") if(STATIC) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") + set_static_flags() endif() endif() @@ -81,7 +91,7 @@ include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) if(MINGW) set(Boost_LIBRARIES "${Boost_LIBRARIES};ws2_32;mswsock") elseif(NOT MSVC) - set(Boost_LIBRARIES "${Boost_LIBRARIES};rt") + set(Boost_LIBRARIES "${Boost_LIBRARIES}") endif() set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version") diff --git a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h index 54535a404..33486d9ec 100644 --- a/contrib/epee/include/serialization/keyvalue_serialization_overloads.h +++ b/contrib/epee/include/serialization/keyvalue_serialization_overloads.h @@ -281,7 +281,7 @@ namespace epee } }; template - struct base_serializable_types: public boost::mpl::vector::type + struct base_serializable_types: public boost::mpl::vector::type {}; //------------------------------------------------------------------------------------------------------------------- template struct selector; @@ -365,4 +365,4 @@ namespace epee return kv_serialization_overloads_impl_is_base_serializable_types, typename std::remove_const::type>::value>::kv_unserialize(d, stg, hparent_section, pname); } } -} \ No newline at end of file +} diff --git a/contrib/epee/include/storages/portable_storage.h b/contrib/epee/include/storages/portable_storage.h index c244dac19..21904da9e 100644 --- a/contrib/epee/include/storages/portable_storage.h +++ b/contrib/epee/include/storages/portable_storage.h @@ -210,7 +210,7 @@ namespace epee template bool portable_storage::get_value(const std::string& value_name, t_value& val, hsection hparent_section) { - BOOST_MPL_ASSERT(( boost::mpl::contains )); + //BOOST_MPL_ASSERT(( boost::mpl::contains )); //TRY_ENTRY(); if(!hparent_section) hparent_section = &m_root; storage_entry* pentry = find_storage_entry(value_name, hparent_section); diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index d77c52f11..126f0a2f6 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -37,6 +37,7 @@ static const char _NR[] = { #include #include #include +#include #ifdef WIN32 #include diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index 554e466cc..5873d2943 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -25,7 +25,7 @@ namespace cryptonote typedef std::pair output_entry; std::vector outputs; //index + key - uint64_t real_output; //index in outputs vector of real output_entry + size_t real_output; //index in outputs vector of real output_entry crypto::public_key real_out_tx_key; //incoming real tx public key size_t real_output_in_tx_index; //index in transaction outputs vector uint64_t amount; //money diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index eeb3f6ffe..4dafa2342 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -745,7 +745,9 @@ namespace nodetool template bool node_server::get_local_node_data(basic_node_data& node_data) { - time(&node_data.local_time); + time_t local_time; + time(&local_time); + node_data.local_time = local_time; node_data.peer_id = m_config.m_peer_id; if(!m_hide_my_port) node_data.my_port = m_external_port ? m_external_port : m_listenning_port; diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h index 9994dca4c..fdf784f49 100644 --- a/src/p2p/p2p_protocol_defs.h +++ b/src/p2p/p2p_protocol_defs.h @@ -86,7 +86,7 @@ namespace nodetool struct basic_node_data { uuid network_id; - time_t local_time; + uint64_t local_time; uint32_t my_port; peerid_type peer_id; @@ -153,7 +153,7 @@ namespace nodetool struct response { - time_t local_time; + uint64_t local_time; t_playload_type payload_data; std::list local_peerlist; diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index bab373c86..311d2a145 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -536,7 +536,7 @@ namespace cryptonote if (!have_block) { error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR; - error_resp.message = "Internal error: can't get block by height. Height = " + req.height + '.'; + error_resp.message = "Internal error: can't get block by height. Height = " + std::to_string(req.height) + '.'; return false; } bool responce_filled = fill_block_header_responce(blk, false, req.height, block_hash, res.block_header); diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index a4cae0480..a9c171f6b 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -469,7 +469,7 @@ bool simple_wallet::refresh(const std::vector& args) return true; message_writer() << "Starting refresh..."; - uint64_t fetched_blocks = 0; + size_t fetched_blocks = 0; bool ok = false; std::ostringstream ss; try diff --git a/tests/gtest/include/gtest/internal/gtest-port.h b/tests/gtest/include/gtest/internal/gtest-port.h index 157b47f86..fbf28cd4e 100644 --- a/tests/gtest/include/gtest/internal/gtest-port.h +++ b/tests/gtest/include/gtest/internal/gtest-port.h @@ -204,6 +204,8 @@ #define GTEST_NAME_ "Google Test" #define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/" +#define GTEST_HAS_TR1_TUPLE 0 + // Determines the version of gcc that is used to compile this. #ifdef __GNUC__ // 40302 means version 4.3.2. diff --git a/tests/net_load_tests/net_load_tests.h b/tests/net_load_tests/net_load_tests.h index 20da11bf3..3d9569835 100644 --- a/tests/net_load_tests/net_load_tests.h +++ b/tests/net_load_tests/net_load_tests.h @@ -212,8 +212,8 @@ namespace net_load_tests struct request { - size_t open_request_target; - size_t max_opened_conn_count; + uint64_t open_request_target; + uint64_t max_opened_conn_count; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(open_request_target) @@ -240,9 +240,9 @@ namespace net_load_tests struct response { - size_t opened_connections_count; - size_t new_connection_counter; - size_t close_connection_counter; + uint64_t opened_connections_count; + uint64_t new_connection_counter; + uint64_t close_connection_counter; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(opened_connections_count) @@ -295,7 +295,7 @@ namespace net_load_tests struct request { - size_t request_size; + uint64_t request_size; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(request_size) @@ -310,7 +310,7 @@ namespace net_load_tests struct request { std::string data; - size_t response_size; + uint64_t response_size; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(data) diff --git a/tests/performance_tests/performance_utils.h b/tests/performance_tests/performance_utils.h index b2ac4076f..45ca5b27b 100644 --- a/tests/performance_tests/performance_utils.h +++ b/tests/performance_tests/performance_utils.h @@ -14,7 +14,9 @@ void set_process_affinity(int core) { -#if defined(BOOST_WINDOWS) +#if defined (__APPLE__) + return; +#elif defined(BOOST_WINDOWS) DWORD_PTR mask = 1; for (int i = 0; i < core; ++i) { @@ -34,7 +36,9 @@ void set_process_affinity(int core) void set_thread_high_priority() { -#if defined(BOOST_WINDOWS) +#if defined(__APPLE__) + return; +#elif defined(BOOST_WINDOWS) ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); #elif defined(BOOST_HAS_PTHREADS) pthread_attr_t attr;