Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On 01/27/2011 05:31 PM, Caolán McNamara wrote:
On Thu, 2011-01-27 at 15:42 +0200, Jani Monoses wrote:
armel

sal/osl/unx/interlck.c probably should have a specific impl for arm btw,
probably a low hanging fruit for someone who knows a little bit of arm
assembly.


What about using GCC atomic builtins like in the attached patch?

If correct (seems so, but I did no test it beyond building it - are
there tests for this in LibO?) it has the advantage of covering more
than ARM, and for ARM letting gcc emit optimal (I hope) code by
taking care of differences between atomic exchange primitives on ARM pre
v6 (SWP) and newer (STREX/LDREX) and memory barrier instructions
(DMB vs MCR ....). Debian still builds for armv5 while Ubuntu for armv7
so there would have been at least some ifdefs if assembly were used.

IMHO it is better to stick to portable C/C++ if it does not constitute a
drawback otherwise :)

Jani

From 6570fea4a5851db6dce6f2c9e69133115026ff63 Mon Sep 17 00:00:00 2001
From: Jani Monoses <jani.monoses@canonical.com>
Date: Thu, 27 Jan 2011 20:02:10 +0200
Subject: [PATCH] Add oslInterlockedCount inc/dec functions using GCC atomic builtins

---
 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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.