From 56a800c7de10c3e3a1a854434e6bfdeb01696dba Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Mon, 25 Apr 2016 14:52:17 +0200 Subject: [PATCH] Use our own minimal signal implementation --- CMakeLists.txt | 2 - include/simgrid_config.h.in | 2 - include/xbt/signal.hpp | 46 +++++++--------- src/mc/Process.cpp | 1 - tools/cmake/DefinePackages.cmake | 1 - tools/cmake/MakeLib.cmake | 5 -- tools/cmake/Modules/FindLibSigc++.cmake | 71 ------------------------- 7 files changed, 18 insertions(+), 110 deletions(-) delete mode 100644 tools/cmake/Modules/FindLibSigc++.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 00ebaf2ef0..fa02471cee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,7 +211,6 @@ include(CheckSymbolExists) set(HAVE_GRAPHVIZ 0) include(FindGraphviz) -include(FindLibSigc++) set(HAVE_LUA 0) if(enable_lua) @@ -975,7 +974,6 @@ message(" Documentation................: ${enable_documentation}") message(" Model checking ..............: ${HAVE_MC}") message(" Jedule mode ................: ${HAVE_JEDULE}") message(" Graphviz mode ...............: ${HAVE_GRAPHVIZ}") -message(" Sigc++ mode .................: ${SIMGRID_HAVE_LIBSIG}") message(" Mallocators .................: ${enable_mallocators}") message("") message(" Simgrid dependencies ........: ${SIMGRID_DEP}") diff --git a/include/simgrid_config.h.in b/include/simgrid_config.h.in index 1ff20fa033..d6808fc22b 100644 --- a/include/simgrid_config.h.in +++ b/include/simgrid_config.h.in @@ -24,6 +24,4 @@ #define HAVE_MC @HAVE_MC@ /* Was the model-checking compiled in? */ #define HAVE_NS3 @HAVE_NS3@ /* Was the NS3 support compiled in? */ -#define SIMGRID_HAVE_LIBSIG @SIMGRID_HAVE_LIBSIG@ /* Used in the public interface xbt/signal.hpp :( */ - #endif /* SIMGRID_PUBLIC_CONFIG_H */ diff --git a/include/xbt/signal.hpp b/include/xbt/signal.hpp index 26bd2df57f..08fbff611a 100644 --- a/include/xbt/signal.hpp +++ b/include/xbt/signal.hpp @@ -6,53 +6,43 @@ #ifndef SIMGRID_XBT_SIGNAL_HPP #define SIMGRID_XBT_SIGNAL_HPP -#include "simgrid_config.h" -#if SIMGRID_HAVE_LIBSIG -#include -#else -#include -#endif +#include +#include namespace simgrid { namespace xbt { -#if SIMGRID_HAVE_LIBSIG + template class signal; - // Wraps sigc++ signals with the interface of boost::signals2: - template class signal; + /** A signal/slot mechanism + * + * S is expected to be the function signature of the signal. + * I'm not sure we need a return value (it is currently ignored). + * If we don't we might use `signal` instead. + */ template class signal { private: - sigc::signal sig_; + typedef std::function callback_type; + std::vector handlers_; public: template XBT_ALWAYS_INLINE - void connect(U&& slot) - { - sig_.connect(std::forward(slot)); - } - template XBT_ALWAYS_INLINE - void connect(Res(*slot)(Args...)) + void connect(U slot) { - sig_.connect(sigc::ptr_fun(slot)); + handlers_.push_back(std::move(slot)); } - template XBT_ALWAYS_INLINE - R operator()(Args&&... args) const + XBT_ALWAYS_INLINE + R operator()(P... args) const { - return sig_.emit(std::forward(args)...); + for (auto& handler : handlers_) + handler(args...); } void disconnect_all_slots() { - sig_.clear(); + handlers_.clear(); } }; -#else - - template - using signal = ::boost::signals2::signal; - -#endif - } } diff --git a/src/mc/Process.cpp b/src/mc/Process.cpp index de390cd39c..597710f838 100644 --- a/src/mc/Process.cpp +++ b/src/mc/Process.cpp @@ -77,7 +77,6 @@ static const char *const filtered_libraries[] = { "libm", "libpthread", "librt", - "libsigc", "libstdc++", "libunwind", "libunwind-x86_64", diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index c9aa053e14..683a623f27 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -986,7 +986,6 @@ set(CMAKE_SOURCE_FILES tools/cmake/MakeLibWin.cmake tools/cmake/Modules/FindGFortran.cmake tools/cmake/Modules/FindGraphviz.cmake - tools/cmake/Modules/FindLibSigc++.cmake tools/cmake/Modules/FindLibdw.cmake tools/cmake/Modules/FindLibunwind.cmake tools/cmake/Modules/FindLuaSimgrid.cmake diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake index 4115a97a2d..6b825b2a37 100644 --- a/tools/cmake/MakeLib.cmake +++ b/tools/cmake/MakeLib.cmake @@ -66,11 +66,6 @@ if(HAVE_GRAPHVIZ) endif() endif() -if(SIMGRID_HAVE_LIBSIG) - SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0") - add_definitions(-DLIBSIGC) -endif() - if(HAVE_MC) # The availability of libunwind was checked in CompleteInFiles.cmake # (that includes FindLibunwind.cmake), so simply load it now. diff --git a/tools/cmake/Modules/FindLibSigc++.cmake b/tools/cmake/Modules/FindLibSigc++.cmake deleted file mode 100644 index 55de343163..0000000000 --- a/tools/cmake/Modules/FindLibSigc++.cmake +++ /dev/null @@ -1,71 +0,0 @@ -find_path(PATH_LIBSIGC++_H "sigc++/sigc++.h" - HINTS - $ENV{LD_LIBRARY_PATH} - PATH_SUFFIXES include/sigc++-2.0/ include/ - PATHS - /opt - /opt/local - /opt/csw - /sw - /usr) - -find_path(PATH_LIBSIGC++CONFIG_H "sigc++config.h" - HINTS - $ENV{LD_LIBRARY_PATH} - PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE}/sigc++-2.0/include/ include/ - PATHS - /opt - /opt/local - /opt/csw - /sw - /usr) - -find_library(PATH_LIBSIGC++_LIB - NAMES sigc-2.0 - HINTS - $ENV{LD_LIBRARY_PATH} - PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE}/ lib/sigc++/ lib/ - PATHS - /opt - /opt/local - /opt/csw - /sw - /usr) - -message(STATUS "Looking for sigc++/sigc++.h") -if(PATH_LIBSIGC++_H) - message(STATUS "Looking for sigc++/sigc++.h - found") -else() - message(STATUS "Looking for sigc++/sigc++.h - not found") -endif() - -message(STATUS "Looking for sigc++config.h") -if(PATH_LIBSIGC++CONFIG_H) - message(STATUS "Looking for sigc++config.h - found") -else() - message(STATUS "Looking for sigc++config.h - not found") -endif() - -message(STATUS "Looking for libsigc++") -if(PATH_LIBSIGC++_LIB) - message(STATUS "Looking for libsigc++ - found") -else() - message(STATUS "Looking for libsigc++ - not found") -endif() - -if(PATH_LIBSIGC++_LIB AND PATH_LIBSIGC++_H AND PATH_LIBSIGC++CONFIG_H) - string(REGEX REPLACE "/sigc\\+\\+/sigc\\+\\+.h" "" PATH_LIBSIGC++_H "${PATH_LIBSIGC++_H}") - string(REGEX REPLACE "/sigc\\+\\+config.h" "" PATH_LIBSIGC++CONFIG_H "${PATH_LIBSIGC++CONFIG_H}") - string(REGEX REPLACE "/libsig.*" "" PATH_LIBSIGC++_LIB "${PATH_LIBSIGC++_LIB}") - - include_directories(${PATH_LIBSIGC++_H}) - include_directories(${PATH_LIBSIGC++CONFIG_H}) - link_directories(${PATH_LIBSIGC++_LIB}) - set(SIMGRID_HAVE_LIBSIG "1") -else() - set(SIMGRID_HAVE_LIBSIG "0") -endif() - -mark_as_advanced(PATH_LIBSIGC++_H) -mark_as_advanced(PATH_LIBSIGC++CONFIG_H) -mark_as_advanced(PATH_LIBSIGC++_LIB) -- 2.20.1