[libcxx-commits] [libcxxabi] f8b1cc3 - [libc++abi] Remove unnecessary atomic_support.h header from libc++abi

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 21 16:55:30 PDT 2021


Author: Louis Dionne
Date: 2021-09-21T19:55:21-04:00
New Revision: f8b1cc36578608f2f840d7ea8b0aa9b28fdaa492

URL: https://github.com/llvm/llvm-project/commit/f8b1cc36578608f2f840d7ea8b0aa9b28fdaa492
DIFF: https://github.com/llvm/llvm-project/commit/f8b1cc36578608f2f840d7ea8b0aa9b28fdaa492.diff

LOG: [libc++abi] Remove unnecessary atomic_support.h header from libc++abi

The file was a duplicate of atomic_support.h in libc++. Since we now
require the libc++ sources in order to build libc++abi, it's OK to
remove this duplication.

Thanks to @chandlerc for noticing this.

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

Added: 
    

Modified: 
    libcxx/src/include/atomic_support.h
    libcxxabi/src/CMakeLists.txt
    libcxxabi/src/cxa_default_handlers.cpp
    libcxxabi/src/cxa_exception.cpp
    libcxxabi/src/cxa_guard_impl.h
    libcxxabi/src/cxa_handlers.cpp
    libcxxabi/src/stdlib_stdexcept.cpp
    libcxxabi/test/libcxxabi/test/config.py

Removed: 
    libcxxabi/src/include/atomic_support.h


