Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt6
m---------doc/html17
-rw-r--r--example/use_cases.cpp2
-rw-r--r--include/llfio/revision.hpp6
-rw-r--r--include/llfio/v2.0/async_file_handle.hpp4
-rw-r--r--include/llfio/v2.0/detail/impl/windows/map_handle.ipp39
-rw-r--r--include/llfio/v2.0/io_service.hpp8
m---------include/llfio/v2.0/outcome0
m---------include/llfio/v2.0/quickcpplib0
-rw-r--r--include/llfio/v2.0/status_code.hpp14
-rw-r--r--test/tests/coroutines.cpp4
11 files changed, 63 insertions, 37 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b863b5e0..15caae4e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,7 +23,7 @@ find_quickcpplib_library(quickcpplib 1.0 REQUIRED)
find_quickcpplib_library(outcome 2.0 REQUIRED)
find_quickcpplib_library(kerneltest 1.0 REQUIRED)
if(WIN32)
- add_subdirectory("include/llfio/ntkernel-error-category" EXCLUDE_FROM_ALL)
+ add_subdirectory("include/llfio/ntkernel-error-category" )
endif()
# Make the standard static and shared libraries, and if supported by this compiler, C++ modules
@@ -111,14 +111,14 @@ if(MSVC)
CheckCXXHasCoroutines(_MSVC "/await")
if(CXX_HAS_COROUTINES_MSVC)
all_compile_options(PUBLIC "/await")
- all_compile_definitions(PUBLIC "__cpp_coroutines")
+ all_compile_definitions(PUBLIC "LLFIO_HAVE_COROUTINES=1")
endif()
endif()
if(CLANG OR GCC)
CheckCXXHasCoroutines(_CLANG_GCC "-std=c++14 -fcoroutines-ts")
if(CXX_HAS_COROUTINES_CLANG_GCC)
all_compile_options(PUBLIC "-fcoroutines-ts")
- all_compile_definitions(PUBLIC "__cpp_coroutines")
+ all_compile_definitions(PUBLIC "LLFIO_HAVE_COROUTINES=1")
endif()
endif()
diff --git a/doc/html b/doc/html
-Subproject cd89fe053ce730c1ae2e8f0fad34771deafd30a
+Subproject 8a7d532a92075a92797aece45c48a0eee0ae1aa
diff --git a/example/use_cases.cpp b/example/use_cases.cpp
index 9514c0e5..9237f5e1 100644
--- a/example/use_cases.cpp
+++ b/example/use_cases.cpp
@@ -388,7 +388,7 @@ void sparse_array()
//! [sparse_array]
}
-#ifdef __cpp_coroutines
+#if LLFIO_HAVE_COROUTINES
std::future<void> coroutine_write()
{
//! [coroutine_write]
diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp
index 8d8b30ef..5ce38f5e 100644
--- a/include/llfio/revision.hpp
+++ b/include/llfio/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 LLFIO_PREVIOUS_COMMIT_REF 554a740c9a23869596b012cfd4195bd19bc421db
-#define LLFIO_PREVIOUS_COMMIT_DATE "2018-12-15 14:56:38 +00:00"
-#define LLFIO_PREVIOUS_COMMIT_UNIQUE 554a740c
+#define LLFIO_PREVIOUS_COMMIT_REF d1f4429d43448daf0b79a6b414aff7c4ad12356b
+#define LLFIO_PREVIOUS_COMMIT_DATE "2019-05-08 09:48:00 +00:00"
+#define LLFIO_PREVIOUS_COMMIT_UNIQUE d1f4429d
diff --git a/include/llfio/v2.0/async_file_handle.hpp b/include/llfio/v2.0/async_file_handle.hpp
index 692ac1d5..3553e713 100644
--- a/include/llfio/v2.0/async_file_handle.hpp
+++ b/include/llfio/v2.0/async_file_handle.hpp
@@ -504,7 +504,7 @@ public:
using file_handle::write;
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC io_result<const_buffers_type> write(io_request<const_buffers_type> reqs, deadline d = deadline()) noexcept override;
-#if defined(__cpp_coroutines) || defined(DOXYGEN_IS_IN_THE_HOUSE)
+#if LLFIO_HAVE_COROUTINES || defined(DOXYGEN_IS_IN_THE_HOUSE)
private:
template <class BuffersType> class awaitable_state
{
@@ -759,7 +759,7 @@ template <class CompletionRoutine> inline result<async_file_handle::io_state_ptr
{
return self.async_write(std::forward<decltype(reqs)>(reqs), std::forward<decltype(completion)>(completion), std::forward<decltype(mem)>(mem));
}
-#if defined(__cpp_coroutines) || defined(DOXYGEN_IS_IN_THE_HOUSE)
+#if LLFIO_HAVE_COROUTINES || defined(DOXYGEN_IS_IN_THE_HOUSE)
/*! \brief Schedule a read to occur asynchronously.
\return An awaitable, which when `co_await`ed upon, suspends execution of the coroutine
diff --git a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
index 74583c9a..a4200f6f 100644
--- a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
@@ -380,13 +380,10 @@ static inline result<void> win32_map_flags(native_handle_type &nativeh, DWORD &a
return success();
}
-QUICKCPPLIB_BITFIELD_BEGIN(win32_map_sought)
-{
- committed = 1U << 0U, freed = 1U << 1U, reserved = 1U << 2U
-}
-QUICKCPPLIB_BITFIELD_END(win32_map_sought)
+QUICKCPPLIB_BITFIELD_BEGIN(win32_map_sought){committed = 1U << 0U, freed = 1U << 1U, reserved = 1U << 2U} QUICKCPPLIB_BITFIELD_END(win32_map_sought)
// Used to apply an operation to all maps within a region
-template <class F> static inline result<void> win32_maps_apply(byte *addr, size_t bytes, win32_map_sought sought, F &&f)
+template <class F>
+static inline result<void> win32_maps_apply(byte *addr, size_t bytes, win32_map_sought sought, F &&f)
{
/* Ok, so we have to be super careful here, because calling VirtualQuery()
somewhere in the middle of a region causes a linear scan until the beginning
@@ -802,15 +799,29 @@ result<void> map_handle::zero_memory(buffer_type region) noexcept
}
// Alas, zero() will not work on mapped views on Windows :(, so memset to zero and call discard if available
memset(region.data(), 0, region.size());
- if((DiscardVirtualMemory_ != nullptr) && region.size() >= utils::page_size())
+ if(region.size() >= utils::page_size())
{
region = utils::round_to_page_size(region, _pagesize);
if(region.size() > 0)
{
OUTCOME_TRYV(win32_maps_apply(region.data(), region.size(), win32_map_sought::committed, [](byte *addr, size_t bytes) -> result<void> {
- if(DiscardVirtualMemory_(addr, bytes) == 0)
+ if(DiscardVirtualMemory_ != nullptr)
{
- return win32_error();
+ if(DiscardVirtualMemory_(addr, bytes) == 0)
+ {
+ return win32_error();
+ }
+ }
+ else
+ {
+ // This will always fail, but has the side effect of discarding the pages anyway.
+ if(VirtualUnlock(addr, bytes) == 0)
+ {
+ if(ERROR_NOT_LOCKED != GetLastError())
+ {
+ return win32_error();
+ }
+ }
}
return success();
}));
@@ -861,11 +872,15 @@ result<map_handle::buffer_type> map_handle::do_not_store(buffer_type region) noe
}));
return region;
}
- // Else MEM_RESET will do
+ // Else VirtualUnlock will do
OUTCOME_TRYV(win32_maps_apply(region.data(), region.size(), win32_map_sought::committed, [](byte *addr, size_t bytes) -> result<void> {
- if(VirtualAlloc(addr, bytes, MEM_RESET, 0) == nullptr)
+ // This will always fail, but has the side effect of discarding the pages anyway.
+ if(VirtualUnlock(addr, bytes) == 0)
{
- return win32_error();
+ if(ERROR_NOT_LOCKED != GetLastError())
+ {
+ return win32_error();
+ }
}
return success();
}));
diff --git a/include/llfio/v2.0/io_service.hpp b/include/llfio/v2.0/io_service.hpp
index 00a7bad9..1b8f590b 100644
--- a/include/llfio/v2.0/io_service.hpp
+++ b/include/llfio/v2.0/io_service.hpp
@@ -31,7 +31,11 @@ Distributed under the Boost Software License, Version 1.0.
#include <deque>
#include <mutex>
-#if defined(__cpp_coroutines)
+#if defined(__cpp_coroutines) && !defined(LLFIO_HAVE_COROUTINES)
+#define LLFIO_HAVE_COROUTINES 1
+#endif
+
+#if defined(LLFIO_HAVE_COROUTINES)
// clang-format off
#if defined(__has_include)
#if __has_include(<coroutine>)
@@ -287,7 +291,7 @@ public:
*/
template <class U> void post(U &&f) { _post(detail::make_function_ptr<void(io_service *)>(std::forward<U>(f))); }
-#if defined(__cpp_coroutines) || defined(DOXYGEN_IS_IN_THE_HOUSE)
+#if LLFIO_HAVE_COROUTINES || defined(DOXYGEN_IS_IN_THE_HOUSE)
/*! An awaitable suspending execution of this coroutine on the current kernel thread,
and resuming execution on the kernel thread running this i/o service. This is a
convenience wrapper for `post()`.
diff --git a/include/llfio/v2.0/outcome b/include/llfio/v2.0/outcome
-Subproject 525478ed519d7c3400d60110649c315d705a07a
+Subproject 7e7d94bce47d810e8d0b7ad93d7011be2f027e5
diff --git a/include/llfio/v2.0/quickcpplib b/include/llfio/v2.0/quickcpplib
-Subproject 01e18d3e6549400646f41b79de318994eac95f2
+Subproject d88b0518d3f7b63c7650b07bf59d0a677d8902d
diff --git a/include/llfio/v2.0/status_code.hpp b/include/llfio/v2.0/status_code.hpp
index 7dacbec7..e9296fc2 100644
--- a/include/llfio/v2.0/status_code.hpp
+++ b/include/llfio/v2.0/status_code.hpp
@@ -88,7 +88,7 @@ namespace detail
//! Compares to a T
constexpr bool operator==(const T &b) const noexcept { return sc == b; }
};
-}
+} // namespace detail
template <class BaseStatusCodeDomain> class file_io_error_domain;
@@ -143,7 +143,7 @@ namespace mixins
return {};
}
};
-}
+} // namespace mixins
SYSTEM_ERROR2_NAMESPACE_END
LLFIO_V2_NAMESPACE_BEGIN
@@ -238,9 +238,9 @@ using file_io_error = SYSTEM_ERROR2_NAMESPACE::errored_status_code<SYSTEM_ERROR2
template <class T> using result = OUTCOME_V2_NAMESPACE::experimental::status_result<T, file_io_error>;
-using OUTCOME_V2_NAMESPACE::success;
using OUTCOME_V2_NAMESPACE::failure;
using OUTCOME_V2_NAMESPACE::in_place_type;
+using OUTCOME_V2_NAMESPACE::success;
//! Choose an errc implementation
using SYSTEM_ERROR2_NAMESPACE::errc;
@@ -260,7 +260,7 @@ inline file_io_error ntkernel_error(SYSTEM_ERROR2_NAMESPACE::win32::NTSTATUS c);
namespace detail
{
inline std::ostream &operator<<(std::ostream &s, const file_io_error &v) { return s << "llfio::file_io_error(" << v.message().c_str() << ")"; }
-}
+} // namespace detail
inline file_io_error error_from_exception(std::exception_ptr &&ep = std::current_exception(), file_io_error not_matched = generic_error(errc::resource_unavailable_try_again)) noexcept
{
if(!ep)
@@ -346,7 +346,7 @@ namespace detail
{
template <class Dest, class Src> inline void fill_failure_info(Dest &dest, const Src &src);
template <class Src> inline void append_path_info(Src &src, std::string &ret);
-}
+} // namespace detail
struct error_info;
inline std::error_code make_error_code(error_info ei);
@@ -386,7 +386,7 @@ public:
OUTCOME_TEMPLATE(class ErrorCondEnum)
OUTCOME_TREQUIRES(OUTCOME_TPRED(std::is_error_condition_enum<ErrorCondEnum>::value))
error_info(ErrorCondEnum &&v) // NOLINT
- : error_info(make_error_code(std::forward<ErrorCondEnum>(v)))
+ : error_info(make_error_code(std::forward<ErrorCondEnum>(v)))
{
}
@@ -554,8 +554,8 @@ inline void error_info::throw_exception() const
template <class T> using result = OUTCOME_V2_NAMESPACE::result<T, error_info>;
template <class T> using outcome = OUTCOME_V2_NAMESPACE::outcome<T, error_info>;
-using OUTCOME_V2_NAMESPACE::success;
using OUTCOME_V2_NAMESPACE::failure;
+using OUTCOME_V2_NAMESPACE::success;
inline error_info error_from_exception(std::exception_ptr &&ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept
{
return error_info(OUTCOME_V2_NAMESPACE::error_from_exception(std::move(ep), not_matched));
diff --git a/test/tests/coroutines.cpp b/test/tests/coroutines.cpp
index e6a09b6a..08727bbc 100644
--- a/test/tests/coroutines.cpp
+++ b/test/tests/coroutines.cpp
@@ -28,7 +28,7 @@ Distributed under the Boost Software License, Version 1.0.
static inline void TestAsyncFileHandleCoroutines()
{
-#ifdef __cpp_coroutines
+#if LLFIO_HAVE_COROUTINES
//! [coroutines_example]
namespace llfio = LLFIO_V2_NAMESPACE;
@@ -88,7 +88,7 @@ static inline void TestAsyncFileHandleCoroutines()
static inline void TestPostSelfToRunCoroutines()
{
-#ifdef __cpp_coroutines
+#if LLFIO_HAVE_COROUTINES
namespace llfio = LLFIO_V2_NAMESPACE;
llfio::io_service service;
std::atomic<bool> ready(false);