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>2018-07-24 22:29:21 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-07-24 22:29:21 +0300
commit964d174c1c44d4810789b198bbf07271cebbe8c8 (patch)
treedc3d0ebb672e919caa2f9d2b8fb5654d230ae604 /include/llfio/v2.0/io_handle.hpp
parent084b3eb8aaae639e9a63e97245386fd78b8d8413 (diff)
i/o buffers now work as if they were span<byte>.
Implemented many of the missing functions in path_view. Implemented symlink_handle for Windows.
Diffstat (limited to 'include/llfio/v2.0/io_handle.hpp')
-rw-r--r--include/llfio/v2.0/io_handle.hpp89
1 files changed, 65 insertions, 24 deletions
diff --git a/include/llfio/v2.0/io_handle.hpp b/include/llfio/v2.0/io_handle.hpp
index 58716368..55aa1f21 100644
--- a/include/llfio/v2.0/io_handle.hpp
+++ b/include/llfio/v2.0/io_handle.hpp
@@ -51,10 +51,13 @@ public:
using flag = handle::flag;
//! The scatter buffer type used by this handle. Guaranteed to be `TrivialType` and `StandardLayoutType`.
+ //! Try to make address and length 64 byte, or ideally, `page_size()` aligned where possible.
struct buffer_type
{
//! Type of the pointer to memory.
using pointer = byte *;
+ //! Type of the pointer to memory.
+ using const_pointer = const byte *;
//! Type of the iterator to memory.
using iterator = byte *;
//! Type of the iterator to memory.
@@ -62,29 +65,50 @@ public:
//! Type of the length of memory.
using size_type = size_t;
- //! Pointer to memory to be filled by a read. Try to make this 64 byte, or ideally, `page_size()` aligned where possible.
- pointer data;
- //! The number of bytes to fill into this address. Try to make this a 64 byte multiple, or ideally, a whole multiple of `page_size()`.
- size_type len;
+ //! Default constructor
+ buffer_type() = default;
+ //! Constructor
+ constexpr buffer_type(pointer data, size_type len) noexcept : _data(data), _len(len) {}
+ buffer_type(const buffer_type &) = default;
+ buffer_type(buffer_type &&) = default;
+ buffer_type &operator=(const buffer_type &) = default;
+ buffer_type &operator=(buffer_type &&) = default;
+ ~buffer_type() = default;
+
+ // Emulation of this being a span<byte> in the TS
+
+ //! Returns the address of the bytes for this buffer
+ constexpr pointer data() noexcept { return _data; }
+ //! Returns the address of the bytes for this buffer
+ constexpr const_pointer data() const noexcept { return _data; }
+ //! Returns the number of bytes in this buffer
+ constexpr size_type size() const noexcept { return _len; }
//! Returns an iterator to the beginning of the buffer
- constexpr iterator begin() { return data; }
+ constexpr iterator begin() noexcept { return _data; }
//! Returns an iterator to the beginning of the buffer
- constexpr const_iterator begin() const { return data; }
+ constexpr const_iterator begin() const noexcept { return _data; }
//! Returns an iterator to the beginning of the buffer
- constexpr const_iterator cbegin() const { return data; }
+ constexpr const_iterator cbegin() const noexcept { return _data; }
//! Returns an iterator to after the end of the buffer
- constexpr iterator end() { return data + len; }
+ constexpr iterator end() noexcept { return _data + _len; }
//! Returns an iterator to after the end of the buffer
- constexpr const_iterator end() const { return data + len; }
+ constexpr const_iterator end() const noexcept { return _data + _len; }
//! Returns an iterator to after the end of the buffer
- constexpr const_iterator cend() const { return data + len; }
+ constexpr const_iterator cend() const noexcept { return _data + _len; }
+ private:
+ friend constexpr inline void _check_iovec_match();
+ pointer _data;
+ size_type _len;
};
//! The gather buffer type used by this handle. Guaranteed to be `TrivialType` and `StandardLayoutType`.
+ //! Try to make address and length 64 byte, or ideally, `page_size()` aligned where possible.
struct const_buffer_type
{
//! Type of the pointer to memory.
using pointer = const byte *;
+ //! Type of the pointer to memory.
+ using const_pointer = const byte *;
//! Type of the iterator to memory.
using iterator = const byte *;
//! Type of the iterator to memory.
@@ -92,23 +116,40 @@ public:
//! Type of the length of memory.
using size_type = size_t;
- //! Pointer to memory to be written. Try to make this 64 byte, or ideally, `page_size()` aligned where possible.
- pointer data;
- //! The number of bytes to write from this address. Try to make this a 64 byte multiple, or ideally, a whole multiple of `page_size()`.
- size_type len;
+ //! Default constructor
+ const_buffer_type() = default;
+ //! Constructor
+ constexpr const_buffer_type(pointer data, size_type len) noexcept : _data(data), _len(len) {}
+ const_buffer_type(const const_buffer_type &) = default;
+ const_buffer_type(const_buffer_type &&) = default;
+ const_buffer_type &operator=(const const_buffer_type &) = default;
+ const_buffer_type &operator=(const_buffer_type &&) = default;
+ ~const_buffer_type() = default;
+
+ // Emulation of this being a span<byte> in the TS
+
+ //! Returns the address of the bytes for this buffer
+ constexpr pointer data() noexcept { return _data; }
+ //! Returns the address of the bytes for this buffer
+ constexpr const_pointer data() const noexcept { return _data; }
+ //! Returns the number of bytes in this buffer
+ constexpr size_type size() const noexcept { return _len; }
//! Returns an iterator to the beginning of the buffer
- constexpr iterator begin() { return data; }
+ constexpr iterator begin() noexcept { return _data; }
//! Returns an iterator to the beginning of the buffer
- constexpr const_iterator begin() const { return data; }
+ constexpr const_iterator begin() const noexcept { return _data; }
//! Returns an iterator to the beginning of the buffer
- constexpr const_iterator cbegin() const { return data; }
+ constexpr const_iterator cbegin() const noexcept { return _data; }
//! Returns an iterator to after the end of the buffer
- constexpr iterator end() { return data + len; }
+ constexpr iterator end() noexcept { return _data + _len; }
//! Returns an iterator to after the end of the buffer
- constexpr const_iterator end() const { return data + len; }
+ constexpr const_iterator end() const noexcept { return _data + _len; }
//! Returns an iterator to after the end of the buffer
- constexpr const_iterator cend() const { return data + len; }
+ constexpr const_iterator cend() const noexcept { return _data + _len; }
+ private:
+ pointer _data;
+ size_type _len;
};
#ifndef NDEBUG
static_assert(std::is_trivial<buffer_type>::value, "buffer_type is not a trivial type!");
@@ -459,11 +500,11 @@ public:
size_t bytes = 0;
for(auto &i : reqs.buffers)
{
- if(bytes + i.len < bytes)
+ if(bytes + i.size() < bytes)
{
return errc::value_too_large;
}
- bytes += i.len;
+ bytes += i.size();
}
return lock(reqs.offset, bytes, false, d);
}
@@ -473,11 +514,11 @@ public:
size_t bytes = 0;
for(auto &i : reqs.buffers)
{
- if(bytes + i.len < bytes)
+ if(bytes + i.size() < bytes)
{
return errc::value_too_large;
}
- bytes += i.len;
+ bytes += i.size();
}
return lock(reqs.offset, bytes, true, d);
}