################################################################################
diff  --git a/libcxx/src/include/atomic_support.h b/libcxx/src/include/atomic_support.h
index c143df11c05f7..5a745a2f0091c 100644
--- a/libcxx/src/include/atomic_support.h
+++ b/libcxx/src/include/atomic_support.h
@@ -146,7 +146,7 @@ _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
 template <class _ValueType>
 inline _LIBCPP_INLINE_VISIBILITY
 _ValueType __libcpp_atomic_exchange(_ValueType* __target,
-                                    _ValueType __value, int __order = _AO_Seq)
+                                    _ValueType __value, int = _AO_Seq)
 {
     _ValueType old = *__target;
     *__target = __value;

diff  --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index f6a452af3f501..94182dccba5e3 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -56,8 +56,8 @@ if (MSVC_IDE OR XCODE)
   endif()
 endif()
 
-# stdlib_stdexcept.cpp depends on libc++ internals.
-include_directories("${LIBCXXABI_LIBCXX_PATH}")
+# Some files depend on libc++ internals.
+include_directories("${LIBCXXABI_LIBCXX_PATH}/src")
 
 if (LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL)
   add_definitions(-DHAVE___CXA_THREAD_ATEXIT_IMPL)

diff  --git a/libcxxabi/src/cxa_default_handlers.cpp b/libcxxabi/src/cxa_default_handlers.cpp
index c059a653d4512..8f9b2533b6a20 100644
--- a/libcxxabi/src/cxa_default_handlers.cpp
+++ b/libcxxabi/src/cxa_default_handlers.cpp
@@ -15,7 +15,7 @@
 #include "cxa_handlers.h"
 #include "cxa_exception.h"
 #include "private_typeinfo.h"
-#include "include/atomic_support.h"
+#include "include/atomic_support.h" // from libc++
 
 #if !defined(LIBCXXABI_SILENT_TERMINATE)
 

diff  --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp
index 510827a37bb74..35956f197f59d 100644
--- a/libcxxabi/src/cxa_exception.cpp
+++ b/libcxxabi/src/cxa_exception.cpp
@@ -17,7 +17,7 @@
 #include "cxa_exception.h"
 #include "cxa_handlers.h"
 #include "fallback_malloc.h"
-#include "include/atomic_support.h"
+#include "include/atomic_support.h" // from libc++
 
 #if __has_feature(address_sanitizer)
 #include <sanitizer/asan_interface.h>

diff  --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h
index 80feaa148983b..9d519bfc9f9fb 100644
--- a/libcxxabi/src/cxa_guard_impl.h
+++ b/libcxxabi/src/cxa_guard_impl.h
@@ -38,7 +38,7 @@
  */
 
 #include "__cxxabi_config.h"
-#include "include/atomic_support.h"
+#include "include/atomic_support.h" // from libc++
 #include <unistd.h>
 #if defined(__has_include)
 #  if __has_include(<sys/syscall.h>)

diff  --git a/libcxxabi/src/cxa_handlers.cpp b/libcxxabi/src/cxa_handlers.cpp
index bcaf4f1f6f0d7..d022752e12e66 100644
--- a/libcxxabi/src/cxa_handlers.cpp
+++ b/libcxxabi/src/cxa_handlers.cpp
@@ -17,7 +17,7 @@
 #include "cxa_handlers.h"
 #include "cxa_exception.h"
 #include "private_typeinfo.h"
-#include "include/atomic_support.h"
+#include "include/atomic_support.h" // from libc++
 
 namespace std
 {

diff  --git a/libcxxabi/src/include/atomic_support.h b/libcxxabi/src/include/atomic_support.h
deleted file mode 100644
index bd9e73c738330..0000000000000
--- a/libcxxabi/src/include/atomic_support.h
+++ /dev/null
@@ -1,180 +0,0 @@
-//===----------------------------------------------------------------------===////
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===////
-
-// FIXME: This file is copied from libcxx/src/include/atomic_support.h. Instead
-// of duplicating the file in libc++abi we should require that the libc++
-// sources are available when building libc++abi.
-
-#ifndef ATOMIC_SUPPORT_H
-#define ATOMIC_SUPPORT_H
-
-#include "__config"
-#include "memory" // for __libcpp_relaxed_load
-
-#if defined(__clang__) && __has_builtin(__atomic_load_n)             \
-                       && __has_builtin(__atomic_store_n)            \
-                       && __has_builtin(__atomic_add_fetch)          \
-                       && __has_builtin(__atomic_exchange_n)         \
-                       && __has_builtin(__atomic_compare_exchange_n) \
-                       && defined(__ATOMIC_RELAXED)                  \
-                       && defined(__ATOMIC_CONSUME)                  \
-                       && defined(__ATOMIC_ACQUIRE)                  \
-                       && defined(__ATOMIC_RELEASE)                  \
-                       && defined(__ATOMIC_ACQ_REL)                  \
-                       && defined(__ATOMIC_SEQ_CST)
-#   define _LIBCXXABI_HAS_ATOMIC_BUILTINS
-#elif defined(_LIBCPP_COMPILER_GCC)
-#   define _LIBCXXABI_HAS_ATOMIC_BUILTINS
-#endif
-
-#if !defined(_LIBCXXABI_HAS_ATOMIC_BUILTINS) && !defined(_LIBCXXABI_HAS_NO_THREADS)
-# if defined(_LIBCPP_WARNING)
-    _LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
-# else
-#   warning Building libc++ without __atomic builtins is unsupported
-# endif
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-namespace {
-
-#if defined(_LIBCXXABI_HAS_ATOMIC_BUILTINS) && !defined(_LIBCXXABI_HAS_NO_THREADS)
-
-enum __libcpp_atomic_order {
-    _AO_Relaxed = __ATOMIC_RELAXED,
-    _AO_Consume = __ATOMIC_CONSUME,
-    _AO_Acquire = __ATOMIC_ACQUIRE,
-    _AO_Release = __ATOMIC_RELEASE,
-    _AO_Acq_Rel = __ATOMIC_ACQ_REL,
-    _AO_Seq     = __ATOMIC_SEQ_CST
-};
-
-template <class _ValueType, class _FromType>
-inline _LIBCPP_INLINE_VISIBILITY
-void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
-                           int __order = _AO_Seq)
-{
-    __atomic_store_n(__dest, __val, __order);
-}
-
-template <class _ValueType, class _FromType>
-inline _LIBCPP_INLINE_VISIBILITY
-void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
-{
-    __atomic_store_n(__dest, __val, _AO_Relaxed);
-}
-
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_atomic_load(_ValueType const* __val,
-                                int __order = _AO_Seq)
-{
-    return __atomic_load_n(__val, __order);
-}
-
-template <class _ValueType, class _AddType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
-                               int __order = _AO_Seq)
-{
-    return __atomic_add_fetch(__val, __a, __order);
-}
-
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_atomic_exchange(_ValueType* __target,
-                                    _ValueType __value, int __order = _AO_Seq)
-{
-    return __atomic_exchange_n(__target, __value, __order);
-}
-
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-bool __libcpp_atomic_compare_exchange(_ValueType* __val,
-    _ValueType* __expected, _ValueType __after,
-    int __success_order = _AO_Seq,
-    int __fail_order = _AO_Seq)
-{
-    return __atomic_compare_exchange_n(__val, __expected, __after, true,
-                                       __success_order, __fail_order);
-}
-
-#else // _LIBCPP_HAS_NO_THREADS
-
-enum __libcpp_atomic_order {
-    _AO_Relaxed,
-    _AO_Consume,
-    _AO_Acquire,
-    _AO_Release,
-    _AO_Acq_Rel,
-    _AO_Seq
-};
-
-template <class _ValueType, class _FromType>
-inline _LIBCPP_INLINE_VISIBILITY
-void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
-                           int = 0)
-{
-    *__dest = __val;
-}
-
-template <class _ValueType, class _FromType>
-inline _LIBCPP_INLINE_VISIBILITY
-void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
-{
-    *__dest = __val;
-}
-
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_atomic_load(_ValueType const* __val,
-                                int = 0)
-{
-    return *__val;
-}
-
-template <class _ValueType, class _AddType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
-                               int = 0)
-{
-    return *__val += __a;
-}
-
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-_ValueType __libcpp_atomic_exchange(_ValueType* __target,
-                                    _ValueType __value, int  = _AO_Seq)
-{
-    _ValueType old = *__target;
-    *__target = __value;
-    return old;
-}
-
-template <class _ValueType>
-inline _LIBCPP_INLINE_VISIBILITY
-bool __libcpp_atomic_compare_exchange(_ValueType* __val,
-    _ValueType* __expected, _ValueType __after,
-    int = 0, int = 0)
-{
-    if (*__val == *__expected) {
-        *__val = __after;
-        return true;
-    }
-    *__expected = *__val;
-    return false;
-}
-
-#endif // _LIBCPP_HAS_NO_THREADS
-
-} // end namespace
-
-_LIBCPP_END_NAMESPACE_STD
-
-#endif // ATOMIC_SUPPORT_H

