diff --git a/.gitignore b/.gitignore index aa473714..36e19522 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ xcuserdata gh-pages/ documentation/doxyfile.bak -build_asl/ + +# CLion +cmake-build-*/ diff --git a/CMakeLists.txt b/CMakeLists.txt index ee22d0f5..c8964775 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ -cmake_minimum_required(VERSION 3.0) -include(FindGit) -include(CMakeParseArguments) +cmake_minimum_required(VERSION 3.17) +include(FetchContent) enable_testing() project(adobe_source_libraries CXX) @@ -10,89 +9,22 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14") set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") -add_definitions ("-Wall") -#add_definitions ("-Werror") - # There are two big choices this file makes - how to include Boost, and how to # include double-conversion, respectively. Build environments vary and we're # trying to support all of them. -# -# If USE_SYSTEM_BOOST is defined, that means the headers and libraries have been built -# and are ready for use by CMake. Otherwise, we'll have to roll them ourselves. -# -# For double-conversion, the unix makefile setup is able to download the git -# repo and build it - -option(USE_SYSTEM_BOOST "use cmake found boost instead of ../boost_libraries" OFF) -option(USE_STLAB_DOUBLECONV "use stlab mirror of double-conversion repository" OFF) - -# with boost 1.60 boost.thread uses boost.move unique_ptr -# which is broken with BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE flag... -# fix is to conditionally remove this last boost thread dependency -# NB: Seems fixed for boost 1.65.1 -# NB: AppleClang lacks thread_local -option(USE_STD_THREAD_LOCAL "use C++11 thread_local instead of Boost" OFF) -if (USE_STD_THREAD_LOCAL AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") - message (WARNING "C++11 thread_local is not supported by AppleClang") -endif() - - -set(root_path ${CMAKE_SOURCE_DIR}/..) -function(setup_dep) - set(options IS_CMAKE) - set(oneValueArgs URL BRANCH TAG NAME) - set(multiValueArgs SUBMODULES) - cmake_parse_arguments(setup_dep "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if ("${setup_dep_NAME}" STREQUAL "") - get_filename_component(name ${setup_dep_URL} NAME_WE) - else() - set(name ${setup_dep_NAME}) - endif() +# by default we will fetch boost from github (see fetchcontent_declare call for boost below) +# If you want to use a custom boost (e.g. ../boost_libraries), define FETCHCONTENT_SOURCE_DIR_BOOST +# you can also "fetchcontent_declare" your own boost before including adobe_source_libraries in your super CMakeList.txt +option(USE_SYSTEM_BOOST OFF) - set(dep_path ${root_path}/${name}) - - if(NOT IS_DIRECTORY ${dep_path}) - message("ASL_INFO: Setting up dep " ${name} " into " ${dep_path}) - execute_process(COMMAND ${GIT_EXECUTABLE} clone ${setup_dep_URL} ${name} WORKING_DIRECTORY ${root_path}) - - if("${setup_dep_BRANCH}" STREQUAL "") - message(FATAL_ERROR "ASL_INFO: No branch given for dep " ${name}) - endif() - - execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${setup_dep_BRANCH} WORKING_DIRECTORY ${dep_path}) - - foreach(submodule ${setup_dep_SUBMODULES}) - message("ASL_INFO: Setting up submodule " ${submodule} " for " ${name}) - execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init ${submodule} WORKING_DIRECTORY ${dep_path}) - endforeach(submodule) - else() - message("ASL_INFO: Found dep " ${name} " into " ${dep_path}) - endif() - - if (setup_dep_IS_CMAKE) - add_subdirectory(${dep_path} ${CMAKE_BINARY_DIR}/imported/${name}) - endif() - -endfunction() - -if (USE_STLAB_DOUBLECONV) - setup_dep(URL https://github.com/stlab/double-conversion.git BRANCH master IS_CMAKE) - target_include_directories(double-conversion PUBLIC $) -else() - setup_dep(URL https://github.com/google/double-conversion.git BRANCH master IS_CMAKE) - target_include_directories(double-conversion PUBLIC $) - # poorly named flag to fix include path - target_compile_definitions(double-conversion PUBLIC ADOBE_BUILT_WITH_CMAKE) -endif() +# cf boost comment above on how to use a custom double-conversion +fetchcontent_declare(double-conversion GIT_REPOSITORY https://github.com/google/double-conversion.git GIT_TAG master GIT_SHALLOW) +fetchcontent_makeavailable(double-conversion) function(target_link_boost target) if (USE_SYSTEM_BOOST) - target_link_libraries(${target} PUBLIC ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}) - if(NOT USE_STD_THREAD_LOCAL) - target_link_libraries(${target} PUBLIC ${Boost_THREAD_LIBRARY}) - endif() + target_link_libraries(${target} PUBLIC Boost::system Boost::filesystem) else() target_link_libraries(${target} PUBLIC boost_glob) endif() @@ -101,7 +33,7 @@ endfunction(target_link_boost) function(target_link_boost_test target) if (USE_SYSTEM_BOOST) target_compile_definitions(${target} PRIVATE BOOST_TEST_DYN_LINK) - target_link_libraries(${target} PRIVATE ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + target_link_libraries(${target} PRIVATE Boost::unit_test_framework) else() target_link_libraries(${target} PUBLIC boost_unit_test) endif() @@ -110,9 +42,6 @@ endfunction(target_link_boost_test) if (USE_SYSTEM_BOOST) message("ASL_INFO: Using system boost.") set(ASL_BOOST_COMPONENTS system filesystem unit_test_framework program_options) - if(NOT USE_STD_THREAD_LOCAL) - list(APPEND ASL_BOOST_COMPONENTS thread) - endif() find_package(Boost COMPONENTS ${ASL_BOOST_COMPONENTS} REQUIRED) else() message("ASL_INFO: Building boost ourselves.") @@ -121,11 +50,12 @@ else() # required by asl libs/system libs/filesystem - libs/thread libs/program_options libs/signals2 libs/variant libs/gil + # required by libs/filesystem + libs/container_hash # required by adobe::fnv unless ADOBE_FNV_NO_BIGINTS is defined libs/multiprecision # required by boost test or by the one above @@ -167,14 +97,6 @@ else() libs/array libs/container libs/math - # required by thread - libs/atomic - libs/date_time - libs/chrono - libs/tuple - libs/align - # required by chrono - libs/ratio # required by multiprecision libs/format libs/rational @@ -182,58 +104,46 @@ else() libs/multi_index ) - setup_dep(NAME boost_libraries URL https://github.com/boostorg/boost.git BRANCH boost-1.76.0 SUBMODULES ${BOOST_SUBMODULES}) + fetchcontent_declare(boost + GIT_REPOSITORY https://github.com/boostorg/boost.git + GIT_TAG boost-1.76.0 + GIT_SUBMODULES ${BOOST_SUBMODULES} + GIT_SHALLOW + SOURCE_SUBDIR "some value that will prevent cmake from finding root boost CMakeLists.txt (and I don't know why CONFIGURE_COMMAND \"\" does not work)") + fetchcontent_makeavailable(boost) + fetchcontent_getproperties(boost SOURCE_DIR boost_root) # There really isn't a need to separate out these sources, so we build them # in one large static library. - file(GLOB ASL_BOOST_FILESYSTEM_SRC ../boost_libraries/libs/filesystem/src/*.cpp) - file(GLOB ASL_BOOST_PROGRAM_OPTIONS_SRC ../boost_libraries/libs/program_options/src/*.cpp) - file(GLOB ASL_BOOST_SYSTEM_SRC ../boost_libraries/libs/system/src/*.cpp) + file(GLOB ASL_BOOST_FILESYSTEM_SRC ${boost_root}/libs/filesystem/src/*.cpp) + file(GLOB ASL_BOOST_PROGRAM_OPTIONS_SRC ${boost_root}/libs/program_options/src/*.cpp) + file(GLOB ASL_BOOST_SYSTEM_SRC ${boost_root}/libs/system/src/*.cpp) set(BOOST_GLOB_SOURCES ${ASL_BOOST_FILESYSTEM_SRC} ${ASL_BOOST_PROGRAM_OPTIONS_SRC} ${ASL_BOOST_SYSTEM_SRC}) - if(NOT USE_STD_THREAD_LOCAL) - message("ASL_INFO: adding boost thread to local boost build") - file(GLOB ASL_BOOST_THREAD_SRC ../boost_libraries/libs/thread/src/*.cpp) - - if (${UNIX}) - file(GLOB ASL_BOOST_THREAD_TSS ../boost_libraries/libs/thread/src/pthread/*.cpp) - elseif (${WIN32}) - set(ASL_BOOST_THREAD_TSS - ../boost_libraries/libs/thread/src/win32/thread.cpp - ../boost_libraries/libs/thread/src/win32/tss_pe.cpp # no idea if this is right... - ) - endif() - list(APPEND BOOST_GLOB_SOURCES - ${ASL_BOOST_THREAD_SRC} - ${ASL_BOOST_THREAD_TSS}) - endif() - add_library(boost_glob STATIC ${BOOST_GLOB_SOURCES}) - - target_include_directories(boost_glob PUBLIC ../boost_libraries) foreach (submodule ${BOOST_SUBMODULES}) - target_include_directories(boost_glob PUBLIC ../boost_libraries/${submodule}/include) + target_include_directories(boost_glob PUBLIC ${boost_root}/${submodule}/include) endforeach(submodule) # We separate out the unit test framework from the rest of the boost # add_library support because it has its own main routine which we only need # when building unit tests. - file(GLOB ASL_BOOST_TEST_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ../boost_libraries/libs/test/src/*.cpp) - list(REMOVE_ITEM ASL_BOOST_TEST_SRC ../boost_libraries/libs/test/src/cpp_main.cpp) + file(GLOB ASL_BOOST_TEST_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${boost_root}/libs/test/src/*.cpp) + set(asl_boost_unit_test_cpp_main_cpp_path ${boost_root}/libs/test/src/cpp_main.cpp) + cmake_path(RELATIVE_PATH asl_boost_unit_test_cpp_main_cpp_path) + list(REMOVE_ITEM ASL_BOOST_TEST_SRC ${asl_boost_unit_test_cpp_main_cpp_path}) add_library(boost_unit_test STATIC ${ASL_BOOST_TEST_SRC}) - - target_include_directories(boost_unit_test PUBLIC ../boost_libraries) - + target_include_directories(boost_unit_test PUBLIC ${boost_root}/libs/test/include) foreach (submodule ${BOOST_SUBMODULES}) - target_include_directories(boost_unit_test PUBLIC ../boost_libraries/${submodule}/include) + target_include_directories(boost_unit_test PUBLIC ${boost_root}/${submodule}/include) endforeach(submodule) endif() diff --git a/adobe/forest.hpp b/adobe/forest.hpp index 1874eae0..e6d3070f 100644 --- a/adobe/forest.hpp +++ b/adobe/forest.hpp @@ -409,6 +409,12 @@ class forest_iterator forest_iterator(const forest_iterator& x) : node_m(x.node_m), edge_m(x.edge_m) {} + forest_iterator& operator=(const forest_iterator& x) { + node_m = x.node_m; + edge_m = x.edge_m; + return *this; + } + std::size_t edge() const { return edge_m; } std::size_t& edge() { return edge_m; } bool equal_node(forest_iterator const& y) const { return node_m == y.node_m; } @@ -477,6 +483,12 @@ class forest_const_iterator : public boost::iterator_facade& x) : node_m(x.node_m), edge_m(x.edge_m) {} std::size_t edge() const { return edge_m; } diff --git a/adobe/functional.hpp b/adobe/functional.hpp index caca9a5e..89450013 100644 --- a/adobe/functional.hpp +++ b/adobe/functional.hpp @@ -12,9 +12,9 @@ #include #include +#include #include -#include #include #include @@ -221,7 +221,7 @@ struct binary_compose { template // T is boost::tuple<> struct element { - typedef typename boost::tuples::element::type type; + typedef typename std::tuple_element_t type; }; template @@ -238,9 +238,9 @@ struct element<1, std::pair> { template // T is pair or tuple struct get_element { - typename element::type& operator()(T& x) const { return boost::get(x); } + typename element::type& operator()(T& x) const { return std::get(x); } - const typename element::type& operator()(const T& x) const { return boost::get(x); } + const typename element::type& operator()(const T& x) const { return std::get(x); } }; /**************************************************************************************************/ diff --git a/adobe/implementation/zuid_sys_dep.hpp b/adobe/implementation/zuid_sys_dep.hpp index 40643845..7545eba0 100644 --- a/adobe/implementation/zuid_sys_dep.hpp +++ b/adobe/implementation/zuid_sys_dep.hpp @@ -41,25 +41,8 @@ #include -#include - -#include - -/* - set the following to the number of 100ns ticks of - the actual resolution of your system's clock -*/ -#define UUIDS_PER_TICK 10 - -/* - Set the following to a call to acquire a system wide global lock -*/ -#define STD_LOCK -#define STD_UNLOCK - -#ifdef BOOST_NO_INT64_T -#error "Your platform has no 64-bit integral type." -#endif +#include +#include /**************************************************************************************************/ @@ -67,13 +50,13 @@ namespace adobe { /**************************************************************************************************/ -typedef boost::uint64_t uuid_time_t; -typedef boost::array uuid_node_t; +typedef std::chrono::system_clock::duration::rep uuid_time_t; +typedef std::array uuid_node_t; /**************************************************************************************************/ void get_ieee_node_identifier(uuid_node_t* node); -void get_system_time(uuid_time_t* uuid_time); +std::chrono::system_clock::time_point get_system_time(); boost::uint64_t true_random(); diff --git a/adobe/json.hpp b/adobe/json.hpp index 39032534..aa873574 100644 --- a/adobe/json.hpp +++ b/adobe/json.hpp @@ -17,11 +17,7 @@ #include #include -#ifdef ADOBE_BUILT_WITH_CMAKE #include -#else -#include -#endif #include #include diff --git a/adobe/md5.hpp b/adobe/md5.hpp index ff9b6191..a4bc31ec 100644 --- a/adobe/md5.hpp +++ b/adobe/md5.hpp @@ -11,9 +11,9 @@ #include -#include #include +#include #include /**************************************************************************************************/ @@ -94,7 +94,7 @@ Finalizes the input hash and clears the MD5 hash state information class md5_t { public: - typedef boost::array digest_t; + typedef std::array digest_t; md5_t(); diff --git a/adobe/name.hpp b/adobe/name.hpp index 9bbe171e..43b8dc01 100644 --- a/adobe/name.hpp +++ b/adobe/name.hpp @@ -99,7 +99,7 @@ namespace literals { /**************************************************************************************************/ -inline constexpr static_name_t operator"" _name(const char* str, std::size_t n); +inline constexpr static_name_t operator"" _name(const char* str, std::size_t n) noexcept; /**************************************************************************************************/ @@ -158,7 +158,7 @@ struct static_name_t { friend struct name_t; - friend constexpr static_name_t literals::operator"" _name(const char* str, std::size_t n); + friend constexpr static_name_t literals::operator"" _name(const char* str, std::size_t n) noexcept; friend std::ostream& operator<<(std::ostream& s, const static_name_t& name); @@ -199,7 +199,7 @@ namespace literals { static_name_t foo("foo"_name); // OK name_t bar("bar"_name); // OK */ -inline constexpr static_name_t operator"" _name(const char* str, std::size_t n) { +inline constexpr static_name_t operator"" _name(const char* str, std::size_t n) noexcept { return static_name_t{str, detail::name_hash(str, n)}; } diff --git a/adobe/once.hpp b/adobe/once.hpp index 0f32d942..086c9c09 100644 --- a/adobe/once.hpp +++ b/adobe/once.hpp @@ -23,8 +23,6 @@ to do something here. /**************************************************************************************************/ -#ifdef ADOBE_STD_THREAD_LOCAL - #define ADOBE_THREAD_LOCAL_STORAGE_1(type, signature, ctor_p1) \ type& adobe_thread_local_storage_##signature##_access() { \ thread_local type holder{ctor_p1}; \ @@ -39,71 +37,6 @@ to do something here. #define ADOBE_THREAD_LOCAL_STORAGE_INITIALIZE(signature) - -#else - -#include - -#if defined(BOOST_HAS_THREADS) - -#include - -#define ADOBE_THREAD_LOCAL_STORAGE_1(type, signature, ctor_p1) \ - namespace { \ - typedef boost::thread_specific_ptr adobe_thread_local_storage_##signature##_t; \ - adobe_thread_local_storage_##signature##_t* adobe_thread_local_storage_##signature##_g = 0; \ - type& adobe_thread_local_storage_##signature##_access(); \ - type& adobe_thread_local_storage_##signature##_access() { \ - type* result = adobe_thread_local_storage_##signature##_g->get(); \ - if (result) \ - return *result; \ - result = new type(ctor_p1); \ - adobe_thread_local_storage_##signature##_g->reset(result); \ - return *result; \ - } \ - } - -#define ADOBE_THREAD_LOCAL_STORAGE(type, signature) \ - namespace { \ - typedef boost::thread_specific_ptr adobe_thread_local_storage_##signature##_t; \ - adobe_thread_local_storage_##signature##_t* adobe_thread_local_storage_##signature##_g = 0; \ - type& adobe_thread_local_storage_##signature##_access(); \ - type& adobe_thread_local_storage_##signature##_access() { \ - type* result = adobe_thread_local_storage_##signature##_g->get(); \ - if (result) \ - return *result; \ - result = new type(); \ - adobe_thread_local_storage_##signature##_g->reset(result); \ - return *result; \ - } \ - } - -#define ADOBE_THREAD_LOCAL_STORAGE_INITIALIZE(signature) \ - static adobe_thread_local_storage_##signature##_t adobe_thread_local_storage_##signature##_s; \ - adobe_thread_local_storage_##signature##_g = &adobe_thread_local_storage_##signature##_s - -#else - -#define ADOBE_THREAD_LOCAL_STORAGE_1(type, signature, ctor_p1) \ - type& adobe_thread_local_storage_##signature##_access(); \ - type& adobe_thread_local_storage_##signature##_access() { \ - static type adobe_thread_local_storage_##signature##_s(ctor_p1); \ - return adobe_thread_local_storage_##signature##_s; \ - } - -#define ADOBE_THREAD_LOCAL_STORAGE(type, signature) \ - type& adobe_thread_local_storage_##signature##_access(); \ - type& adobe_thread_local_storage_##signature##_access() { \ - static type adobe_thread_local_storage_##signature##_s; \ - return adobe_thread_local_storage_##signature##_s; \ - } - -#define ADOBE_THREAD_LOCAL_STORAGE_INITIALIZE(signature) - -#endif - -#endif - #define ADOBE_THREAD_LOCAL_STORAGE_ACCESS(signature) \ adobe_thread_local_storage_##signature##_access() diff --git a/adobe/serializable.hpp b/adobe/serializable.hpp index e0129d00..52f2213f 100644 --- a/adobe/serializable.hpp +++ b/adobe/serializable.hpp @@ -14,11 +14,7 @@ #include #include -#ifdef ADOBE_BUILT_WITH_CMAKE #include -#else -#include -#endif #include diff --git a/adobe/timer.hpp b/adobe/timer.hpp index 4920e998..75cd20b7 100644 --- a/adobe/timer.hpp +++ b/adobe/timer.hpp @@ -106,10 +106,8 @@ ones used above. #undef WINDOWS_LEAN_AND_MEAN #undef ADOBE_UNDEFINE_WINDOWS_LEAN_AND_MEAN #endif -#elif defined(BOOST_HAS_THREADS) -#include -#elif defined(BOOST_HAS_GETTIMEOFDAY) -#include +#else +#include #endif #include @@ -125,10 +123,9 @@ namespace adobe { class timer_t : boost::totally_ordered { #if ADOBE_PLATFORM_WIN typedef LARGE_INTEGER value_type; -#elif defined(BOOST_HAS_THREADS) - typedef boost::xtime value_type; -#elif defined(BOOST_HAS_GETTIMEOFDAY) - typedef timeval value_type; +#else + typedef std::chrono::steady_clock clock_t; + typedef typename clock_t::time_point value_type; #endif typedef std::vector accumulator_type; @@ -176,10 +173,8 @@ class timer_t : boost::totally_ordered { inline void reset() { #if ADOBE_PLATFORM_WIN (void)::QueryPerformanceCounter(&epoch_m); -#elif defined(BOOST_HAS_THREADS) - boost::xtime_get(&epoch_m, boost::TIME_UTC_); -#elif defined(BOOST_HAS_GETTIMEOFDAY) - gettimeofday(&epoch_m, static_cast(0)); +#else + epoch_m = clock_t::now(); #endif } @@ -199,16 +194,10 @@ class timer_t : boost::totally_ordered { (void)::QueryPerformanceCounter(&split_m); return (split_m.QuadPart - epoch_m.QuadPart) / static_cast(frequency_m.QuadPart) * double(1e3); -#elif defined(BOOST_HAS_THREADS) - boost::xtime_get(&split_m, boost::TIME_UTC_); - return ((split_m.sec - epoch_m.sec) * double(1e3) + - (split_m.nsec - epoch_m.nsec) / double(1e6)); -#elif defined(BOOST_HAS_GETTIMEOFDAY) - gettimeofday(&split_m, static_cast(0)); - return ((split_m.tv_sec - epoch_m.tv_sec) * double(1e3) + - (split_m.tv_usec - epoch_m.tv_usec) / double(1e3)); #else - return -1; + split_m = clock_t::now(); + auto const duration = split_m - epoch_m; + return std::chrono::duration_cast(duration).count(); #endif } diff --git a/cmake_build.sh b/cmake_build.sh index 3760f97c..69445628 100755 --- a/cmake_build.sh +++ b/cmake_build.sh @@ -4,30 +4,26 @@ set -e : "${BUILDDIR:?BUILDDIR path required}" : "${TOOLSET:?TOOLSET required (xcode or your c++ compiler)}" : "${USE_SYSTEM_BOOST:?USE_SYSTEM_BOOST required (ON/OFF)}" -: "${USE_STD_THREAD_LOCAL:?USE_STD_THREAD_LOCAL required (ON/OFF)}" SRC_PATH=$(pwd) -mkdir -p ${BUILDDIR}/${TOOLSET}/${BUILDMODE}/${USE_SYSTEM_BOOST}/${USE_STD_THREAD_LOCAL} -pushd ${BUILDDIR}/${TOOLSET}/${BUILDMODE}/${USE_SYSTEM_BOOST}/${USE_STD_THREAD_LOCAL} +mkdir -p "${BUILDDIR}"/"${TOOLSET}"/"${BUILDMODE}"/"${USE_SYSTEM_BOOST}" +pushd "${BUILDDIR}"/"${TOOLSET}"/"${BUILDMODE}"/"${USE_SYSTEM_BOOST}" if [ "$TOOLSET" == "xcode" ]; then - cmake -DUSE_STD_THREAD_LOCAL=${USE_STD_THREAD_LOCAL} -DUSE_SYSTEM_BOOST=${USE_SYSTEM_BOOST} -DCMAKE_CXX_COMPILER=${TOOLSET} -DCMAKE_BUILD_TYPE=${BUILDMODE} -G "Xcode" ${SRC_PATH} + cmake -DUSE_SYSTEM_BOOST="${USE_SYSTEM_BOOST}" -DCMAKE_CXX_COMPILER="${TOOLSET}" -DCMAKE_BUILD_TYPE="${BUILDMODE}" -G "Xcode" "${SRC_PATH}" #make -j4 else GENERATOR="Unix Makefiles" - BUILDCMD="make -j4" + BUILDCMD="make -j" - #GENERATOR="Ninja" - #BUILDCMD="ninja-build" - - cmake -DUSE_STD_THREAD_LOCAL=${USE_STD_THREAD_LOCAL} -DUSE_SYSTEM_BOOST=${USE_SYSTEM_BOOST} -DCMAKE_CXX_COMPILER=${TOOLSET} -DCMAKE_BUILD_TYPE=${BUILDMODE} -G "${GENERATOR}" ${SRC_PATH} + cmake -DUSE_SYSTEM_BOOST="${USE_SYSTEM_BOOST}" -DCMAKE_CXX_COMPILER="${TOOLSET}" -DCMAKE_BUILD_TYPE="${BUILDMODE}" -G "${GENERATOR}" "${SRC_PATH}" ${BUILDCMD} # "ctest -C ${BUILDMODE}" handles CONFIGURATIONS option of CMake's add_test # which we use this to skip benchmarks in DEBUG builds # "make test" only run tests declared without any CONFIGURATIONS flag - ctest --output-on-failure -C ${BUILDMODE} + ctest --output-on-failure -C "${BUILDMODE}" fi popd diff --git a/cmake_build_all.sh b/cmake_build_all.sh index 162c2b97..a65096c6 100755 --- a/cmake_build_all.sh +++ b/cmake_build_all.sh @@ -7,31 +7,22 @@ BUILDDIR=${1:-../build_asl} # CLANG # -# local BOOST -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=OFF TOOLSET=clang++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=OFF TOOLSET=clang++ BUILDMODE=DEBUG sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=OFF TOOLSET=clang++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=OFF TOOLSET=clang++ BUILDMODE=DEBUG sh cmake_build.sh - # system BOOST -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=ON TOOLSET=clang++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=ON TOOLSET=clang++ BUILDMODE=DEBUG sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=ON TOOLSET=clang++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=ON TOOLSET=clang++ BUILDMODE=DEBUG sh cmake_build.sh +BUILDMODE=RELEASE USE_SYSTEM_BOOST=ON TOOLSET=clang++ BUILDDIR=${BUILDDIR} sh cmake_build.sh +BUILDMODE=DEBUG USE_SYSTEM_BOOST=ON TOOLSET=clang++ BUILDDIR=${BUILDDIR} sh cmake_build.sh + +# local BOOST +BUILDMODE=RELEASE USE_SYSTEM_BOOST=OFF TOOLSET=clang++ BUILDDIR=${BUILDDIR} sh cmake_build.sh +BUILDMODE=DEBUG USE_SYSTEM_BOOST=OFF TOOLSET=clang++ BUILDDIR=${BUILDDIR} sh cmake_build.sh # # GCC # -# local BOOST -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=OFF TOOLSET=g++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=OFF TOOLSET=g++ BUILDMODE=DEBUG sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=OFF TOOLSET=g++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=OFF TOOLSET=g++ BUILDMODE=DEBUG sh cmake_build.sh - # system BOOST -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=ON TOOLSET=g++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=ON USE_SYSTEM_BOOST=ON TOOLSET=g++ BUILDMODE=DEBUG sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=ON TOOLSET=g++ BUILDMODE=RELEASE sh cmake_build.sh -BUILDDIR=${BUILDDIR} USE_STD_THREAD_LOCAL=OFF USE_SYSTEM_BOOST=ON TOOLSET=g++ BUILDMODE=DEBUG sh cmake_build.sh +BUILDMODE=RELEASE USE_SYSTEM_BOOST=ON TOOLSET=g++ BUILDDIR=${BUILDDIR} sh cmake_build.sh +BUILDMODE=DEBUG USE_SYSTEM_BOOST=ON TOOLSET=g++ BUILDDIR=${BUILDDIR} sh cmake_build.sh +# local BOOST +BUILDMODE=RELEASE USE_SYSTEM_BOOST=OFF TOOLSET=g++ BUILDDIR=${BUILDDIR} sh cmake_build.sh +BUILDMODE=DEBUG USE_SYSTEM_BOOST=OFF TOOLSET=g++ BUILDDIR=${BUILDDIR} sh cmake_build.sh diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index d00ffc0c..4bc23a16 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -2,6 +2,12 @@ aux_source_directory(. SRC_LIST) file(GLOB_RECURSE INC_LIST ../adobe/*.hpp) add_library(asl ${SRC_LIST} ${INC_LIST}) +if(MSVC) + target_compile_options(asl PRIVATE /W4 /WX) +else() + target_compile_options(asl PRIVATE -Wall -Wextra -pedantic -Werror) +endif() + target_include_directories(asl PUBLIC ..) target_compile_definitions(asl PUBLIC ADOBE_STD_SERIALIZATION) diff --git a/source/adam.cpp b/source/adam.cpp index 63958e5b..32479ec1 100644 --- a/source/adam.cpp +++ b/source/adam.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/source/any_regular.cpp b/source/any_regular.cpp index bc734839..ba166982 100644 --- a/source/any_regular.cpp +++ b/source/any_regular.cpp @@ -12,12 +12,6 @@ #include #include -#ifdef ADOBE_BUILT_WITH_CMAKE -#include -#else -#include -#endif - #include #include #include diff --git a/source/virtual_machine.cpp b/source/virtual_machine.cpp index 597e131a..325f63f9 100644 --- a/source/virtual_machine.cpp +++ b/source/virtual_machine.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include diff --git a/source/xstring.cpp b/source/xstring.cpp index de9a1f2c..b5620463 100644 --- a/source/xstring.cpp +++ b/source/xstring.cpp @@ -308,7 +308,7 @@ struct transform_range { /**************************************************************************************************/ template -boost::tuple::type> +std::tuple::type> count_max_element_tuple(Range& x, UnaryFunction f) { typedef transform_range transform_range_t; @@ -316,16 +316,16 @@ count_max_element_tuple(Range& x, UnaryFunction f) { typename transform_range_t::iterator max_item = max_element(container); if (max_item == container.end()) - return boost::make_tuple(1, 0, max_item.base()); + return std::make_tuple(1, 0, max_item.base()); - return boost::make_tuple(std::count(max_item, container.end(), *max_item), *max_item, + return std::make_tuple(std::count(max_item, container.end(), *max_item), *max_item, max_item.base()); } /**************************************************************************************************/ context_frame_t::store_iterator -context_frame_t::closest_match(store_range_pair_t range, const adobe::attribute_set_t& searching) { +context_frame_t::closest_match(store_range_pair_t /*range*/, const adobe::attribute_set_t& /*searching*/) { // REVISIT: (fbrereto) This function fails to compile because `store_range_pair_t range`'s // iterators fail to evaluate as modeling the ForwardIterator concept, so the // count_max_element_tuple call below emits an error. I am disabling this routine instead @@ -341,18 +341,18 @@ context_frame_t::closest_match(store_range_pair_t range, const adobe::attribute_ if (!range_size) return glossary_m.end(); - boost::tuple result_tuple = count_max_element_tuple( + std::tuple result_tuple = count_max_element_tuple( range, boost::bind(store_count_same_t(), _1, boost::cref(searching))); - if (boost::get<1>(result_tuple) == 0) + if (std::get<1>(result_tuple) == 0) return glossary_m.end(); - else if (boost::get<0>(result_tuple) > 1) { + else if (std::get<0>(result_tuple) > 1) { std::stringstream errstr; errstr << "xstr: ambiguous closest match; found " - << static_cast(boost::get<0>(result_tuple)) + << static_cast(std::get<0>(result_tuple)) << " glossary entries that matched " - << static_cast(boost::get<1>(result_tuple)) << " attribute(s)"; + << static_cast(std::get<1>(result_tuple)) << " attribute(s)"; #if ADOBE_SERIALIZATION errstr << " while looking for a match to { " << searching << " }"; @@ -361,7 +361,7 @@ context_frame_t::closest_match(store_range_pair_t range, const adobe::attribute_ throw std::runtime_error(errstr.str()); } - return boost::get<2>(result_tuple); + return std::get<2>(result_tuple); #endif } @@ -508,37 +508,35 @@ struct replacement_engine_t { : score_m(-1), xstring_id_m(adobe::static_token_range(id.c_str())) {} replacement_engine_t(const std::string& xstr) : score_m(-1) { - using namespace boost::placeholders; + using namespace std::placeholders; adobe::make_xml_parser( reinterpret_cast(&xstr[0]), reinterpret_cast(&xstr[0]) + xstr.size(), adobe::line_position_t("replacement_engine_t"), adobe::implementation::xstring_preorder_predicate, - boost::bind(&replacement_engine_t::xstr_id_harvest, boost::ref(*this), _1, _2, _3, _4), - adobe::implementation::null_output_t()) - .parse_content(); + std::bind(&replacement_engine_t::xstr_id_harvest, std::ref(*this), _1, _2, _3, _4), + adobe::implementation::null_output_t()).parse_content(); } void add_marker(const std::string& marker) { - using namespace boost::placeholders; + using namespace std::placeholders; adobe::make_xml_parser( reinterpret_cast(&marker[0]), reinterpret_cast(&marker[0]) + marker.size(), adobe::line_position_t("add_marker"), adobe::implementation::xstring_preorder_predicate, - boost::bind(&replacement_engine_t::marker_parse, boost::ref(*this), _1, _2, _3, _4), - adobe::implementation::null_output_t()) - .parse_content(); + std::bind(&replacement_engine_t::marker_parse, std::ref(*this), _1, _2, _3, _4), + adobe::implementation::null_output_t()).parse_content(); } std::string run() { - using namespace boost::placeholders; + using namespace std::placeholders; implementation::context_frame_t::store_range_pair_t range( implementation::top_frame().range_for_key(xstring_id_m)); #ifndef NDEBUG std::iterator_traits::difference_type - range_size(std::distance(range.first, range.second)); + range_size(std::distance(range.first, range.second)); #endif for (; range.first != range.second; ++range.first) { @@ -550,11 +548,10 @@ struct replacement_engine_t { adobe::make_xml_parser(first, last, adobe::line_position_t("replacement_engine_t::run"), adobe::implementation::xstring_preorder_predicate, - boost::bind(&replacement_engine_t::candidate_parse, - boost::ref(*this), _1, _2, _3, _4, - boost::ref(score)), - std::back_inserter(temp_result)) - .parse_content(); + std::bind(&replacement_engine_t::candidate_parse, + std::ref(*this), _1, _2, _3, _4, + std::ref(score)), + std::back_inserter(temp_result)).parse_content(); if (score > score_m) { result_m = temp_result; diff --git a/source/zuid.cpp b/source/zuid.cpp index 8a5b9d59..cfb11259 100644 --- a/source/zuid.cpp +++ b/source/zuid.cpp @@ -131,7 +131,7 @@ void format_uuid(zuid_char_buffer_t& buffer, const adobe::uuid_t& uuid) { /**************************************************************************************************/ const adobe::uuid_t& empty_uuid() { - static adobe::uuid_t uuid_s = {0}; + static adobe::uuid_t uuid_s = {}; return uuid_s; } @@ -179,7 +179,7 @@ zuid_t::zuid_t(const std::string& zuid) : uuid_m(empty_uuid()) { zuid_t::zuid_t(const char* zuid_t) : uuid_m(empty_uuid()) { unsigned long temp_data1; - int temp_data[8]; + unsigned int temp_data[8]; std::sscanf(zuid_t, "%8lx-%4hx-%4hx-%2x%2x-%2x%2x%2x%2x%2x%2x", &temp_data1, &uuid_m.data2_m, &uuid_m.data3_m, &temp_data[0], &temp_data[1], &temp_data[2], &temp_data[3], diff --git a/source/zuid_sys_dep.cpp b/source/zuid_sys_dep.cpp index 0238c6b4..b1a3bfbf 100644 --- a/source/zuid_sys_dep.cpp +++ b/source/zuid_sys_dep.cpp @@ -27,16 +27,10 @@ #pragma warning(disable : 4996) // c runtime library deprecated function warning #endif -#include - #if defined(BOOST_MSVC) #pragma warning(pop) #endif -#if defined(BOOST_HAS_THREADS) -#include -#endif - #if defined(BOOST_HAS_GETTIMEOFDAY) #include #endif @@ -122,15 +116,13 @@ namespace { adobe::md5_t::digest_t get_generic_random_info() { struct randomness { randomness() - : thread_id_m(std::hash()(std::this_thread::get_id())) + : thread_id_m(std::hash()(std::this_thread::get_id())), + time_m{std::chrono::system_clock::now()} #if defined(BOOST_HAS_UNISTD_H) , pid_m(getpid()), uid_m(getuid()), gid_m(getgid()) #endif { -#if defined(BOOST_HAS_THREADS) - boost::xtime_get(&time_m, boost::TIME_UTC_); -#endif #if defined(BOOST_HAS_UNISTD_H) gethostname(hostname_m, 256); #endif @@ -140,9 +132,7 @@ adobe::md5_t::digest_t get_generic_random_info() { } std::size_t thread_id_m; -#if defined(BOOST_HAS_THREADS) - boost::xtime time_m; -#endif + std::chrono::system_clock::time_point time_m; #if defined(BOOST_HAS_UNISTD_H) pid_t pid_m; uid_t uid_m; @@ -221,21 +211,8 @@ void random_address(uuid_node_t* node) { /**************************************************************************************************/ -void get_system_time(uuid_time_t* uuid_time) { - // REVISIT (fbrereto) : universal_time() is only available on the second_clock. - // It would be nice if it was one on the microsec_clock. - - boost::posix_time::ptime then(boost::gregorian::date(1585, boost::date_time::Oct, 15)); -#if BOOST_VERSION < 103300 - boost::posix_time::ptime now( - boost::date_time::second_clock::universal_time()); -#else - boost::posix_time::ptime now( - boost::date_time::second_clock::universal_time()); -#endif - *uuid_time = static_cast((now - then).total_nanoseconds() / - boost::posix_time::time_duration::ticks_per_second()); +std::chrono::system_clock::time_point get_system_time() { + return std::chrono::system_clock::now(); } /**************************************************************************************************/ diff --git a/source/zuid_uuid.cpp b/source/zuid_uuid.cpp index 0e69b185..d51eb797 100644 --- a/source/zuid_uuid.cpp +++ b/source/zuid_uuid.cpp @@ -87,46 +87,13 @@ void format_uuid_v3(uuid_t* uuid, boost::uint8_t hash[16]) { /**************************************************************************************************/ -/* - get-current_time -- get time as 60 bit 100ns ticks since whenever. - Compensate for the fact that real clock resolution is - less than 100ns. - - NOTE (SRP) : This code has been modified for ZUIDs. The code used - to throttle on the clock and be limited to UUIDS_PER_TICK. The new - code will increment first and reset on the clock every UUIDS_PER_TICK. -*/ - -void get_current_time(uuid_time_t* timestamp) { - static uuid_time_t time_last; - static boost::uint16_t uuids_this_tick(0); - static bool inited(false); - - if (!inited) { - get_system_time(&time_last); - inited = true; - }; +uuid_time_t get_current_time() { - if (uuids_this_tick < UUIDS_PER_TICK) { - ++uuids_this_tick; - } else { - uuid_time_t time_now; - - get_system_time(&time_now); - - // if the clock is outrunning the counter - - if (time_now > uuid_time_t(time_last + uuids_this_tick)) { - // reset count of uuids gen'd with this clock reading - uuids_this_tick = 0; - time_last = time_now; - } else { - ++uuids_this_tick; - } - } + static_assert( + std::is_same::value, + "this code is meant for nanoseconds clock resolution"); - /* add the count of uuids to low order bits of the clock reading */ - *timestamp = time_last + uuids_this_tick; + return get_system_time().time_since_epoch().count(); } /**************************************************************************************************/ @@ -137,7 +104,6 @@ void get_current_time(uuid_time_t* timestamp) { /* uuid_create -- generator a UUID */ boost::int16_t uuid_create(uuid_t* uuid) { - uuid_time_t timestamp; uuid_time_t last_time; boost::uint16_t clockseq; uuid_node_t node; @@ -145,7 +111,7 @@ boost::int16_t uuid_create(uuid_t* uuid) { boost::int16_t f; /* get current time */ - get_current_time(×tamp); + auto const timestamp = get_current_time(); /* get node ID */ get_ieee_node_identifier(&node); diff --git a/test/md5/check_md5.cpp b/test/md5/check_md5.cpp index 56780e90..d21d8f1f 100644 --- a/test/md5/check_md5.cpp +++ b/test/md5/check_md5.cpp @@ -4,9 +4,9 @@ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ +#include #include #include -#include #include #include @@ -36,7 +36,7 @@ int main(int argc, char* argv[]) { boost::filesystem::ifstream stream(file_path, std::ios::binary | std::ios::in); while (stream.good()) { - boost::array buffer; + std::array buffer; stream.read(&buffer[0], static_cast(buffer.size())); diff --git a/test/to_string/main.cpp b/test/to_string/main.cpp index 87607f75..018ab5c4 100644 --- a/test/to_string/main.cpp +++ b/test/to_string/main.cpp @@ -24,12 +24,7 @@ #include #include -// double-conversion -#ifdef ADOBE_BUILT_WITH_CMAKE #include -#else -#include -#endif /******************************************************************************/