Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 727b - A second option #33

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
PROJECT( fc )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )

add_compile_options(-std=c++14)

MESSAGE(STATUS "Configuring project fc located in: ${CMAKE_CURRENT_SOURCE_DIR}")
SET( CMAKE_AUTOMOC OFF )

Expand Down Expand Up @@ -106,15 +104,15 @@ endif ( MSVC )

# Configure editline
if ( MSVC )
# autoconf won't work here, hard code the defines
set( EDITLINE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline" )

file( GLOB EDITLINE_SOURCES "${EDITLINE_DIR}/src/editline.c" )
add_library( editline ${EDITLINE_SOURCES} )

target_include_directories( editline PRIVATE "${EDITLINE_DIR}" PUBLIC "${EDITLINE_DIR}/include" )

set_target_properties( editline PROPERTIES COMPILE_DEFINITIONS LINKER_LANGUAGE C )
# # autoconf won't work here, hard code the defines
# set( EDITLINE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vendor/editline" )
#
# file( GLOB EDITLINE_SOURCES "${EDITLINE_DIR}/src/editline.c" )
# add_library( editline ${EDITLINE_SOURCES} )
#
# target_include_directories( editline PRIVATE "${EDITLINE_DIR}" PUBLIC "${EDITLINE_DIR}/include" )
#
# set_target_properties( editline PROPERTIES COMPILE_DEFINITIONS LINKER_LANGUAGE C )
else ( MSVC )
include(ExternalProject)
if ( MINGW )
Expand Down Expand Up @@ -234,7 +232,6 @@ set( fc_sources
src/io/varint.cpp
src/io/console.cpp
src/filesystem.cpp
src/interprocess/process.cpp
src/interprocess/signals.cpp
src/interprocess/file_mapping.cpp
src/interprocess/mmap_struct.cpp
Expand Down Expand Up @@ -284,6 +281,7 @@ set( fc_sources
src/network/url.cpp
src/compress/smaz.cpp
src/compress/zlib.cpp
src/stacktrace.cpp
)

file( GLOB_RECURSE fc_headers ${CMAKE_CURRENT_SOURCE_DIR} *.hpp *.h )
Expand All @@ -302,8 +300,10 @@ setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC )
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include )

# begin editline stuff
target_compile_definitions (fc PRIVATE HAVE_EDITLINE)
set(editline_libraries editline)
if(NOT MSVC)
target_compile_definitions (fc PRIVATE HAVE_EDITLINE)
set(editline_libraries editline)
endif(NOT MSVC)
if(WIN32)
target_compile_definitions( fc PRIVATE _CRT_NONSTDC_NO_DEPRECATE )
endif(WIN32)
Expand Down Expand Up @@ -403,7 +403,6 @@ target_include_directories(fc
${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp

PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost_1.51/include
${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp
)

Expand Down
4 changes: 3 additions & 1 deletion include/fc/crypto/sha256.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <fc/string.hpp>
#include <fc/platform_independence.hpp>
#include <fc/io/raw_fwd.hpp>
#include <boost/functional/hash.hpp>

namespace fc
{
Expand Down Expand Up @@ -140,9 +141,10 @@ namespace boost
{
size_t operator()( const fc::sha256& s )const
{
return s._hash[3];//*((size_t*)&s);
return s._hash[3];// *((size_t*)&s);
}
};
}

#include <fc/reflect/reflect.hpp>
FC_REFLECT_TYPENAME( fc::sha256 )
16 changes: 16 additions & 0 deletions include/fc/stacktrace.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// stacktrace.h (c) 2008, Timo Bingmann from http://idlebox.net/
// published under the WTFPL v2.0

// Downloaded from http://panthema.net/2008/0901-stacktrace-demangled/
// and modified for C++ and FC by Steemit, Inc.

#pragma once

#include <iostream>

namespace fc {

void print_stacktrace(std::ostream& out);
void print_stacktrace_on_segfault();

}
190 changes: 0 additions & 190 deletions src/interprocess/process.cpp

This file was deleted.

1 change: 1 addition & 0 deletions src/log/file_appender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <iomanip>
#include <queue>
#include <sstream>
#include <iostream>

namespace fc {

Expand Down
8 changes: 4 additions & 4 deletions src/network/tcp_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace fc {
#elif !defined(__clang__) || (__clang_major__ >= 6)
// This should work for modern Linuxes and for OSX >= Mountain Lion
int timeout_sec = interval.count() / fc::seconds(1).count();
if (setsockopt(my->_sock.native(), IPPROTO_TCP,
if (setsockopt(my->_sock.native_handle(), IPPROTO_TCP,
#if defined( __APPLE__ )
TCP_KEEPALIVE,
#else
Expand All @@ -192,7 +192,7 @@ namespace fc {
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
wlog("Error setting TCP keepalive idle time");
# if !defined(__APPLE__) || defined(TCP_KEEPINTVL) // TCP_KEEPINTVL not defined before 10.9
if (setsockopt(my->_sock.native(), IPPROTO_TCP, TCP_KEEPINTVL,
if (setsockopt(my->_sock.native_handle(), IPPROTO_TCP, TCP_KEEPINTVL,
(char*)&timeout_sec, sizeof(timeout_sec)) < 0)
wlog("Error setting TCP keepalive interval");
# endif // !__APPLE__ || TCP_KEEPINTVL
Expand Down Expand Up @@ -224,7 +224,7 @@ namespace fc {
if (detail::have_so_reuseport)
{
int reuseport_value = 1;
if (setsockopt(my->_sock.native(), SOL_SOCKET, SO_REUSEPORT,
if (setsockopt(my->_sock.native_handle(), SOL_SOCKET, SO_REUSEPORT,
(char*)&reuseport_value, sizeof(reuseport_value)) < 0)
{
if (errno == ENOPROTOOPT)
Expand Down Expand Up @@ -291,7 +291,7 @@ namespace fc {
if (detail::have_so_reuseport)
{
int reuseport_value = 1;
if (setsockopt(my->_accept.native(), SOL_SOCKET, SO_REUSEPORT,
if (setsockopt(my->_accept.native_handle(), SOL_SOCKET, SO_REUSEPORT,
(char*)&reuseport_value, sizeof(reuseport_value)) < 0)
{
if (errno == ENOPROTOOPT)
Expand Down
31 changes: 31 additions & 0 deletions src/stacktrace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// A stacktrace handler for bitshares
//

#include <signal.h>
#include <fc/log/logger.hpp>
#include <boost/stacktrace.hpp>

namespace fc
{

static void segfault_signal_handler(int signum)
{
::signal(signum, SIG_DFL);
std::stringstream ss;
ss << boost::stacktrace::stacktrace();
elog(ss.str());
::raise(SIGABRT);
}

void print_stacktrace_on_segfault()
{
::signal(SIGSEGV, &segfault_signal_handler);
}

void print_stacktrace(std::ostream& out)
{
out << boost::stacktrace::stacktrace();
}

}
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ add_executable( all_tests all_tests.cpp
bloom_test.cpp
real128_test.cpp
serialization_test.cpp
stacktrace_test.cpp
time_test.cpp
utf8_test.cpp
variant_test.cpp
Expand Down
Loading