From: Debian Science Maintainers Date: Fri, 6 May 2011 13:52:41 +0000 (+0100) Subject: fix-asm X-Git-Tag: archive/raspbian/7.3.0+dfsg1-4+rpi1~1^2^2~22 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=81fd892261e61a30f97e44c93337668ec54aac06;p=opencascade.git fix-asm Replace x86 assembly code by atomic extensions provided by GNU g++. (closes: #518837) Submitted upstream: http://www.opencascade.org/org/forum/thread_20053/ Gbp-Pq: Topic submitted Gbp-Pq: Name fix-asm.patch --- diff --git a/ros/inc/Standard_Atomic.hxx b/ros/inc/Standard_Atomic.hxx index 93f80ecd8..ce9c8102b 100644 --- a/ros/inc/Standard_Atomic.hxx +++ b/ros/inc/Standard_Atomic.hxx @@ -45,13 +45,13 @@ inline int Standard_Atomic_DecrementTest (int volatile* var) } //=================================================== -// Linux, GCC compiler +// GCC compiler on x86 or x86_64 // Note: Linux kernel 2.6x provides definitions for atomic operators // in the header file /usr/include/asm/atomic.h, // however these definitions involve specific type atomic_t // Note: The same code probably would work for Intel compiler //=================================================== -#elif defined(LIN) +#elif defined(__GNUG__) && (defined(__i386) || defined(__x86_64)) inline void Standard_Atomic_Increment (int volatile* var) { @@ -82,6 +82,30 @@ inline int Standard_Atomic_DecrementTest (int volatile* var) return c != 0; } +//=================================================== +// GCC extension for atomic operations +// http://gcc.gnu.org/wiki/Atomic +//=================================================== +#elif defined(__GNUG__) && !defined(__sparc_v9) && !defined(__sparc_v9__) // _Atomic_word is not an int on SPARC V9 + +#include + +inline void Standard_Atomic_Increment (int* var) +{ + // C equivalent: + // ++(*var); + + __gnu_cxx::__atomic_add_dispatch(static_cast<_Atomic_word*>(var), 1); +} + +inline int Standard_Atomic_DecrementTest (int* var) +{ + // C equivalent: + // return --(*var) == 0; + + return __gnu_cxx::__exchange_and_add_dispatch(static_cast<_Atomic_word*>(var),-1) == 1; +} + //=================================================== // Default stub implementation, not atomic actually //=================================================== diff --git a/ros/src/Standard/Standard_Atomic.hxx b/ros/src/Standard/Standard_Atomic.hxx index 93f80ecd8..ce9c8102b 100644 --- a/ros/src/Standard/Standard_Atomic.hxx +++ b/ros/src/Standard/Standard_Atomic.hxx @@ -45,13 +45,13 @@ inline int Standard_Atomic_DecrementTest (int volatile* var) } //=================================================== -// Linux, GCC compiler +// GCC compiler on x86 or x86_64 // Note: Linux kernel 2.6x provides definitions for atomic operators // in the header file /usr/include/asm/atomic.h, // however these definitions involve specific type atomic_t // Note: The same code probably would work for Intel compiler //=================================================== -#elif defined(LIN) +#elif defined(__GNUG__) && (defined(__i386) || defined(__x86_64)) inline void Standard_Atomic_Increment (int volatile* var) { @@ -82,6 +82,30 @@ inline int Standard_Atomic_DecrementTest (int volatile* var) return c != 0; } +//=================================================== +// GCC extension for atomic operations +// http://gcc.gnu.org/wiki/Atomic +//=================================================== +#elif defined(__GNUG__) && !defined(__sparc_v9) && !defined(__sparc_v9__) // _Atomic_word is not an int on SPARC V9 + +#include + +inline void Standard_Atomic_Increment (int* var) +{ + // C equivalent: + // ++(*var); + + __gnu_cxx::__atomic_add_dispatch(static_cast<_Atomic_word*>(var), 1); +} + +inline int Standard_Atomic_DecrementTest (int* var) +{ + // C equivalent: + // return --(*var) == 0; + + return __gnu_cxx::__exchange_and_add_dispatch(static_cast<_Atomic_word*>(var),-1) == 1; +} + //=================================================== // Default stub implementation, not atomic actually //===================================================