[Libreoffice-commits] .: 2 commits - sal/inc
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Sep 17 05:46:34 PDT 2012
sal/inc/osl/interlck.h | 47 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 43 insertions(+), 4 deletions(-)
New commits:
commit 576ba0c0c082dfe50c4b97292093b833443c3756
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Sep 17 14:45:47 2012 +0200
Some comment clean up
Change-Id: I33fbe68b17e9a1c457b37c6d81619f2df67fbe8d
diff --git a/sal/inc/osl/interlck.h b/sal/inc/osl/interlck.h
index f8cd56e..792ea55 100644
--- a/sal/inc/osl/interlck.h
+++ b/sal/inc/osl/interlck.h
@@ -41,50 +41,51 @@ extern "C" {
typedef sal_Int32 oslInterlockedCount;
/** Increments the count variable addressed by pCount.
- @param pCount Address of counter variable
- @return The result of the operation is zero, the value of the count variable.
+ @param pCount Address of count variable
+ @return The adjusted value of the count variable.
*/
SAL_DLLPUBLIC oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInterlockedCount* pCount);
/** Decrement the count variable addressed by pCount.
- @param pCount Address of counter variable
- @return The result of the operation is the new value is of the count variable.
+ @param pCount Address of count variable
+ @return The adjusted value of the count variable.
*/
SAL_DLLPUBLIC oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount);
-/** Increments the count variable addressed by pCount.
- @param pCount Address of counter variable
- @return The result of the operation is zero, the value of the count variable.
-*/
-
/// @cond INTERNAL
/** Increments the count variable addressed by p.
- @param p Address of counter variable
+
@attention This functionality should only be used internally within
LibreOffice.
+ @param p Address of count variable
@return The adjusted value of the count variable.
+
+ @since LibreOffice 3.7
*/
#if defined( HAVE_GCC_BUILTIN_ATOMIC )
# define osl_atomic_increment(p) __sync_add_and_fetch((p), 1)
#else
-# define osl_atomic_increment(p) osl_incrementInterlockedCount(p)
+# define osl_atomic_increment(p) osl_incrementInterlockedCount((p))
#endif
/** Decrement the count variable addressed by p.
- @param p Address of counter variable
+
@attention This functionality should only be used internally within
LibreOffice.
+ @param p Address of count variable
@return The adjusted value of the count variable.
+
+ @since LibreOffice 3.7
*/
#if defined( HAVE_GCC_BUILTIN_ATOMIC )
# define osl_atomic_decrement(p) __sync_sub_and_fetch((p), 1)
#else
-# define osl_atomic_decrement(p) osl_decrementInterlockedCount(p)
+# define osl_atomic_decrement(p) osl_decrementInterlockedCount((p))
#endif
/// @endcond
commit afbc57927854c423e12206c048bbe7c285a4d9a6
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date: Sun Sep 16 01:59:07 2012 -0500
add osl_atomic_* api to allow for inlined atomic increment/decrement
atomic increment/decrement is provided by
osl_increment/decrementInterlockedCount()
but that is a exported dll function, so it cannot be inlined.
valgrind analysis of a run, loading a medium sized spreadsheet, shows
that these 2 functions were called 3.5 millions times for a total cost of
55 millions of instructions... a cost of 8 instructions per call,
which is at least a 300% overhead since an atomic inc/dec is 2 instructions
iow we could save about 1% of the total instruction count of that run(4.6B)
We cannot change the existing api, as this would break ABI.
but we can add a new api. and migrate internal user to it.
osl_atomic_decrement/osl_atomic_increment do the same task,
than osl_*IntelockedCount() but do that inlined if possible.
Note that this version only optimize the case GCC with atomic built-in.
but support for other case should not be very hard.
follows-up patches will replace the use of the osl_*InterlockedCount()
in the product with their osl_atomic_* equivalent.
Change-Id: If4dcbf94ea6f62eb6d55d30613fe65878ffb8023
Signed-off-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sal/inc/osl/interlck.h b/sal/inc/osl/interlck.h
index 858f99f..f8cd56e 100644
--- a/sal/inc/osl/interlck.h
+++ b/sal/inc/osl/interlck.h
@@ -52,10 +52,48 @@ SAL_DLLPUBLIC oslInterlockedCount SAL_CALL osl_incrementInterlockedCount(oslInte
*/
SAL_DLLPUBLIC oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* pCount);
+
+/** Increments the count variable addressed by pCount.
+ @param pCount Address of counter variable
+ @return The result of the operation is zero, the value of the count variable.
+*/
+
+/// @cond INTERNAL
+
+/** Increments the count variable addressed by p.
+ @param p Address of counter variable
+ @attention This functionality should only be used internally within
+ LibreOffice.
+
+ @return The adjusted value of the count variable.
+*/
+#if defined( HAVE_GCC_BUILTIN_ATOMIC )
+# define osl_atomic_increment(p) __sync_add_and_fetch((p), 1)
+#else
+# define osl_atomic_increment(p) osl_incrementInterlockedCount(p)
+#endif
+
+
+/** Decrement the count variable addressed by p.
+ @param p Address of counter variable
+ @attention This functionality should only be used internally within
+ LibreOffice.
+
+ @return The adjusted value of the count variable.
+*/
+#if defined( HAVE_GCC_BUILTIN_ATOMIC )
+# define osl_atomic_decrement(p) __sync_sub_and_fetch((p), 1)
+#else
+# define osl_atomic_decrement(p) osl_decrementInterlockedCount(p)
+#endif
+
+/// @endcond
+
#ifdef __cplusplus
}
#endif
+
#endif /* _OSL_INTERLOCK_H_ */
More information about the Libreoffice-commits
mailing list