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-09-16 19:08:59 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2021-09-16 19:08:59 +0300
commitca32e1c25908866b277f5332bb308f23de54e187 (patch)
tree9746cb2f5217a29ae07c4db3b6ddf882c8fb9964
parentac83bef9d7bc6e31e8487e2f8e01ea63269dc4f9 (diff)
Fix last two commits by using volatile to prevent dead store elimination.
-rw-r--r--include/llfio/v2.0/detail/impl/map_handle.ipp20
1 files changed, 18 insertions, 2 deletions
diff --git a/include/llfio/v2.0/detail/impl/map_handle.ipp b/include/llfio/v2.0/detail/impl/map_handle.ipp
index 46fc46c8..e03587a7 100644
--- a/include/llfio/v2.0/detail/impl/map_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/map_handle.ipp
@@ -173,8 +173,24 @@ namespace detail
};
extern inline QUICKCPPLIB_SYMBOL_VISIBLE map_handle_cache_t *map_handle_cache()
{
- static auto v = std::make_unique<map_handle_cache_t>();
- return v.get();
+ static struct _
+ {
+ map_handle_cache_t *v;
+ _()
+ : v(new map_handle_cache_t)
+ {
+ }
+ ~_()
+ {
+ if(v != nullptr)
+ {
+ auto *r = v;
+ *(volatile map_handle_cache_t **) &v = nullptr;
+ delete r;
+ }
+ }
+ } v;
+ return v.v;
}
} // namespace detail