summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Dionne <ldionne@apple.com>2021-06-09 21:17:55 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-06-09 21:17:55 +0000
commit2396b288e60080a69528bb4c9ca48bf04bacd3f0 (patch)
tree8dcb9a84d178b5b75af6beea5764ab5448a79294
parentd3399eedf5afd156dce113c6c704388b1390f5a2 (diff)
parent14521dcdcb4b620b8420fb64a7a824867bc04cac (diff)
downloadlibcxxabi-2396b288e60080a69528bb4c9ca48bf04bacd3f0.tar.gz
[libc++abi] Create a macro for the 32 bit guard setting on ARM platforms am: c1d35c578d am: ad17909428 am: f63c9a0b70 am: 14521dcdcb
Original change: https://android-review.googlesource.com/c/platform/external/libcxxabi/+/1727434 Change-Id: I40e078a3a14aee610c6a7e03d345851e73577414
-rw-r--r--include/__cxxabi_config.h4
-rw-r--r--include/cxxabi.h2
-rw-r--r--src/cxa_guard.cpp20
3 files changed, 15 insertions, 11 deletions
diff --git a/include/__cxxabi_config.h b/include/__cxxabi_config.h
index 46f5914..1f60167 100644
--- a/include/__cxxabi_config.h
+++ b/include/__cxxabi_config.h
@@ -70,4 +70,8 @@
#define _LIBCXXABI_NO_CFI
#endif
+#if defined(__arm__)
+# define _LIBCXXABI_GUARD_ABI_ARM
+#endif
+
#endif // ____CXXABI_CONFIG_H
diff --git a/include/cxxabi.h b/include/cxxabi.h
index c6724ad..2926081 100644
--- a/include/cxxabi.h
+++ b/include/cxxabi.h
@@ -78,7 +78,7 @@ extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
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 *);
diff --git a/src/cxa_guard.cpp b/src/cxa_guard.cpp
index 8803415..9ae9e70 100644
--- a/src/cxa_guard.cpp
+++ b/src/cxa_guard.cpp
@@ -36,7 +36,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;
@@ -45,7 +45,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
@@ -240,7 +240,7 @@ GuardValue GuardValue::ZERO() { return GuardValue(0); }
GuardValue GuardValue::INIT_COMPLETE() {
guard_type value = {0};
-#ifdef __arm__
+#if defined(_LIBCXXABI_GUARD_ABI_ARM)
value |= 1;
#else
char* init_bit = (char*)&value;
@@ -254,7 +254,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;
@@ -272,31 +272,31 @@ lock_type GuardValue::get_lock_value() const {
// 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