summaryrefslogtreecommitdiff
path: root/src/exception.cc
diff options
context:
space:
mode:
authorDavid Chisnall <dchisnall@pathscale.com>2012-03-27 19:34:09 +0100
committerDavid Chisnall <dchisnall@pathscale.com>2012-03-27 19:34:09 +0100
commitfb8cc3b07be8677604df8df8e7b270edc2000aef (patch)
tree812f8e4d37b0838e9babb67597cfb6575d3aa816 /src/exception.cc
parentd48277e2a7749bd2555e0b75f30ed33225462429 (diff)
downloadlibcxxrt-fb8cc3b07be8677604df8df8e7b270edc2000aef.tar.gz
libcxxrt-fb8cc3b07be8677604df8df8e7b270edc2000aef.tar.bz2
libcxxrt-fb8cc3b07be8677604df8df8e7b270edc2000aef.tar.xz
Ensure the correct happens-before relationship between set / get
functions. Add the C++11 std::get_new_handler().
Diffstat (limited to 'src/exception.cc')
-rw-r--r--src/exception.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/exception.cc b/src/exception.cc
index fe56297..6e841ef 100644
--- a/src/exception.cc
+++ b/src/exception.cc
@@ -32,6 +32,7 @@
#include <pthread.h>
#include "typeinfo.h"
#include "dwarf_eh.h"
+#include "atomic.h"
#include "cxxabi.h"
#pragma weak pthread_key_create
@@ -1328,7 +1329,7 @@ namespace std
{
if (thread_local_handlers) { return pathscale::set_unexpected(f); }
- return __sync_lock_test_and_set(&unexpectedHandler, f);
+ return ATOMIC_SWAP(&terminateHandler, f);
}
/**
* Sets the function that is called to terminate the program.
@@ -1336,7 +1337,8 @@ namespace std
terminate_handler set_terminate(terminate_handler f) throw()
{
if (thread_local_handlers) { return pathscale::set_terminate(f); }
- return __sync_lock_test_and_set(&terminateHandler, f);
+
+ return ATOMIC_SWAP(&terminateHandler, f);
}
/**
* Terminates the program, calling a custom terminate implementation if
@@ -1390,7 +1392,7 @@ namespace std
{
return info->unexpectedHandler;
}
- return unexpectedHandler;
+ return ATOMIC_LOAD(&unexpectedHandler);
}
/**
* Returns the current terminate handler.
@@ -1402,7 +1404,7 @@ namespace std
{
return info->terminateHandler;
}
- return terminateHandler;
+ return ATOMIC_LOAD(&terminateHandler);
}
}
#ifdef __arm__