building tog-pegasus for ARM on Fedora 19
"David A. Marlin" <[email protected]> Fri, 26 Apr 2013 11:52:38 -0500
| Newsgroups | gmane.network.open-pegasus.general |
|---|---|
| Message-ID | <[email protected]> |
tog-pegasus-2.2.3-4 fails to build successfully for ARM on Fedora 19. It is based on pegasus-2.12.1. The failure is due to failing test cases which uses atomic operations for synchronization (Tracer). The atomic operation code indicates it is for XScale, which is an older ARM platform. To address this, I replaced the platform-specific code with GCC built-in atomic operations (libatomic). http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html This worked for ARM, so since this was architecture-neutral code I combined x86 and ARM to use the same (new) code. This also passed on ARM and x86_64. In theory it should work for other architectures as well, but I don't have access to test. The only restriction is that it requires a recent version of GCC (4.1 or newer). Attached is the patch I used to make these changes. Please let me know if this is an acceptable approach. Thank you, d.marlin
tog-pegasus-arm.patch
(text/x-patch, 4.6 KB)
--- pegasus/src/Pegasus/Common/AtomicInt.h.arm 2012-07-30 04:23:47.000000000 -0500
+++ pegasus/src/Pegasus/Common/AtomicInt.h 2013-04-22 13:18:00.199877108 -0500
@@ -100,12 +100,14 @@
// PEGASUS_PLATFORM_LINUX_IX86_GNU
// PEGASUS_PLATFORM_DARWIN_IX86_GNU
// PEGASUS_PLATFORM_LINUX_X86_64_GNU
+// PEGASUS_PLATFORM_LINUX_XSCALE_GNU
//
//==============================================================================
#if defined(PEGASUS_PLATFORM_LINUX_IX86_GNU) || \
defined(PEGASUS_PLATFORM_DARWIN_IX86_GNU) || \
- defined(PEGASUS_PLATFORM_LINUX_X86_64_GNU)
+ defined(PEGASUS_PLATFORM_LINUX_X86_64_GNU) || \
+ defined(PEGASUS_PLATFORM_LINUX_XSCALE_GNU)
# define PEGASUS_ATOMIC_INT_DEFINED
// Note: this lock can be eliminated for single processor systems.
@@ -121,7 +123,7 @@
PEGASUS_TEMPLATE_SPECIALIZATION
inline AtomicIntTemplate<AtomicType>::AtomicIntTemplate(Uint32 n)
{
- _rep.n = n;
+ __atomic_store_n (&_rep.n, n, __ATOMIC_SEQ_CST);
}
PEGASUS_TEMPLATE_SPECIALIZATION
@@ -132,44 +134,31 @@
PEGASUS_TEMPLATE_SPECIALIZATION
inline Uint32 AtomicIntTemplate<AtomicType>::get() const
{
- return _rep.n;
+ return __atomic_load_n (&_rep.n, __ATOMIC_SEQ_CST);
}
PEGASUS_TEMPLATE_SPECIALIZATION
inline void AtomicIntTemplate<AtomicType>::set(Uint32 n)
{
- _rep.n = n;
+ __atomic_store_n (&_rep.n, n, __ATOMIC_SEQ_CST);
}
PEGASUS_TEMPLATE_SPECIALIZATION
inline void AtomicIntTemplate<AtomicType>::inc()
{
- asm volatile(
- PEGASUS_ATOMIC_LOCK "incl %0"
- :"=m" (_rep.n)
- :"m" (_rep.n));
+ __atomic_fetch_add (&_rep.n, 1, __ATOMIC_SEQ_CST);
}
PEGASUS_TEMPLATE_SPECIALIZATION
inline void AtomicIntTemplate<AtomicType>::dec()
{
- asm volatile(
- PEGASUS_ATOMIC_LOCK "decl %0"
- :"=m" (_rep.n)
- :"m" (_rep.n));
+ __atomic_fetch_sub (&_rep.n, 1, __ATOMIC_SEQ_CST);
}
PEGASUS_TEMPLATE_SPECIALIZATION
inline bool AtomicIntTemplate<AtomicType>::decAndTestIfZero()
{
- unsigned char c;
-
- asm volatile(
- PEGASUS_ATOMIC_LOCK "decl %0; sete %1"
- :"=m" (_rep.n), "=qm" (c)
- :"m" (_rep.n) : "memory");
-
- return c != 0;
+ return (__atomic_fetch_sub (&_rep.n, 1, __ATOMIC_SEQ_CST) == 1);
}
typedef AtomicIntTemplate<AtomicType> AtomicInt;
@@ -756,109 +745,6 @@
//==============================================================================
//
-// PEGASUS_PLATFORM_LINUX_XSCALE_GNU
-//
-//==============================================================================
-
-#if defined (PEGASUS_PLATFORM_LINUX_XSCALE_GNU)
-# define PEGASUS_ATOMIC_INT_DEFINED
-
-PEGASUS_NAMESPACE_BEGIN
-
-inline void AtomicIntDisableIRQs(unsigned long& flags)
-{
- unsigned long temp;
- unsigned long x;
-
- asm volatile(
- "mrs %0, cpsr\n"
- "orr %1, %0, #128\n"
- "msr cpsr_c, %1\n"
- : "=r" (x), "=r" (temp)
- :
- : "memory");
-
- flags = x;
-}
-
-inline void AtomicIntEnableIRQs(unsigned long x)
-{
- unsigned long temp;
-
- asm volatile(
- "mrs %0, cpsr\n"
- "orr %1, %0, #128\n"
- "msr cpsr_c, %1\n"
- : "=r" (x), "=r" (temp)
- :
- : "memory");
-}
-
-struct AtomicType
-{
- volatile Uint32 n;
-};
-
-PEGASUS_TEMPLATE_SPECIALIZATION
-inline AtomicIntTemplate<AtomicType>::AtomicIntTemplate(Uint32 n)
-{
- _rep.n = n;
-}
-
-PEGASUS_TEMPLATE_SPECIALIZATION
-inline AtomicIntTemplate<AtomicType>::~AtomicIntTemplate()
-{
-}
-
-PEGASUS_TEMPLATE_SPECIALIZATION
-inline Uint32 AtomicIntTemplate<AtomicType>::get() const
-{
- return _rep.n;
-}
-
-PEGASUS_TEMPLATE_SPECIALIZATION
-inline void AtomicIntTemplate<AtomicType>::set(Uint32 n)
-{
- _rep.n = n;
-}
-
-PEGASUS_TEMPLATE_SPECIALIZATION
-inline void AtomicIntTemplate<AtomicType>::inc()
-{
- unsigned long flags;
- AtomicIntDisableIRQs(flags);
- _rep.n++;
- AtomicIntEnableIRQs(flags);
-}
-
-PEGASUS_TEMPLATE_SPECIALIZATION
-inline void AtomicIntTemplate<AtomicType>::dec()
-{
- unsigned long flags;
- AtomicIntDisableIRQs(flags);
- _rep.n--;
- AtomicIntEnableIRQs(flags);
-}
-
-PEGASUS_TEMPLATE_SPECIALIZATION
-inline bool AtomicIntTemplate<AtomicType>::decAndTestIfZero()
-{
- Uint32 tmp;
- unsigned long flags;
- AtomicIntDisableIRQs(flags);
- tmp = --_rep.n;
- AtomicIntEnableIRQs(flags);
- return tmp == 0;
-}
-
-typedef AtomicIntTemplate<AtomicType> AtomicInt;
-
-PEGASUS_NAMESPACE_END
-
-#endif /* PEGASUS_PLATFORM_LINUX_XSCALE_GNU */
-
-//==============================================================================
-//
// PEGASUS_PLATFORM_VMS_ALPHA_DECCXX
// PEGASUS_PLATFORM_VMS_IA64_DECCXX
//