Skip to content

Commit

Permalink
Remove map_view<T>, as attached<T> has supplanted it. This bring LLFI…
Browse files Browse the repository at this point in the history
…O up to date with P1031R2.
  • Loading branch information
ned14 committed May 26, 2019
1 parent 19115c0 commit 14d5c7f
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 108 deletions.
1 change: 0 additions & 1 deletion cmake/headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ set(llfio_HEADERS
"include/llfio/v2.0/llfio.hpp"
"include/llfio/v2.0/logging.hpp"
"include/llfio/v2.0/map_handle.hpp"
"include/llfio/v2.0/map_view.hpp"
"include/llfio/v2.0/mapped.hpp"
"include/llfio/v2.0/mapped_file_handle.hpp"
"include/llfio/v2.0/native_handle_type.hpp"
Expand Down
4 changes: 2 additions & 2 deletions example/use_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void malloc1()
mh.do_not_store({mh.address(), mh.length()}).value();

// Fill the memory with 'b' C++ style, probably faulting new pages into existence
llfio::map_view<char> p2(mh);
llfio::attached<char> p2(mh);
std::fill(p2.begin(), p2.end(), 'b');

// Kick the contents of the memory out to the swap file so it is no longer cached in RAM
Expand Down Expand Up @@ -380,7 +380,7 @@ void sparse_array()
(void) mfh.truncate(1000000000000ULL * sizeof(int));

// Create a typed view of the one trillion integers
llfio::map_view<int> one_trillion_int_array(mfh);
llfio::attached<int> one_trillion_int_array(mfh);

// Write and read as you see fit, if you exceed physical RAM it'll be paged out
one_trillion_int_array[0] = 5;
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 d9720b3670a8d481f202842d973f82b360a467e3
#define LLFIO_PREVIOUS_COMMIT_DATE "2019-05-24 19:26:26 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE d9720b36
#define LLFIO_PREVIOUS_COMMIT_REF 19115c0eb238e6ab5e159c246d88ff551b134e9c
#define LLFIO_PREVIOUS_COMMIT_DATE "2019-05-24 19:51:21 +00:00"
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 19115c0e
4 changes: 2 additions & 2 deletions include/llfio/v2.0/detail/impl/posix/path_discovery.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Distributed under the Boost Software License, Version 1.0.
#error Must be included by ../path_discovery.ipp only
#endif

#include "../../../map_view.hpp"
#include "../../../mapped_file_handle.hpp"

#include <pwd.h>

Expand Down Expand Up @@ -77,7 +77,7 @@ namespace path_discovery
}
else
{
map_view<const char> passwd(_passwdh.value());
attached<const char> passwd(_passwdh.value());
/* This will consist of lines of the form:
jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8910,(234)555-0044,email:/home/jsmith:/bin/sh
Expand Down
2 changes: 1 addition & 1 deletion include/llfio/v2.0/llfio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import LLFIO_MODULE_NAME;
#include "file_handle.hpp"
#endif
#include "directory_handle.hpp"
#include "map_view.hpp"
#include "mapped.hpp"
#include "statfs.hpp"
#ifndef LLFIO_LEAN_AND_MEAN
#include "storage_profile.hpp"
Expand Down
87 changes: 0 additions & 87 deletions include/llfio/v2.0/map_view.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion include/llfio/v2.0/outcome
2 changes: 1 addition & 1 deletion include/llfio/v2.0/quickcpplib
2 changes: 1 addition & 1 deletion test/kerneltest
18 changes: 9 additions & 9 deletions test/tests/mapped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,27 @@ static inline void TestMappedView2()
byte *addr = mfh.address();
BOOST_CHECK(addr != nullptr);

map_view<int> v1(mfh);
attached<int> v1(mfh);
BOOST_CHECK(v1.size() == 10000);
v1[0] = 78;
v1[9999] = 79;
mfh.truncate(20000 * sizeof(int)).value();
BOOST_CHECK(addr == mfh.address());
BOOST_CHECK(mfh.maximum_extent().value() == 20000 * sizeof(int));
BOOST_CHECK(mfh.underlying_file_maximum_extent().value() == 20000 * sizeof(int));
v1 = map_view<int>(mfh);
v1 = attached<int>(mfh);
BOOST_CHECK(v1.size() == 20000);
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
mfh.truncate(2 * 1024 * 1024).value(); // exceed reservation, cause hidden reserve
BOOST_CHECK(addr != nullptr);
v1 = map_view<int>(mfh);
v1 = attached<int>(mfh);
BOOST_CHECK(v1.size() == 2 * 1024 * 1024 / sizeof(int));
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
mfh.reserve(2 * 1024 * 1024).value();
BOOST_CHECK(mfh.address() != nullptr);
v1 = map_view<int>(mfh);
v1 = attached<int>(mfh);
BOOST_CHECK(v1.size() == 2 * 1024 * 1024 / sizeof(int));
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
Expand All @@ -111,20 +111,20 @@ static inline void TestMappedView2()
#endif
mfh.truncate(1 * sizeof(int)).value();
BOOST_CHECK(mfh.address() != nullptr);
v1 = map_view<int>(mfh);
v1 = attached<int>(mfh);
BOOST_CHECK(v1.size() == 1);
BOOST_CHECK(v1[0] == 78);

// Use a different handle to extend the file
mapped_file_handle mfh2 = mapped_file_handle::mapped_file(1024 * 1024, {}, "testfile", file_handle::mode::write, file_handle::creation::open_existing, file_handle::caching::all, file_handle::flag::unlink_on_first_close).value();
mfh2.truncate(10000 * sizeof(int)).value();
v1 = map_view<int>(mfh2);
v1 = attached<int>(mfh2);
BOOST_CHECK(v1.size() == 10000);
v1[0] = 78;
v1[9999] = 79;
// On Windows this will have updated the mapping, on POSIX it will not, so prod POSIX
mfh.update_map().value();
v1 = map_view<int>(mfh);
v1 = attached<int>(mfh);
BOOST_CHECK(v1.size() == 10000);
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 79);
Expand All @@ -137,7 +137,7 @@ static inline void TestMappedView2()
fh.truncate(10000 * sizeof(int)).value();
// On POSIX this will have updated the mapping, on Windows it will not, so prod Windows
mfh.update_map().value();
v1 = map_view<int>(mfh);
v1 = attached<int>(mfh);
BOOST_REQUIRE(v1.size() == 10000);
BOOST_CHECK(v1[0] == 78);
BOOST_CHECK(v1[9999] == 0);
Expand All @@ -147,4 +147,4 @@ static inline void TestMappedView2()
}

KERNELTEST_TEST_KERNEL(integration, llfio, algorithm, mapped_span1, "Tests that llfio::mapped works as expected", TestMappedView1())
KERNELTEST_TEST_KERNEL(integration, llfio, algorithm, mapped_span2, "Tests that llfio::map_view works as expected", TestMappedView2())
KERNELTEST_TEST_KERNEL(integration, llfio, algorithm, mapped_span2, "Tests that llfio::attached works as expected", TestMappedView2())

0 comments on commit 14d5c7f

Please sign in to comment.