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:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-10-16 15:19:12 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-10-16 15:19:12 +0300
commit8aa7070561256f147aa5bb6c20b7c5ae4370fb0f (patch)
tree578fdad70efabbb6a596a47ce6f9bd8ce7558d85
parent5cc6420a3faa9ac87c769a014afefbbe5bc9ba83 (diff)
Add reservation to mapped_temp_inode().
Replace bless emulation with start_lifetime_as, which is the new naming.
-rw-r--r--example/use_cases.cpp2
-rw-r--r--include/llfio/v2.0/config.hpp11
-rw-r--r--include/llfio/v2.0/detail/impl/windows/map_handle.ipp6
-rw-r--r--include/llfio/v2.0/mapped_file_handle.hpp7
4 files changed, 15 insertions, 11 deletions
diff --git a/example/use_cases.cpp b/example/use_cases.cpp
index 388622a8..ac632333 100644
--- a/example/use_cases.cpp
+++ b/example/use_cases.cpp
@@ -215,7 +215,7 @@ void malloc1()
size_t len = mh.length();
// map_handle::address() returns indeterminate bytes, so you need to bless
// them into existence before use
- llfio::bless(p, len);
+ new(p) llfio::byte[len];
memset(p, 'a', len);
// Tell the kernel to throw away the contents of any whole pages
diff --git a/include/llfio/v2.0/config.hpp b/include/llfio/v2.0/config.hpp
index f2f4525d..607c7f76 100644
--- a/include/llfio/v2.0/config.hpp
+++ b/include/llfio/v2.0/config.hpp
@@ -346,6 +346,11 @@ LLFIO_V2_NAMESPACE_END
LLFIO_V2_NAMESPACE_BEGIN
using namespace QUICKCPPLIB_NAMESPACE::mem_flush_loads_stores;
LLFIO_V2_NAMESPACE_END
+// Bring in a start_lifetime_as and launder implementation
+#include "quickcpplib/start_lifetime_as.hpp"
+LLFIO_V2_NAMESPACE_BEGIN
+using namespace QUICKCPPLIB_NAMESPACE::start_lifetime_as;
+LLFIO_V2_NAMESPACE_END
// Bring in a detach_cast implementation
#include "quickcpplib/detach_cast.hpp"
LLFIO_V2_NAMESPACE_BEGIN
@@ -376,12 +381,6 @@ namespace detail
inline T unsigned_integer_cast(U *v) { return static_cast<T>(reinterpret_cast<uintptr_t>(v)); }
} // namespace detail
-// Define a https://wg21.link/P0593 bless implementation
-inline void bless(void *start, size_t length) noexcept
-{
- memmove(start, start, length);
-}
-
LLFIO_V2_NAMESPACE_END
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 33ea06d9..38285a57 100644
--- a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
@@ -798,7 +798,11 @@ result<void> map_handle::zero_memory(buffer_type region) noexcept
{
if(DiscardVirtualMemory_(addr, bytes) == 0)
{
- return win32_error();
+ // It seems DiscardVirtualMemory() behaves like VirtualUnlock() sometimes.
+ if(ERROR_NOT_LOCKED != GetLastError())
+ {
+ return win32_error();
+ }
}
}
else
diff --git a/include/llfio/v2.0/mapped_file_handle.hpp b/include/llfio/v2.0/mapped_file_handle.hpp
index 41df2253..494d836c 100644
--- a/include/llfio/v2.0/mapped_file_handle.hpp
+++ b/include/llfio/v2.0/mapped_file_handle.hpp
@@ -277,10 +277,11 @@ public:
\errors Any of the values POSIX open() or CreateFile() can return.
*/
LLFIO_MAKE_FREE_FUNCTION
- static LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<mapped_file_handle> mapped_temp_inode(const path_handle &dir = path_discovery::storage_backed_temporary_files_directory(), mode _mode = mode::write, flag flags = flag::none) noexcept
+ static LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<mapped_file_handle> mapped_temp_inode(size_type reservation = 0, const path_handle &dir = path_discovery::storage_backed_temporary_files_directory(), mode _mode = mode::write, flag flags = flag::none) noexcept
{
OUTCOME_TRY(v, file_handle::temp_inode(dir, _mode, flags));
mapped_file_handle ret(std::move(v));
+ ret._reservation = reservation;
return {std::move(ret)};
}
@@ -522,9 +523,9 @@ is for backing shared memory maps).
\errors Any of the values POSIX open() or CreateFile() can return.
*/
-inline result<mapped_file_handle> mapped_temp_inode(const path_handle &dir = path_discovery::storage_backed_temporary_files_directory(), mapped_file_handle::mode _mode = mapped_file_handle::mode::write, mapped_file_handle::flag flags = mapped_file_handle::flag::none) noexcept
+inline result<mapped_file_handle> mapped_temp_inode(mapped_file_handle::size_type reservation = 0, const path_handle &dir = path_discovery::storage_backed_temporary_files_directory(), mapped_file_handle::mode _mode = mapped_file_handle::mode::write, mapped_file_handle::flag flags = mapped_file_handle::flag::none) noexcept
{
- return mapped_file_handle::mapped_temp_inode(std::forward<decltype(dir)>(dir), std::forward<decltype(_mode)>(_mode), std::forward<decltype(flags)>(flags));
+ return mapped_file_handle::mapped_temp_inode(std::forward<decltype(reservation)>(reservation), std::forward<decltype(dir)>(dir), std::forward<decltype(_mode)>(_mode), std::forward<decltype(flags)>(flags));
}
// END make_free_functions.py