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>2021-02-03 00:17:49 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2021-02-03 00:17:49 +0300
commit46451d97a7c7d44af017f5b4eb138b7d34685df0 (patch)
tree48764a64b0ac2136ef8a3e6c6c28659d55c0240c
parentfc3aba2e135c8b31d00f7061a2d1068a326c3ff7 (diff)
parent33bf320ee712fab44aeba68f9fd3c672c9414b4f (diff)
Merge branch 'develop' of https://github.com/ned14/llfio into develop
-rw-r--r--CMakeLists.txt27
-rw-r--r--cmake/QuickCppLibBootstrap.cmake4
-rw-r--r--include/llfio/revision.hpp6
-rw-r--r--include/llfio/v2.0/detail/impl/fast_random_file_handle.ipp4
-rw-r--r--include/llfio/v2.0/detail/impl/windows/file_handle.ipp10
-rw-r--r--include/llfio/v2.0/detail/impl/windows/map_handle.ipp12
-rw-r--r--include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp14
-rw-r--r--test-packaging/example.cpp53
8 files changed, 75 insertions, 55 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ab59a446..a83a4dd9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,8 @@ include(QuickCppLibUtils)
include(QuickCppLibPolicies)
option(LLFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE "Whether to use SG14 status_code for failure handling" OFF)
+option(LLFIO_ENABLE_DEPENDENCY_SMOKE_TEST "Whether to build executables which are smoke tests that LLFIO is fully working. Used by various package managers such as vcpkg." OFF)
+set(UNIT_TESTS_CXX_VERSION "latest" CACHE STRING "The version of C++ to use in the header-only unit tests")
ensure_git_subrepo("${CMAKE_CURRENT_SOURCE_DIR}/include/llfio/ntkernel-error-category/include" "https://github.com/ned14/ntkernel-error-category.git")
@@ -66,8 +68,6 @@ if(WIN32)
endif()
endif()
-set(UNIT_TESTS_CXX_VERSION "latest" CACHE STRING "The version of C++ to use in the header-only unit tests")
-
# Make the standard static and shared libraries, and if supported by this compiler, C++ modules
# for both static and shared libraries as well. For the non-C++ module variants, makes the
# interface headers into precompiled headers. Only builds all of them if this is the topmost
@@ -161,7 +161,13 @@ if((MSVC AND MSVC_VERSION VERSION_GREATER_EQUAL 1923) OR APPLE)
endif()
endif()
# Set the library dependencies this library has
-all_link_libraries(PUBLIC quickcpplib::hl outcome::hl Threads::Threads $<$<PLATFORM_ID:Linux>:rt>)
+all_link_libraries(PUBLIC Threads::Threads $<$<PLATFORM_ID:Linux>:rt>)
+if(TARGET outcome::hl)
+ all_link_libraries(PUBLIC outcome::hl)
+endif()
+if(TARGET quickcpplib::hl)
+ all_link_libraries(PUBLIC quickcpplib::hl)
+endif()
# Set the system dependencies this library has
include(CheckCXXSourceCompiles)
@@ -390,6 +396,21 @@ if(NOT PROJECT_IS_DEPENDENCY)
endif()
endif()
+if(LLFIO_ENABLE_DEPENDENCY_SMOKE_TEST)
+ set(LLFIO_SMOKE_TESTS)
+ add_executable(llfio-dependency-smoke-test "test-packaging/example.cpp")
+ list(APPEND LLFIO_SMOKE_TESTS llfio-dependency-smoke-test)
+ foreach(target ${LLFIO_SMOKE_TESTS})
+ target_link_libraries(${target} PRIVATE llfio::dl)
+ set_target_properties(${target} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+ )
+ add_test(NAME ${target} CONFIGURATIONS Debug Release RelWithDebInfo MinSizeRel
+ COMMAND $<TARGET_FILE:${target}> --reporter junit --out $<TARGET_FILE:${target}>.junit.xml
+ )
+ endforeach()
+endif()
+
# Cache this library's auto scanned sources for later reuse
include(QuickCppLibCacheLibrarySources)
diff --git a/cmake/QuickCppLibBootstrap.cmake b/cmake/QuickCppLibBootstrap.cmake
index 0094ad4f..359c0eb7 100644
--- a/cmake/QuickCppLibBootstrap.cmake
+++ b/cmake/QuickCppLibBootstrap.cmake
@@ -28,7 +28,7 @@ foreach(item ${CMAKE_MODULE_PATH})
set(quickcpplib_done ON)
endif()
endforeach()
-if(DEFINED quickcpplib_DIR)
+if(NOT quickcpplib_done AND quickcpplib_DIR)
find_package(quickcpplib QUIET CONFIG)
if(quickcpplib_FOUND)
if(EXISTS "${quickcpplib_DIR}/share/cmakelib")
@@ -53,6 +53,8 @@ if(NOT quickcpplib_done)
set(CTEST_QUICKCPPLIB_SCRIPTS "${CMAKE_SOURCE_DIR}/../quickcpplib/scripts")
# Copy latest version of myself into end user
file(COPY "${CTEST_QUICKCPPLIB_SCRIPTS}/../cmake/QuickCppLibBootstrap.cmake" DESTINATION "${CMAKE_SOURCE_DIR}/cmake/")
+ elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/quickcpplib/repo/cmakelib")
+ set(CTEST_QUICKCPPLIB_CLONE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/quickcpplib")
elseif(CMAKE_BINARY_DIR)
# Place into root binary directory, same place as where find_quickcpplib_library() puts dependencies.
set(CTEST_QUICKCPPLIB_CLONE_DIR "${CMAKE_BINARY_DIR}/quickcpplib")
diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp
index c823736d..b43c4858 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 48ee8bae656cb5d53f38feb462caa53e1128b76d
-#define LLFIO_PREVIOUS_COMMIT_DATE "2021-01-27 20:37:58 +00:00"
-#define LLFIO_PREVIOUS_COMMIT_UNIQUE 48ee8bae
+#define LLFIO_PREVIOUS_COMMIT_REF 669e0b45bbc60cf4d46a72559710d428f2863740
+#define LLFIO_PREVIOUS_COMMIT_DATE "2021-02-02 11:20:42 +00:00"
+#define LLFIO_PREVIOUS_COMMIT_UNIQUE 669e0b45
diff --git a/include/llfio/v2.0/detail/impl/fast_random_file_handle.ipp b/include/llfio/v2.0/detail/impl/fast_random_file_handle.ipp
index 4429592e..200e4df6 100644
--- a/include/llfio/v2.0/detail/impl/fast_random_file_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/fast_random_file_handle.ipp
@@ -123,10 +123,10 @@ fast_random_file_handle::io_result<fast_random_file_handle::buffers_type> fast_r
}
if(p == &blk)
{
- memcpy(buffer.data() + i, ((const char *) p) + thisblockoffset, thisblocklen);
+ memcpy(buffer.data() + i, ((const char *) p) + thisblockoffset, (size_type) thisblocklen);
}
reqs.offset += thisblocklen;
- i += thisblocklen;
+ i += (size_type) thisblocklen;
togo -= thisblocklen;
if(togo == 0)
{
diff --git a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp
index 43bbf4df..8c065f68 100644
--- a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp
@@ -441,7 +441,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
extent.length = mycurrentlength - extent.offset;
}
LLFIO_DEADLINE_TO_SLEEP_INIT(d);
- const extent_type blocksize = utils::file_buffer_default_size();
+ const size_type blocksize = utils::file_buffer_default_size();
byte *buffer = nullptr;
auto unbufferh = make_scope_exit([&]() noexcept {
if(buffer != nullptr)
@@ -663,7 +663,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
for(extent_type thisoffset = 0; thisoffset < item.src.length; thisoffset += blocksize)
{
bool done = false;
- const auto thisblock = std::min(blocksize, item.src.length - thisoffset);
+ const auto thisblock = std::min((extent_type) blocksize, item.src.length - thisoffset);
if(duplicate_extents && item.op == workitem::clone_extents)
{
typedef struct _DUPLICATE_EXTENTS_DATA
@@ -713,7 +713,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
buffer = utils::page_allocator<byte>().allocate(blocksize);
}
deadline nd;
- buffer_type b(buffer, thisblock);
+ buffer_type b(buffer, (size_type) thisblock);
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
OUTCOME_TRY(auto readed, read({{&b, 1}, item.src.offset + thisoffset}, nd));
buffer_dirty = true;
@@ -807,10 +807,10 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte
buffer = utils::page_allocator<byte>().allocate(blocksize);
}
deadline nd;
- const_buffer_type cb(buffer, thisblock);
+ const_buffer_type cb(buffer, (size_type) thisblock);
if(buffer_dirty)
{
- memset(buffer, 0, thisblock);
+ memset(buffer, 0, (size_type) thisblock);
buffer_dirty = false;
}
LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d);
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 dd17d754..f1996484 100644
--- a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp
@@ -455,7 +455,7 @@ static inline result<void> win32_maps_apply(byte *addr, size_t bytes, win32_map_
/* mbi.RegionSize will be that from mbi.BaseAddress to end of a reserved region,
so clamp to region size originally requested.
*/
- OUTCOME_TRY(f(reinterpret_cast<byte *>(mbi.BaseAddress), std::min(mbi.RegionSize, bytes)));
+ OUTCOME_TRY(f(reinterpret_cast<byte *>(mbi.BaseAddress), std::min((size_t) mbi.RegionSize, bytes)));
}
addr += mbi.RegionSize;
if(mbi.RegionSize < bytes)
@@ -597,13 +597,13 @@ map_handle::io_result<map_handle::const_buffers_type> map_handle::_do_barrier(ma
// If nvram and not syncing metadata, use lightweight barrier
if(kind <= barrier_kind::wait_data_only && is_nvram())
{
- auto synced = nvram_barrier({addr, bytes});
+ auto synced = nvram_barrier({addr, (size_type) bytes});
if(synced.size() >= bytes)
{
return {reqs.buffers};
}
}
- OUTCOME_TRYV(win32_maps_apply(addr, bytes, win32_map_sought::committed, [](byte *addr, size_t bytes) -> result<void> {
+ OUTCOME_TRYV(win32_maps_apply(addr, (size_type) bytes, win32_map_sought::committed, [](byte *addr, size_t bytes) -> result<void> {
if(FlushViewOfFile(addr, static_cast<SIZE_T>(bytes)) == 0)
{
return win32_error();
@@ -684,7 +684,7 @@ result<map_handle> map_handle::map(section_handle &section, size_type bytes, ext
ret.value()._addr = static_cast<byte *>(addr);
ret.value()._offset = offset;
ret.value()._reservation = _bytes;
- ret.value()._length = section.length().value() - offset;
+ ret.value()._length = (size_type) (section.length().value() - offset);
ret.value()._pagesize = pagesize;
// Make my handle borrow the native handle of my backing storage
ret.value()._v.h = section.backing_native_handle().h;
@@ -754,7 +754,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool /* un
// If newsize isn't exactly a previous extension, this will fail, same as for the VirtualAlloc case
OUTCOME_TRY(win32_release_file_allocations(_addr + newsize, _reservation - newsize));
_reservation = newsize;
- _length = (length - _offset < newsize) ? (length - _offset) : newsize; // length of backing, not reservation
+ _length = (size_type)((length - _offset < newsize) ? (length - _offset) : newsize); // length of backing, not reservation
return _reservation;
}
// Try to map an additional part of the section directly after this map
@@ -772,7 +772,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool /* un
return ntkernel_error(ntstat);
}
_reservation += _bytes;
- _length = (length - _offset < newsize) ? (length - _offset) : newsize; // length of backing, not reservation
+ _length = (size_type)((length - _offset < newsize) ? (length - _offset) : newsize); // length of backing, not reservation
return _reservation;
}
diff --git a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp
index beef8cb8..6afece64 100644
--- a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp
@@ -39,7 +39,7 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese
}
if(reservation == 0)
{
- reservation = length;
+ reservation = (size_type) length;
}
if(!_sh.is_valid())
{
@@ -66,7 +66,7 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese
}
else if(map_size > length)
{
- map_size = length;
+ map_size = (size_type) length;
}
OUTCOME_TRYV(_mh.close());
OUTCOME_TRY(auto &&mh, map_handle::map(_sh, map_size, 0, mapflags));
@@ -117,7 +117,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type
OUTCOME_TRY(auto &&ret, file_handle::truncate(newsize));
if(newsize > _reservation)
{
- _reservation = newsize;
+ _reservation = (size_type) newsize;
}
// Reserve now we have resized, it'll create a new section for the new size
OUTCOME_TRYV(reserve(_reservation));
@@ -149,13 +149,13 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type
// Have we exceeded the reservation? If so, reserve a new reservation which will recreate the map.
if(newsize > _reservation)
{
- OUTCOME_TRY(auto &&ret, reserve(newsize));
+ OUTCOME_TRY(auto &&ret, reserve((size_type) newsize));
return ret;
}
size = newsize;
}
// Adjust the map to reflect the new size of the section
- _mh._length = size;
+ _mh._length = (size_type) size;
return newsize;
}
@@ -183,13 +183,13 @@ result<mapped_file_handle::extent_type> mapped_file_handle::update_map() noexcep
if(size >= length)
{
// Section is already the same size as the file, or is as big as it can go
- _mh._length = length;
+ _mh._length = (size_type) length;
return length;
}
// Nobody appears to have extended the section to match the file yet
OUTCOME_TRYV(_sh.truncate(length));
// Adjust the map to reflect the new size of the section
- _mh._length = length;
+ _mh._length = (size_type) length;
return length;
}
diff --git a/test-packaging/example.cpp b/test-packaging/example.cpp
index 5840d4df..b64a98d2 100644
--- a/test-packaging/example.cpp
+++ b/test-packaging/example.cpp
@@ -24,37 +24,34 @@ Distributed under the Boost Software License, Version 1.0.
#include <llfio.hpp>
-#include <vector>
+#include <iostream>
int main()
{
- //! [file_entire_file1]
namespace llfio = LLFIO_V2_NAMESPACE;
- // Open the file for read
- llfio::file_handle fh = llfio::file( //
- {}, // path_handle to base directory
- "foo" // path_view to path fragment relative to base directory
- // default mode is read only
- // default creation is open existing
- // default caching is all
- // default flags is none
- ).value(); // If failed, throw a filesystem_error exception
-
- // Make a vector sized the current maximum extent of the file
- std::vector<llfio::byte> buffer(fh.maximum_extent().value());
-
- // Synchronous scatter read from file
- llfio::file_handle::size_type bytesread = llfio::read(
- fh, // handle to read from
- 0, // offset
- {{ buffer.data(), buffer.size() }} // Single scatter buffer of the vector
- // default deadline is infinite
- ).value(); // If failed, throw a filesystem_error exception
-
- // In case of racy truncation of file by third party to new length, adjust buffer to
- // bytes actually read
- buffer.resize(bytesread);
- //! [file_entire_file1]
- return 0;
+ auto r = []() -> llfio::result<int> {
+ OUTCOME_TRY(auto fh, llfio::file_handle::temp_file());
+ static const char *buffers[] = { "He", "llo", " world" };
+ OUTCOME_TRY(fh.write(0, { { (const llfio::byte *) buffers[0], 2 }, { (const llfio::byte *) buffers[1], 3 }, { (const llfio::byte *) buffers[2], 6 } } ));
+ llfio::byte buffer[64];
+ OUTCOME_TRY(auto read, fh.read(0, { {buffer, sizeof(buffer)} }));
+ if(read != 11)
+ {
+ std::cerr << "FAILURE: Did not read 11 bytes!" << std::endl;
+ return 1;
+ }
+ if(0 != memcmp(buffer, "Hello world", 11))
+ {
+ std::cerr << "FAILURE: Did not read what was written!" << std::endl;
+ return 1;
+ }
+ return 0;
+ }();
+ if(!r)
+ {
+ std::cerr << "ERROR: " << r.error().message().c_str() << std::endl;
+ return 1;
+ }
+ return r.value();
}