diff  --git a/libcxxabi/src/stdlib_stdexcept.cpp b/libcxxabi/src/stdlib_stdexcept.cpp
index 0ca378dcde011..3e74db34d0ba9 100644
--- a/libcxxabi/src/stdlib_stdexcept.cpp
+++ b/libcxxabi/src/stdlib_stdexcept.cpp
@@ -12,9 +12,7 @@
 #include <cstring>
 #include <cstdint>
 #include <cstddef>
-
-// This includes an implementation file from libc++.
-#include "src/include/refstring.h"
+#include "include/refstring.h" // from libc++
 
 static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
 

diff  --git a/libcxxabi/test/libcxxabi/test/config.py b/libcxxabi/test/libcxxabi/test/config.py
index f44892be06f4b..843441fbebb8a 100644
--- a/libcxxabi/test/libcxxabi/test/config.py
+++ b/libcxxabi/test/libcxxabi/test/config.py
@@ -72,6 +72,7 @@ def configure_compile_flags_header_includes(self):
             if os.path.isdir(cxx_target_headers):
                 self.cxx.compile_flags += ['-I' + cxx_target_headers]
         self.cxx.compile_flags += ['-I' + cxx_headers]
+        self.cxx.compile_flags += ['-I' + os.path.join(self.libcxx_src_root, 'src')]
 
         libcxxabi_headers = self.get_lit_conf(
             'libcxxabi_headers',


        


More information about the libcxx-commits mailing list