summaryrefslogtreecommitdiffstats
path: root/libcxxabi
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-04-08 23:37:48 +0000
committerEric Fiselier <eric@efcs.ca>2019-04-08 23:37:48 +0000
commitaa10ca12686ed253af47553e80e99f5874a08724 (patch)
treed5b3733a92e4aa1673323df73ffd6f4ffd453bab /libcxxabi
parent806d5741aa7f52746eebd25f1cf60b12ca56ef35 (diff)
downloadbcm5719-llvm-aa10ca12686ed253af47553e80e99f5874a08724.tar.gz
bcm5719-llvm-aa10ca12686ed253af47553e80e99f5874a08724.zip
Revert "Make reads and writes of the guard variable atomic."
This reverts commit r357944 and r357949. These changes failed to account for the fact that the guard object is under aligned for atomic operations on 32 bit platforms (It's aligned to 4 bytes but we require 8). llvm-svn: 357958
Diffstat (limited to 'libcxxabi')
-rw-r--r--libcxxabi/src/cxa_guard.cpp52
1 files changed, 19 insertions, 33 deletions
diff --git a/libcxxabi/src/cxa_guard.cpp b/libcxxabi/src/cxa_guard.cpp
index 7c85d8ae294..e606665acc8 100644
--- a/libcxxabi/src/cxa_guard.cpp
+++ b/libcxxabi/src/cxa_guard.cpp
@@ -9,7 +9,6 @@
#include "__cxxabi_config.h"
#include "abort_message.h"
-#include "include/atomic_support.h"
#include <__threading_support>
#include <stdint.h>
@@ -156,18 +155,13 @@ private:
struct GuardObject {
explicit GuardObject(guard_type *g) : guard(g) {}
- /// Load the current value from the guard object.
- GuardValue load() const;
+ // Read the current value of the guard object.
+ // TODO: Make this read atomic.
+ GuardValue read() const;
- /// Store the specified value in the guard object.
- void store(GuardValue new_val);
-
- /// Store the specified value in the guard object and return the previous value.
- GuardValue exchange(GuardValue new_val);
-
- /// Perform a atomic compare and exchange operation. Return true if
- // desired is written to the guard object.
- bool compare_exchange(GuardValue *expected, GuardValue desired);
+ // Write the specified value to the guard object.
+ // TODO: Make this atomic
+ void write(GuardValue new_val);
private:
GuardObject(const GuardObject&) = delete;
@@ -184,7 +178,7 @@ extern "C"
_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type* raw_guard_object) {
GlobalMutexGuard gmutex("__cxa_guard_acquire", OnRelease::UNLOCK);
GuardObject guard(raw_guard_object);
- GuardValue current_value = guard.load();
+ GuardValue current_value = guard.read();
if (current_value.is_initialization_complete())
return INIT_COMPLETE;
@@ -198,12 +192,12 @@ _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type* raw_guard_object) {
#endif
while (current_value.is_initialization_pending()) {
gmutex.wait_for_signal();
- current_value = guard.load();
+ current_value = guard.read();
}
if (current_value.is_initialization_complete())
return INIT_COMPLETE;
- guard.store(LOCK_ID);
+ guard.write(LOCK_ID);
return INIT_NOT_COMPLETE;
}
@@ -211,13 +205,14 @@ _LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *raw_guard_object) {
GlobalMutexGuard gmutex("__cxa_guard_release",
OnRelease::UNLOCK_AND_BROADCAST);
GuardObject guard(raw_guard_object);
- guard.store(GuardValue::INIT_COMPLETE());
+ guard.write(GuardValue::ZERO());
+ guard.write(GuardValue::INIT_COMPLETE());
}
_LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *raw_guard_object) {
GlobalMutexGuard gmutex("__cxa_guard_abort", OnRelease::UNLOCK_AND_BROADCAST);
GuardObject guard(raw_guard_object);
- guard.store(GuardValue::ZERO());
+ guard.write(GuardValue::ZERO());
}
} // extern "C"
@@ -225,26 +220,17 @@ _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *raw_guard_object) {
// GuardObject Definitions
//===----------------------------------------------------------------------===//
-GuardValue GuardObject::load() const {
- return GuardValue(std::__libcpp_atomic_load(guard));
-}
-
-void GuardObject::store(GuardValue new_val) {
- std::__libcpp_atomic_store(guard, new_val.value);
+GuardValue GuardObject::read() const {
+ // FIXME: Make this atomic
+ guard_type val = *guard;
+ return GuardValue(val);
}
-GuardValue GuardObject::exchange(GuardValue new_val) {
- return GuardValue(
- std::__libcpp_atomic_exchange(guard, new_val.value, std::_AO_Acq_Rel));
+void GuardObject::write(GuardValue new_val) {
+ // FIXME: make this atomic
+ *guard = new_val.value;
}
-bool GuardObject::compare_exchange(GuardValue* expected,
- GuardValue desired) {
- return std::__libcpp_atomic_compare_exchange(guard, &expected->value, desired.value,
- std::_AO_Acq_Rel, std::_AO_Acquire);
-}
-
-
//===----------------------------------------------------------------------===//
// GuardValue Definitions
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud