[PATCH] Add oslInterlockedCount inc/dec functions using GCC atomic builtins

Jani Monoses jani.monoses at canonical.com
Thu Jan 27 10:02:10 PST 2011


---
 osl/unx/interlck.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/osl/unx/interlck.c b/osl/unx/interlck.c
index f164371..51c1c9e 100644
--- a/osl/unx/interlck.c
+++ b/osl/unx/interlck.c
@@ -135,6 +135,16 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount*
     return nCount;
 }
 
+#elif defined ( GCC )
+oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount)
+{
+	return __sync_add_and_fetch(pCount, 1);
+}
+
+oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount)
+{
+	return __sync_sub_and_fetch(pCount, 1);
+}
 #else
 /* use only if nothing else works, expensive due to single mutex for all reference counts */
 
-- 
1.7.2.3


--------------040608060603010209050401--



More information about the LibreOffice mailing list