Skip to content

Commit

Permalink
LLFIO is now make installable and cmake find_package()-able, which sh…
Browse files Browse the repository at this point in the history
…ould implement cmake hunter support.

Significantly slimmed down the headers being dragged in by the default LLFIO include, specifically that outcome<T> is no longer dragged in, and:

- #36 Async file i/o and storage profile have been modularised out of the default headers.

- #36 Mapped file i/o can be modularised out of the default headers.

Changed barrier kind to class enum, as per latest WG21 spec.
  • Loading branch information
ned14 committed Sep 25, 2019
1 parent a394242 commit aea9a0b
Show file tree
Hide file tree
Showing 46 changed files with 252 additions and 363 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ if(MSVC)
endif()
endif()
if(CLANG OR GCC)
CheckCXXHasCoroutines(_CLANG_GCC "-std=c++14 -fcoroutines-ts")
CheckCXXHasCoroutines(_CLANG_GCC "-fcoroutines-ts")
if(CXX_HAS_COROUTINES_CLANG_GCC)
all_compile_options(PUBLIC "-fcoroutines-ts")
all_compile_definitions(PUBLIC "LLFIO_HAVE_COROUTINES=1")
Expand Down Expand Up @@ -176,6 +176,10 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR APPLE)
all_link_libraries(PUBLIC ${libcxx_cxxexperimental})
endif()
# Set any macros this library requires
all_compile_definitions(PRIVATE LLFIO_INCLUDE_ASYNC_FILE_HANDLE=1 LLFIO_INCLUDE_STORAGE_PROFILE=1)
foreach(target ${llfio_EXAMPLE_TARGETS})
target_compile_definitions(${target} PRIVATE LLFIO_INCLUDE_ASYNC_FILE_HANDLE=1 LLFIO_INCLUDE_STORAGE_PROFILE=1)
endforeach()
if(LLFIO_USE_EXPERIMENTAL_SG14_STATUS_CODE)
all_compile_definitions(PUBLIC LLFIO_EXPERIMENTAL_STATUS_CODE=1)
endif()
Expand Down Expand Up @@ -208,7 +212,10 @@ endif()

# For all possible configurations of this library, add each test
include(QuickCppLibMakeStandardTests)
# For each test target, link to kerneltest
# For each test target, set definitions and linkage
foreach(target ${llfio_COMPILE_TEST_TARGETS} ${llfio_TEST_TARGETS})
target_compile_definitions(${target} PRIVATE LLFIO_INCLUDE_ASYNC_FILE_HANDLE=1 LLFIO_INCLUDE_STORAGE_PROFILE=1)
endforeach()
foreach(test_target ${llfio_TEST_TARGETS})
target_link_libraries(${test_target} PRIVATE kerneltest::hl)
endforeach()
Expand Down
2 changes: 1 addition & 1 deletion doc/html
Submodule html updated 158 files
1 change: 1 addition & 0 deletions example/ts_examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ inline io_handle::buffers_type read_all(io_handle &h, io_handle::io_request<io_h
}
// Partial fill buffers with current request
io_handle::buffers_type filled = h.read(creq, nd) VALUE;
(void) filled;

// Adjust output buffers by what was filled, and prepare input
// buffers for next round of partial fill
Expand Down
12 changes: 1 addition & 11 deletions include/kvstore/kvstore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,7 @@ Distributed under the Boost Software License, Version 1.0.

#include "../llfio/v2.0/file_handle.hpp"

#ifdef __has_include
#if __has_include("../llfio/v2.0/quickcpplib/include/memory_resource.hpp")
#include "../llfio/v2.0/quickcpplib/include/memory_resource.hpp"
#else
#include "quickcpplib/include/memory_resource.hpp"
#endif
#elif __PCPP_ALWAYS_TRUE__
#include "quickcpplib/include/memory_resource.hpp"
#else
#include "../llfio/v2.0/quickcpplib/include/memory_resource.hpp"
#endif
#include "quickcpplib/memory_resource.hpp"

//! \file kvstore.hpp Provides the abstract interface for a key-value store.

Expand Down
6 changes: 3 additions & 3 deletions include/llfio/revision.hpp
Original file line number Diff line number Diff line change
@@ -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 5129a908d2855e7f22f5e1f3577a91826115075d
#define LLFIO_PREVIOUS_COMMIT_DATE "2019-09-18 22:06:21 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 5129a908
#define LLFIO_PREVIOUS_COMMIT_REF a3942420524c91179009e06b9d77cfb4326dcf7f
#define LLFIO_PREVIOUS_COMMIT_DATE "2019-09-19 09:51:59 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE a3942420
12 changes: 1 addition & 11 deletions include/llfio/v2.0/algorithm/shared_fs_mutex/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,7 @@ 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
#include "quickcpplib/algorithm/hash.hpp"


