summaryrefslogtreecommitdiff
path: root/sal/osl/unx/interlck.c
diff options
context:
space:
mode:
authorJani Monoses <jani.monoses@canonical.com>2011-03-14 19:10:04 +0100
committerPetr Mladek <pmladek@suse.cz>2011-04-05 16:57:57 +0200
commitf170c2376ae6cd3d6308a9224b68347e1a6c141f (patch)
treea0888137f51d151ad5d00de62463fccb2969f9ed /sal/osl/unx/interlck.c
parentb8867927e2fee37ed60b1b8773bcc0dc7e2b91cd (diff)
prefer gcc __sync functions over pthread
Signed-off-by: Bjoern Michaelsen <bjoern.michaelsen@canonical.com>
Diffstat (limited to 'sal/osl/unx/interlck.c')
-rw-r--r--sal/osl/unx/interlck.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c
index f8630c97a4f1..ee64f8d7ab50 100644
--- a/sal/osl/unx/interlck.c
+++ b/sal/osl/unx/interlck.c
@@ -134,7 +134,16 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount*
return nCount;
}
+#elif ( __GNUC__ > 4 ) || (( __GNUC__ == 4) && ( __GNUC_MINOR__ >= 4 ))
+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 */