libxx : Fix C++ __guard implementation for ARM.
The standard C++ ABI that most platforms follow defines __guard to be 64 bits.
The existing implementation of libxx_cxa_guard.cxx follows this.
However, the 32-bit __guard is required by ARM
Back ported from NuttX.
// Private Types
//***************************************************************************
+#ifdef __ARM_EABI__
+// The 32-bit ARM C++ ABI specifies that the guard is a 32-bit
+// variable and the least significant bit contains 0 prior to
+// initialization, and 1 after.
+
+typedef int __guard;
+
+#else
+// The "standard" C++ ABI specifies that the guard is a 64-bit
+// variable and the first byte contains 0 prior to initialization, and
+// 1 after.
+
__extension__ typedef int __guard __attribute__((mode(__DI__)));
+#endif
//***************************************************************************
// Private Data
@@ -82,7 +95,11 @@ extern "C"
int __cxa_guard_acquire(FAR __guard *g)
{
- return !*g;
+#ifdef __ARM_EABI__
+ return !(*g & 1);
+#else
+ return !*(char *)g;
+#endif
}
//*************************************************************************
@@ -91,7 +108,11 @@ extern "C"
void __cxa_guard_release(FAR __guard *g)
{
+#ifdef __ARM_EABI__
*g = 1;
+#else
+ *(char *)g = 1;
+#endif
}
//*************************************************************************
