Files
android_external_libcxx/src/support/runtime/new_handler_fallback.ipp
Weiming Zhao 880dc47f37 [libc++] Refactoring __sync_* builtins; NFC (Reland)
Summary: Wrap __sync_* builtins with __libcpp_ functions to facility future customizations as atomic operations are unavailable on some targets.

Reviewers: danalbert, EricWF, jroelofs

Subscribers: joerg, llvm-commits

Differential Revision: https://reviews.llvm.org/D34918

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@307595 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10 21:37:35 +00:00

30 lines
753 B
C++

// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 <__atomic_support>
namespace std {
_LIBCPP_SAFE_STATIC static std::new_handler __new_handler;
new_handler
set_new_handler(new_handler handler) _NOEXCEPT
{
return __libcpp_sync_lock_test_and_set(&__new_handler, handler);
}
new_handler
get_new_handler() _NOEXCEPT
{
return __libcpp_sync_fetch_and_add<new_handler>(&__new_handler, nullptr);
}
} // namespace std