//! \file base.hpp Provides algorithm::shared_fs_mutex::shared_fs_mutex
Expand Down
12 changes: 1 addition & 11 deletions include/llfio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@ 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
#include "quickcpplib/algorithm/small_prng.hpp"

//! \file byte_ranges.hpp Provides algorithm::shared_fs_mutex::byte_ranges

Expand Down
12 changes: 1 addition & 11 deletions include/llfio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,7 @@ 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
#include "quickcpplib/algorithm/small_prng.hpp"


//! \file lock_files.hpp Provides algorithm::shared_fs_mutex::lock_files
Expand Down
22 changes: 3 additions & 19 deletions include/llfio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,9 @@ 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
#include "quickcpplib/algorithm/hash.hpp"
#include "quickcpplib/algorithm/small_prng.hpp"
#include "quickcpplib/spinlock.hpp"


//! \file memory_map.hpp Provides algorithm::shared_fs_mutex::memory_map
Expand Down
44 changes: 6 additions & 38 deletions include/llfio/v2.0/async_file_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class LLFIO_DECL async_file_handle : public file_handle
}

LLFIO_MAKE_FREE_FUNCTION
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC io_result<const_buffers_type> barrier(io_request<const_buffers_type> reqs = io_request<const_buffers_type>(), bool wait_for_device = false, bool and_metadata = false, deadline d = deadline()) noexcept override;
LLFIO_HEADERS_ONLY_VIRTUAL_SPEC io_result<const_buffers_type> barrier(io_request<const_buffers_type> reqs = io_request<const_buffers_type>(), barrier_kind kind = barrier_kind::nowait_data_only, deadline d = deadline()) noexcept override;
/*! Clone this handle to a different io_service (copy constructor is disabled to avoid accidental copying)
\errors Any of the values POSIX dup() or DuplicateHandle() can return.
Expand Down Expand Up @@ -367,10 +367,7 @@ class LLFIO_DECL async_file_handle : public file_handle
which always write barrier the entire file. Supplying a default initialised reqs write barriers the entire file.
\param completion A callable to call upon i/o completion. Spec is `void(async_file_handle *, io_result<const_buffers_type> &)`.
Note that buffers returned may not be buffers input, see documentation for `barrier()`.
\param wait_for_device True if you want the call to wait until data reaches storage and that storage
has acknowledged the data is physically written. Slow.
\param and_metadata True if you want the call to sync the metadata for retrieving the writes before the
barrier after a sudden power loss event. Slow.
\param kind Which kind of write reordering barrier to perform.
\param mem Optional span of memory to use to avoid using `calloc()`. Note span MUST be all bits zero on entry.
\errors As for `barrier()`, plus `ENOMEM`.
\mallocs If mem is not set, one calloc, one free. The allocation is unavoidable due to the need to store a type
Expand All @@ -379,7 +376,7 @@ class LLFIO_DECL async_file_handle : public file_handle
LLFIO_MAKE_FREE_FUNCTION
template <class CompletionRoutine> //
LLFIO_REQUIRES(detail::is_invocable_r<void, CompletionRoutine, async_file_handle *, io_result<const_buffers_type> &>::value) //
result<io_state_ptr> async_barrier(io_request<const_buffers_type> reqs, CompletionRoutine &&completion, bool wait_for_device = false, bool and_metadata = false, span<char> mem = {}) noexcept
result<io_state_ptr> async_barrier(io_request<const_buffers_type> reqs, CompletionRoutine &&completion, barrier_kind kind = barrier_kind::nowait_data_only, span<char> mem = {}) noexcept
{
LLFIO_LOG_FUNCTION_CALL(this);
struct completion_handler : _erased_completion_handler
Expand All @@ -401,15 +398,15 @@ class LLFIO_DECL async_file_handle : public file_handle
void *address() noexcept final { return &completion; }
} ch{std::forward<CompletionRoutine>(completion)};
operation_t operation = operation_t::fsync_sync;
if(!wait_for_device && and_metadata)
if(kind == barrier_kind::nowait_all)
{
operation = operation_t::fsync_async;
}
else if(wait_for_device && !and_metadata)
else if(kind == barrier_kind::wait_data_only)
{
operation = operation_t::dsync_sync;
}
else if(!wait_for_device && !and_metadata)
else if(kind == barrier_kind::nowait_data_only)
{
operation = operation_t::dsync_async;
}
Expand Down Expand Up @@ -689,35 +686,6 @@ inline result<async_file_handle> async_temp_inode(io_service &service, const pat
{
return async_file_handle::async_temp_inode(std::forward<decltype(service)>(service), std::forward<decltype(dir)>(dir), std::forward<decltype(_mode)>(_mode), std::forward<decltype(flags)>(flags));
}
inline async_file_handle::io_result<async_file_handle::const_buffers_type> barrier(async_file_handle &self, async_file_handle::io_request<async_file_handle::const_buffers_type> reqs = async_file_handle::io_request<async_file_handle::const_buffers_type>(), bool wait_for_device = false, bool and_metadata = false,
deadline d = deadline()) noexcept
{
return self.barrier(std::forward<decltype(reqs)>(reqs), std::forward<decltype(wait_for_device)>(wait_for_device), std::forward<decltype(and_metadata)>(and_metadata), std::forward<decltype(d)>(d));
}
/*! \brief Schedule a barrier to occur asynchronously.
\note All the caveats and exclusions which apply to `barrier()` also apply here. Note that Microsoft Windows
does not support asynchronously executed barriers, and this call will fail on that operating system.
\return Either an io_state_ptr to the i/o in progress, or an error code.
\param self The object whose member function to call.
\param reqs A scatter-gather and offset request for what range to barrier. May be ignored on some platforms
which always write barrier the entire file. Supplying a default initialised reqs write barriers the entire file.
\param completion A callable to call upon i/o completion. Spec is `void(async_file_handle *, io_result<const_buffers_type> &)`.
Note that buffers returned may not be buffers input, see documentation for `barrier()`.
\param wait_for_device True if you want the call to wait until data reaches storage and that storage
has acknowledged the data is physically written. Slow.
\param and_metadata True if you want the call to sync the metadata for retrieving the writes before the
barrier after a sudden power loss event. Slow.
\param mem Optional span of memory to use to avoid using `calloc()`. Note span MUST be all bits zero on entry.
\errors As for `barrier()`, plus `ENOMEM`.
\mallocs If mem is not set, one calloc, one free. The allocation is unavoidable due to the need to store a type
erased completion handler of unknown type and state per buffers input.
*/
template <class CompletionRoutine> inline result<async_file_handle::io_state_ptr> async_barrier(async_file_handle &self, async_file_handle::io_request<async_file_handle::const_buffers_type> reqs, CompletionRoutine &&completion, bool wait_for_device = false, bool and_metadata = false, span<char> mem = {}) noexcept
{
return self.async_barrier(std::forward<decltype(reqs)>(reqs), std::forward<decltype(completion)>(completion), std::forward<decltype(wait_for_device)>(wait_for_device), std::forward<decltype(and_metadata)>(and_metadata), std::forward<decltype(mem)>(mem));
}
/*! \brief Schedule a read to occur asynchronously.
Note that some OS kernels can only process a limited number async i/o
Expand Down
28 changes: 14 additions & 14 deletions include/llfio/v2.0/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <_mingw.h>
#endif

#include "quickcpplib/include/cpp_feature.h"
#include "quickcpplib/cpp_feature.h"

#ifndef __cpp_exceptions
#error LLFIO needs C++ exceptions to be turned on
Expand Down Expand Up @@ -144,7 +144,7 @@ Distributed under the Boost Software License, Version 1.0.
#endif


#include "quickcpplib/include/import.h"
#include "quickcpplib/import.h"

#if defined(LLFIO_UNSTABLE_VERSION) && !defined(LLFIO_DISABLE_ABI_PERMUTATION)
#include "../revision.hpp"
Expand Down Expand Up @@ -214,10 +214,10 @@ class file_handle;
LLFIO_V2_NAMESPACE_END

// Bring in the Boost-lite macros
#include "quickcpplib/include/config.hpp"
#include "quickcpplib/config.hpp"
#if LLFIO_LOGGING_LEVEL
#include "quickcpplib/include/ringbuffer_log.hpp"
#include "quickcpplib/include/utils/thread.hpp"
#include "quickcpplib/ringbuffer_log.hpp"
#include "quickcpplib/utils/thread.hpp"
#endif
// Bring in filesystem
#if defined(__has_include)
Expand Down Expand Up @@ -307,45 +307,45 @@ LLFIO_V2_NAMESPACE_END
#endif

// Bring in bitfields
#include "quickcpplib/include/bitfield.hpp"
#include "quickcpplib/bitfield.hpp"
// Bring in scoped undo
#include "quickcpplib/include/scoped_undo.hpp"
#include "quickcpplib/scoped_undo.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using QUICKCPPLIB_NAMESPACE::scoped_undo::undoer;
LLFIO_V2_NAMESPACE_END
// Bring in a span implementation
#include "quickcpplib/include/span.hpp"
#include "quickcpplib/span.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using namespace QUICKCPPLIB_NAMESPACE::span;
LLFIO_V2_NAMESPACE_END
// Bring in an optional implementation
#include "quickcpplib/include/optional.hpp"
#include "quickcpplib/optional.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using namespace QUICKCPPLIB_NAMESPACE::optional;
LLFIO_V2_NAMESPACE_END
// Bring in a byte implementation
#include "quickcpplib/include/byte.hpp"
#include "quickcpplib/byte.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using QUICKCPPLIB_NAMESPACE::byte::byte;
using QUICKCPPLIB_NAMESPACE::byte::to_byte;
LLFIO_V2_NAMESPACE_END
// Bring in a string_view implementation
#include "quickcpplib/include/string_view.hpp"
#include "quickcpplib/string_view.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using namespace QUICKCPPLIB_NAMESPACE::string_view;
LLFIO_V2_NAMESPACE_END
// Bring in an ensure_flushes implementation
#include "quickcpplib/include/mem_flush_loads_stores.hpp"
#include "quickcpplib/mem_flush_loads_stores.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using namespace QUICKCPPLIB_NAMESPACE::mem_flush_loads_stores;
LLFIO_V2_NAMESPACE_END
// Bring in a detach_cast implementation
#include "quickcpplib/include/detach_cast.hpp"
#include "quickcpplib/detach_cast.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using namespace QUICKCPPLIB_NAMESPACE::detach_cast;
LLFIO_V2_NAMESPACE_END
// Bring in an in_place_detach implementation
#include "quickcpplib/include/in_place_detach_attach.hpp"
#include "quickcpplib/in_place_detach_attach.hpp"
LLFIO_V2_NAMESPACE_BEGIN
using namespace QUICKCPPLIB_NAMESPACE::in_place_attach_detach;
using QUICKCPPLIB_NAMESPACE::in_place_attach_detach::in_place_attach;
Expand Down
4 changes: 2 additions & 2 deletions include/llfio/v2.0/detail/impl/posix/async_file_handle.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ Distributed under the Boost Software License, Version 1.0.

LLFIO_V2_NAMESPACE_BEGIN

async_file_handle::io_result<async_file_handle::const_buffers_type> async_file_handle::barrier(async_file_handle::io_request<async_file_handle::const_buffers_type> reqs, bool wait_for_device, bool and_metadata, deadline d) noexcept
async_file_handle::io_result<async_file_handle::const_buffers_type> async_file_handle::barrier(async_file_handle::io_request<async_file_handle::const_buffers_type> reqs, barrier_kind kind, deadline d) noexcept
{
LLFIO_LOG_FUNCTION_CALL(this);
optional<io_result<const_buffers_type>> ret;
OUTCOME_TRY(io_state, async_barrier(reqs, [&ret](async_file_handle *, io_result<const_buffers_type> &&result) { ret = std::move(result); }, wait_for_device, and_metadata));
OUTCOME_TRY(io_state, async_barrier(reqs, [&ret](async_file_handle *, io_result<const_buffers_type> &&result) { ret = std::move(result); }, kind));
(void) io_state;

// While i/o is not done pump i/o completion
Expand Down
10 changes: 1 addition & 9 deletions include/llfio/v2.0/detail/impl/posix/directory_handle.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ http://www.boost.org/LICENSE_1_0.txt)
#include "import.hpp"

#ifdef QUICKCPPLIB_ENABLE_VALGRIND
#ifdef __has_include
#if __has_include("../../../quickcpplib/valgrind/memcheck.h")
#include "../../../quickcpplib/valgrind/memcheck.h"
#else
#include "quickcpplib/valgrind/memcheck.h"
#endif
#else
#include "quickcpplib/valgrind/memcheck.h"
#endif
#include "../valgrind/memcheck.h" // from quickcpplib include directory
#define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b) VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE((a), (b))
#else
#define LLFIO_VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, b)
Expand Down
Loading

0 comments on commit aea9a0b

Please sign in to comment.