[libcxx-commits] [libcxxabi] r358106 - [libc++abi] Create a macro for the 32 bit guard setting on ARM platforms
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Apr 10 10:12:06 PDT 2019
Author: ldionne
Date: Wed Apr 10 10:12:06 2019
New Revision: 358106
URL: http://llvm.org/viewvc/llvm-project?rev=358106&view=rev
Log:
[libc++abi] Create a macro for the 32 bit guard setting on ARM platforms
Summary:
The goal is to use a descriptive name for this feature, instead of just
using __arm__.
Reviewers: EricWF
Subscribers: javed.absar, kristof.beyls, christof, jkorous, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D60520
Modified:
libcxxabi/trunk/include/__cxxabi_config.h
libcxxabi/trunk/include/cxxabi.h
libcxxabi/trunk/src/cxa_guard.cpp
Modified: libcxxabi/trunk/include/__cxxabi_config.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/__cxxabi_config.h?rev=358106&r1=358105&r2=358106&view=diff
==============================================================================
--- libcxxabi/trunk/include/__cxxabi_config.h (original)
+++ libcxxabi/trunk/include/__cxxabi_config.h Wed Apr 10 10:12:06 2019
@@ -69,4 +69,8 @@
#define _LIBCXXABI_NO_CFI
#endif
+#if defined(__arm__)
+# define _LIBCXXABI_GUARD_ABI_ARM
+#endif
+
#endif // ____CXXABI_CONFIG_H
Modified: libcxxabi/trunk/include/cxxabi.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/cxxabi.h?rev=358106&r1=358105&r2=358106&view=diff
==============================================================================
--- libcxxabi/trunk/include/cxxabi.h (original)
+++ libcxxabi/trunk/include/cxxabi.h Wed Apr 10 10:12:06 2019
@@ -77,7 +77,7 @@ extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NO
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
// 3.3.2 One-time Construction API
-#ifdef __arm__
+#if defined(_LIBCXXABI_GUARD_ABI_ARM)
extern _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(uint32_t *);
extern _LIBCXXABI_FUNC_VIS void __cxa_guard_release(uint32_t *);
extern _LIBCXXABI_FUNC_VIS void __cxa_guard_abort(uint32_t *);
Modified: libcxxabi/trunk/src/cxa_guard.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_guard.cpp?rev=358106&r1=358105&r2=358106&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_guard.cpp (original)
+++ libcxxabi/trunk/src/cxa_guard.cpp Wed Apr 10 10:12:06 2019
@@ -35,7 +35,7 @@ enum InitializationResult {
INIT_NOT_COMPLETE,
};
-#ifdef __arm__
+#if defined(_LIBCXXABI_GUARD_ABI_ARM)
// A 32-bit, 4-byte-aligned static data value. The least significant 2 bits must
// be statically initialized to 0.
typedef uint32_t guard_type;
@@ -44,7 +44,7 @@ typedef uint64_t guard_type;
#endif
#if !defined(_LIBCXXABI_HAS_NO_THREADS) && defined(__APPLE__) && \
- !defined(__arm__)
+ !defined(_LIBCXXABI_GUARD_ABI_ARM)
// This is a special-case pthread dependency for Mac. We can't pull this
// out into libcxx's threading API (__threading_support) because not all
// supported Mac environments provide this function (in pthread.h). To
@@ -239,7 +239,7 @@ GuardValue GuardValue::ZERO() { return G
GuardValue GuardValue::INIT_COMPLETE() {
guard_type value = {0};
-#ifdef __arm__
+#if defined(_LIBCXXABI_GUARD_ABI_ARM)
value |= 1;
#else
char* init_bit = (char*)&value;
@@ -253,7 +253,7 @@ GuardValue GuardValue::INIT_PENDING() {
}
bool GuardValue::is_initialization_complete() const {
-#ifdef __arm__
+#if defined(_LIBCXXABI_GUARD_ABI_ARM)
return value & 1;
#else
const char* init_bit = (const char*)&value;
@@ -271,31 +271,31 @@ lock_type GuardValue::get_lock_value() c
// Create a guard object with the lock set to the specified value.
guard_type GuardValue::guard_value_from_lock(lock_type l) {
-#if defined(__APPLE__) && !defined(__arm__)
+#if defined(__APPLE__) && !defined(_LIBCXXABI_GUARD_ABI_ARM)
#if __LITTLE_ENDIAN__
return static_cast<guard_type>(l) << 32;
#else
return static_cast<guard_type>(l);
#endif
-#else // defined(__APPLE__) && !defined(__arm__)
+#else // defined(__APPLE__) && !defined(_LIBCXXABI_GUARD_ABI_ARM)
guard_type f = {0};
memcpy(static_cast<char*>(static_cast<void*>(&f)) + 1, &l, sizeof(lock_type));
return f;
-#endif // defined(__APPLE__) && !defined(__arm__)
+#endif // defined(__APPLE__) && !defined(_LIBCXXABI_GUARD_ABI_ARM)
}
lock_type GuardValue::lock_value_from_guard(guard_type g) {
-#if defined(__APPLE__) && !defined(__arm__)
+#if defined(__APPLE__) && !defined(_LIBCXXABI_GUARD_ABI_ARM)
#if __LITTLE_ENDIAN__
return static_cast<lock_type>(g >> 32);
#else
return static_cast<lock_type>(g);
#endif
-#else // defined(__APPLE__) && !defined(__arm__)
+#else // defined(__APPLE__) && !defined(_LIBCXXABI_GUARD_ABI_ARM)
uint8_t guard_bytes[sizeof(guard_type)];
memcpy(&guard_bytes, &g, sizeof(guard_type));
return guard_bytes[1] != 0;
-#endif // defined(__APPLE__) && !defined(__arm__)
+#endif // defined(__APPLE__) && !defined(_LIBCXXABI_GUARD_ABI_ARM)
}
} // __cxxabiv1
More information about the libcxx-commits
mailing list