summaryrefslogtreecommitdiffstats
path: root/lib/libcxx/src/shared_mutex.cpp
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2021-01-11 15:31:56 +0000
committerpatrick <patrick@openbsd.org>2021-01-11 15:31:56 +0000
commit16ff81ed8b1ed9aa06fb1a731a2446b66cc49bef (patch)
tree1a7dd8152b94f6f8cd318bfaf85aa40882854583 /lib/libcxx/src/shared_mutex.cpp
parentsync (diff)
downloadwireguard-openbsd-16ff81ed8b1ed9aa06fb1a731a2446b66cc49bef.tar.xz
wireguard-openbsd-16ff81ed8b1ed9aa06fb1a731a2446b66cc49bef.zip
Remove libc++ and libc++abi 8.0.0 now that we switched to version 10.0.1
in the gnu/ directory.
Diffstat (limited to 'lib/libcxx/src/shared_mutex.cpp')
-rw-r--r--lib/libcxx/src/shared_mutex.cpp116
1 files changed, 0 insertions, 116 deletions
diff --git a/lib/libcxx/src/shared_mutex.cpp b/lib/libcxx/src/shared_mutex.cpp
deleted file mode 100644
index 6185f15deab..00000000000
--- a/lib/libcxx/src/shared_mutex.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-//===---------------------- shared_mutex.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "__config"
-#ifndef _LIBCPP_HAS_NO_THREADS
-
-#include "shared_mutex"
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-// Shared Mutex Base
-__shared_mutex_base::__shared_mutex_base()
- : __state_(0)
-{
-}
-
-// Exclusive ownership
-
-void
-__shared_mutex_base::lock()
-{
- unique_lock<mutex> lk(__mut_);
- while (__state_ & __write_entered_)
- __gate1_.wait(lk);
- __state_ |= __write_entered_;
- while (__state_ & __n_readers_)
- __gate2_.wait(lk);
-}
-
-bool
-__shared_mutex_base::try_lock()
-{
- unique_lock<mutex> lk(__mut_);
- if (__state_ == 0)
- {
- __state_ = __write_entered_;
- return true;
- }
- return false;
-}
-
-void
-__shared_mutex_base::unlock()
-{
- lock_guard<mutex> _(__mut_);
- __state_ = 0;
- __gate1_.notify_all();
-}
-
-// Shared ownership
-
-void
-__shared_mutex_base::lock_shared()
-{
- unique_lock<mutex> lk(__mut_);
- while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
- __gate1_.wait(lk);
- unsigned num_readers = (__state_ & __n_readers_) + 1;
- __state_ &= ~__n_readers_;
- __state_ |= num_readers;
-}
-
-bool
-__shared_mutex_base::try_lock_shared()
-{
- unique_lock<mutex> lk(__mut_);
- unsigned num_readers = __state_ & __n_readers_;
- if (!(__state_ & __write_entered_) && num_readers != __n_readers_)
- {
- ++num_readers;
- __state_ &= ~__n_readers_;
- __state_ |= num_readers;
- return true;
- }
- return false;
-}
-
-void
-__shared_mutex_base::unlock_shared()
-{
- lock_guard<mutex> _(__mut_);
- unsigned num_readers = (__state_ & __n_readers_) - 1;
- __state_ &= ~__n_readers_;
- __state_ |= num_readers;
- if (__state_ & __write_entered_)
- {
- if (num_readers == 0)
- __gate2_.notify_one();
- }
- else
- {
- if (num_readers == __n_readers_ - 1)
- __gate1_.notify_one();
- }
-}
-
-
-// Shared Timed Mutex
-// These routines are here for ABI stability
-shared_timed_mutex::shared_timed_mutex() : __base() {}
-void shared_timed_mutex::lock() { return __base.lock(); }
-bool shared_timed_mutex::try_lock() { return __base.try_lock(); }
-void shared_timed_mutex::unlock() { return __base.unlock(); }
-void shared_timed_mutex::lock_shared() { return __base.lock_shared(); }
-bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); }
-void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); }
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // !_LIBCPP_HAS_NO_THREADS