diff options
-rw-r--r-- | .travis.yml | 8 | ||||
-rw-r--r-- | CMakeLists.txt | 23 | ||||
-rw-r--r-- | include/afio/revision.hpp | 6 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp | 11 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp | 10 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp | 11 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp | 17 | ||||
-rw-r--r-- | include/afio/v2.0/config.hpp | 17 | ||||
-rw-r--r-- | include/afio/v2.0/detail/impl/posix/utils.ipp | 10 | ||||
-rw-r--r-- | include/afio/v2.0/detail/impl/safe_byte_ranges.ipp | 13 | ||||
-rw-r--r-- | include/afio/v2.0/detail/impl/storage_profile.ipp | 10 | ||||
m--------- | include/afio/v2.0/outcome | 0 | ||||
m--------- | include/afio/v2.0/quickcpplib | 0 | ||||
-rw-r--r-- | single-header/Readme.md | 4 | ||||
m--------- | test/kerneltest | 0 |
15 files changed, 125 insertions, 15 deletions
diff --git a/.travis.yml b/.travis.yml index 6cf66ead..fba93eb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,8 @@ env: global: - secure: "A3TeWTlJdjUaQ31NF60kMOik8mzaJkdKA55jZXjN83BJ2ZjMDmWfq1XmZ7iDIxmn7HC2BVpjhdkj9jpRtPztb08L5VSlJIiVbXlBWNwgzmYANujpR9rA+bhZJwlKDaYQHUZUd4+iGHCHb0dLt2HG0eHF5azaifd0YqCfz5GcWl8=" matrix: - - __="cmake tests" NAME=TravisLinuxWorker + - __="cmake tests (error_code)" NAME=TravisLinuxWorker CMAKE_CONFIGURE_OPTIONS= + - __="cmake tests (status_code)" NAME=TravisLinuxWorker CMAKE_CONFIGURE_OPTIONS=-DAFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE=ON - __="cmake tests" NAME=TravisOSXWorker - __="Documentation" NAME=TravisDocumentation - __="Programs" @@ -46,7 +47,8 @@ matrix: - os: osx env: __="Documentation" NAME=TravisDocumentation - os: osx - env: __="cmake tests" NAME=TravisLinuxWorker + env: __="cmake tests (error_code)" NAME=TravisLinuxWorker + env: __="cmake tests (status_code)" NAME=TravisLinuxWorker - os: linux compiler: g++ env: __="Documentation" NAME=TravisDocumentation @@ -75,7 +77,7 @@ before_install: export CXX=/usr/local/opt/llvm/bin/clang++; export LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"; export CPPFLAGS=-I/usr/local/opt/llvm/include; - export CMAKE_CONFIGURE_OPTIONS=-DCMAKE_LIBRARY_PATH=/usr/local/opt/llvm/lib; + export CMAKE_CONFIGURE_OPTIONS=$CMAKE_CONFIGURE_OPTIONS -DCMAKE_LIBRARY_PATH=/usr/local/opt/llvm/lib; fi - if [ "$CXX" = "g++" ]; then export CXX=g++-6; export NAME=TravisLinuxWorkerGCC; fi; - if [ "$CXX" = "clang++" ]; then export CXX=clang++-4.0; export NAME=TravisLinuxWorkerClang; fi; diff --git a/CMakeLists.txt b/CMakeLists.txt index 508ac977..1f1cf68f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ include(QuickCppLibRequireOutOfSourceBuild) include(QuickCppLibUtils) include(QuickCppLibPolicies) +option(AFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE "Whether to use SG14 status_code for failure handling" ON) + # Parse the version we tell cmake directly from the version header file ParseProjectVersionFromHpp("${CMAKE_CURRENT_SOURCE_DIR}/include/afio/version.hpp" VERSIONSTRING) # Sets the usual PROJECT_NAME etc @@ -49,23 +51,33 @@ if(NOT PROJECT_IS_DEPENDENCY) ${ARGN} -I .. --passthru-defines --passthru-unfound-includes --passthru-unknown-exprs - --passthru-comments --line-directive # --debug + --line-directive #--passthru-comments --debug -U QUICKCPPLIB_ENABLE_VALGRIND -U DOXYGEN_SHOULD_SKIP_THIS -U DOXYGEN_IS_IN_THE_HOUSE -U STANDARDESE_IS_IN_THE_HOUSE -U __has_include -U __has_feature -U __has_cpp_attribute -U __cpp_modules + -U gsl_FEATURE_WITH_CONTAINER_TO_STD -U gsl_FEATURE_MAKE_SPAN_TO_STD -U gsl_FEATURE_BYTE_SPAN_TO_STD + -U gsl_FEATURE_HAVE_IMPLICIT_MACRO -U gsl_FEATURE_HAVE_OWNER_MACRO -U gsl_FEATURE_EXPERIMENTAL_RETURN_GUARD WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) if(NOT CMAKE_VERSION VERSION_LESS 3.3) add_dependencies(outcome_hl ${target}) endif() endfunction() - make_single_header(afio_hl-pp-std - "${CMAKE_CURRENT_SOURCE_DIR}/single-header/afio.hpp" + make_single_header(afio_hl-pp-posix + "${CMAKE_CURRENT_SOURCE_DIR}/single-header/afio-posix.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/afio/v2.0/afio.hpp" #-D QUICKCPPLIB_USE_STD_BYTE -D QUICKCPPLIB_USE_STD_OPTIONAL -D QUICKCPPLIB_USE_STD_SPAN - -D AFIO_LEAN_AND_MEAN + -U gsl_COMPILER_MSVC_VERSION -U gsl_HAS_CPP0X -D gsl_CPLUSPLUS=201703 -D __cplusplus=201703 + -D AFIO_LEAN_AND_MEAN -U _WIN32 + -D AFIO_EXPERIMENTAL_STATUS_CODE=1) + make_single_header(afio_hl-pp-win + "${CMAKE_CURRENT_SOURCE_DIR}/single-header/afio-win.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/include/afio/v2.0/afio.hpp" + #-D QUICKCPPLIB_USE_STD_BYTE -D QUICKCPPLIB_USE_STD_OPTIONAL -D QUICKCPPLIB_USE_STD_SPAN + -D gsl_CPLUSPLUS=201703 -D __cplusplus=201703 + -D AFIO_LEAN_AND_MEAN -D _WIN32 -D AFIO_EXPERIMENTAL_STATUS_CODE=1) make_single_header(afio_hl-pp-abi "${CMAKE_CURRENT_SOURCE_DIR}/single-header/abi.hpp" @@ -141,6 +153,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE) all_link_libraries(PUBLIC ${libcxx_cxxexperimental}) endif() # Set any macros this library requires +if(AFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE) + all_compile_definitions(PUBLIC AFIO_EXPERIMENTAL_STATUS_CODE=1) +endif() if(WIN32) all_compile_definitions(PRIVATE _WIN32_WINNT=0x600) ## Target WinVista target_link_libraries(afio_dl PUBLIC ntkernel-error-category::dl) diff --git a/include/afio/revision.hpp b/include/afio/revision.hpp index 1dae6877..c55a7ab9 100644 --- a/include/afio/revision.hpp +++ b/include/afio/revision.hpp @@ -1,4 +1,4 @@ // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define AFIO_PREVIOUS_COMMIT_REF a36490c2e5cfdeedb65bf82bed40e3de28caf557 -#define AFIO_PREVIOUS_COMMIT_DATE "2018-06-07 15:12:29 +00:00" -#define AFIO_PREVIOUS_COMMIT_UNIQUE a36490c2 +#define AFIO_PREVIOUS_COMMIT_REF d90d68f80799f036e1a8270d0637f079d3a2bb71 +#define AFIO_PREVIOUS_COMMIT_DATE "2018-06-07 19:42:50 +00:00" +#define AFIO_PREVIOUS_COMMIT_UNIQUE d90d68f8 diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp index 9466c4c9..29aaee27 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp @@ -27,7 +27,18 @@ Distributed under the Boost Software License, Version 1.0. #include "../../handle.hpp" +#ifdef __has_include +#if __has_include("../../../quickcpplib/include/algorithm/hash.hpp") #include "../../quickcpplib/include/algorithm/hash.hpp" +#else +#include "quickcpplib/include/algorithm/hash.hpp" +#endif +#elif __PCPP_ALWAYS_TRUE__ +#include "quickcpplib/include/algorithm/hash.hpp" +#else +#include "../../quickcpplib/include/algorithm/hash.hpp" +#endif + //! \file base.hpp Provides algorithm::shared_fs_mutex::shared_fs_mutex diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp index 42f050df..1fe9fb13 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp @@ -28,7 +28,17 @@ Distributed under the Boost Software License, Version 1.0. #include "../../file_handle.hpp" #include "base.hpp" +#ifdef __has_include +#if __has_include("../../quickcpplib/include/algorithm/small_prng.hpp") #include "../../quickcpplib/include/algorithm/small_prng.hpp" +#else +#include "quickcpplib/include/algorithm/small_prng.hpp" +#endif +#elif __PCPP_ALWAYS_TRUE__ +#include "quickcpplib/include/algorithm/small_prng.hpp" +#else +#include "../../quickcpplib/include/algorithm/small_prng.hpp" +#endif //! \file byte_ranges.hpp Provides algorithm::shared_fs_mutex::byte_ranges diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp index 58774be2..33b3b31d 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp @@ -28,7 +28,18 @@ Distributed under the Boost Software License, Version 1.0. #include "../../file_handle.hpp" #include "base.hpp" +#ifdef __has_include +#if __has_include("../../quickcpplib/include/algorithm/small_prng.hpp") #include "../../quickcpplib/include/algorithm/small_prng.hpp" +#else +#include "quickcpplib/include/algorithm/small_prng.hpp" +#endif +#elif __PCPP_ALWAYS_TRUE__ +#include "quickcpplib/include/algorithm/small_prng.hpp" +#else +#include "../../quickcpplib/include/algorithm/small_prng.hpp" +#endif + //! \file lock_files.hpp Provides algorithm::shared_fs_mutex::lock_files diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp index 901ae528..3c140030 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp @@ -28,9 +28,26 @@ Distributed under the Boost Software License, Version 1.0. #include "../../map_handle.hpp" #include "base.hpp" +#ifdef __has_include +#if __has_include("../../../quickcpplib/include/algorithm/hash.hpp") #include "../../quickcpplib/include/algorithm/hash.hpp" #include "../../quickcpplib/include/algorithm/small_prng.hpp" #include "../../quickcpplib/include/spinlock.hpp" +#else +#include "quickcpplib/include/algorithm/hash.hpp" +#include "quickcpplib/include/algorithm/small_prng.hpp" +#include "quickcpplib/include/spinlock.hpp" +#endif +#elif __PCPP_ALWAYS_TRUE__ +#include "quickcpplib/include/algorithm/hash.hpp" +#include "quickcpplib/include/algorithm/small_prng.hpp" +#include "quickcpplib/include/spinlock.hpp" +#else +#include "../../quickcpplib/include/algorithm/hash.hpp" +#include "../../quickcpplib/include/algorithm/small_prng.hpp" +#include "../../quickcpplib/include/spinlock.hpp" +#endif + //! \file memory_map.hpp Provides algorithm::shared_fs_mutex::memory_map diff --git a/include/afio/v2.0/config.hpp b/include/afio/v2.0/config.hpp index da7bfa17..d8046bc3 100644 --- a/include/afio/v2.0/config.hpp +++ b/include/afio/v2.0/config.hpp @@ -82,7 +82,7 @@ Distributed under the Boost Software License, Version 1.0. #if !defined(AFIO_EXPERIMENTAL_STATUS_CODE) //! \brief Whether to use SG14 experimental `status_code` instead of `std::error_code` -#define AFIO_EXPERIMENTAL_STATUS_CODE 1 +#define AFIO_EXPERIMENTAL_STATUS_CODE 0 #endif @@ -229,6 +229,11 @@ AFIO_V2_NAMESPACE_BEGIN namespace filesystem = std::experimental::filesystem; AFIO_V2_NAMESPACE_END #endif +#elif __PCPP_ALWAYS_TRUE__ +#include <filesystem> +AFIO_V2_NAMESPACE_BEGIN +namespace filesystem = std::filesystem; +AFIO_V2_NAMESPACE_END // clang-format on #elif defined(_MSC_VER) #include <filesystem> @@ -1044,9 +1049,15 @@ template <class BaseStatusCodeDomain> inline typename error_domain<BaseStatusCod { assert(code.domain() == *this); const auto &v = static_cast<const SYSTEM_ERROR2_NAMESPACE::status_code<error_domain> &>(code); // NOLINT - std::string ret = v.message().c_str(); + std::string ret = _base::_message(code).c_str(); detail::append_path_info(v.value(), ret); - return atomic_refcounted_string_ref(ret.c_str(), ret.size()); + char *p = (char *) malloc(ret.size() + 1); + if(p == nullptr) + { + return string_ref("Failed to allocate memory to store error string"); + } + memcpy(p, ret.c_str(), ret.size() + 1); + return atomic_refcounted_string_ref(p, ret.size()); } #endif diff --git a/include/afio/v2.0/detail/impl/posix/utils.ipp b/include/afio/v2.0/detail/impl/posix/utils.ipp index e4376608..aecd0a03 100644 --- a/include/afio/v2.0/detail/impl/posix/utils.ipp +++ b/include/afio/v2.0/detail/impl/posix/utils.ipp @@ -24,7 +24,17 @@ Distributed under the Boost Software License, Version 1.0. #include "../../../utils.hpp" +#ifdef __has_include +#if __has_include("../../../quickcpplib/include/spinlock.hpp") #include "../../../quickcpplib/include/spinlock.hpp" +#else +#include "quickcpplib/include/spinlock.hpp" +#endif +#elif __PCPP_ALWAYS_TRUE__ +#include "quickcpplib/include/spinlock.hpp" +#else +#include "../../../quickcpplib/include/spinlock.hpp" +#endif #include <mutex> // for lock_guard diff --git a/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp b/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp index d8ee4255..e8544351 100644 --- a/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp +++ b/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp @@ -28,8 +28,21 @@ Distributed under the Boost Software License, Version 1.0. #include "../../algorithm/shared_fs_mutex/safe_byte_ranges.hpp" +#ifdef __has_include +#if __has_include("../../../quickcpplib/include/uint128.hpp") #include "../../quickcpplib/include/uint128.hpp" #include "../../quickcpplib/include/utils/thread.hpp" +#else +#include "quickcpplib/include/uint128.hpp" +#include "quickcpplib/include/utils/thread.hpp" +#endif +#elif __PCPP_ALWAYS_TRUE__ +#include "quickcpplib/include/uint128.hpp" +#include "quickcpplib/include/utils/thread.hpp" +#else +#include "../../quickcpplib/include/uint128.hpp" +#include "../../quickcpplib/include/utils/thread.hpp" +#endif #include <fcntl.h> #include <sys/stat.h> diff --git a/include/afio/v2.0/detail/impl/storage_profile.ipp b/include/afio/v2.0/detail/impl/storage_profile.ipp index b37305af..cc1ac9fc 100644 --- a/include/afio/v2.0/detail/impl/storage_profile.ipp +++ b/include/afio/v2.0/detail/impl/storage_profile.ipp @@ -28,7 +28,17 @@ Distributed under the Boost Software License, Version 1.0. #include "../../storage_profile.hpp" #include "../../utils.hpp" +#ifdef __has_include +#if __has_include("../../quickcpplib/include/algorithm/small_prng.hpp") #include "../../quickcpplib/include/algorithm/small_prng.hpp" +#else +#include "quickcpplib/include/algorithm/small_prng.hpp" +#endif +#elif __PCPP_ALWAYS_TRUE__ +#include "quickcpplib/include/algorithm/small_prng.hpp" +#else +#include "../../quickcpplib/include/algorithm/small_prng.hpp" +#endif #include <future> #include <vector> diff --git a/include/afio/v2.0/outcome b/include/afio/v2.0/outcome -Subproject a4fe32179a63d727422c17225e3fbd26fcc616c +Subproject c86fe12e5dfb35353d324170667fc96d830072f diff --git a/include/afio/v2.0/quickcpplib b/include/afio/v2.0/quickcpplib -Subproject b5fc1d357a75832a34bf776f395159490bbd9e6 +Subproject 341a549fcb1497db8825ae3f9aec8d6b9c93a2f diff --git a/single-header/Readme.md b/single-header/Readme.md index b2e45343..b4670d35 100644 --- a/single-header/Readme.md +++ b/single-header/Readme.md @@ -1,2 +1,2 @@ -Herein can lie a single header edition of AFIO. It currently exceeds 1.5Mb, -and so to keep the git repo from expanding it is not committed here. +Herein lie two single header editions of AFIO. To keep the size down, they are +split into POSIX and Windows only editions. diff --git a/test/kerneltest b/test/kerneltest -Subproject 7dce886c4ed4501d43886a97e44f9ff94e13a99 +Subproject f5afcd7f33df8d2d67082b66d81954723947acd |