Permalink
Browse files

Use __sync_swap when available.

  • Loading branch information...
1 parent 04a6546 commit c7d66e279e31c0523bcb8bc5b1dd5c98260f0848 David Chisnall committed Nov 24, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/memory.cc
View
@@ -11,6 +11,10 @@
#include <stdlib.h>
#include "stdexcept.h"
+#if !__has_builtin(__sync_swap)
+#define __sync_swap __sync_lock_test_and_set
+#endif
+
namespace std
{
struct nothrow_t {};
@@ -33,7 +37,7 @@ namespace std
__attribute__((weak))
new_handler set_new_handler(new_handler handler)
{
- return __sync_lock_test_and_set(&new_handl, handler);
+ return __sync_swap(&new_handl, handler);
}
}

0 comments on commit c7d66e2

Please sign in to comment.