[svn-commits] trunk r36409 - in /trunk: configure.ac
include/asterisk/lock.h
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Fri Jun 30 08:54:14 MST 2006
Author: russell
Date: Fri Jun 30 10:54:13 2006
New Revision: 36409
URL: http://svn.digium.com/view/asterisk?rev=36409&view=rev
Log:
add support for atomic operations provided by mac osx
Modified:
trunk/configure.ac
trunk/include/asterisk/lock.h
Modified: trunk/configure.ac
URL: http://svn.digium.com/view/asterisk/trunk/configure.ac?rev=36409&r1=36408&r2=36409&view=diff
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Jun 30 10:54:13 2006
@@ -887,6 +887,11 @@
AC_MSG_RESULT(no)
)
+AC_CHECK_HEADER([libkern/OSAtomic.h],
+ [AC_DEFINE_UNQUOTED([HAVE_OSX_ATOMICS], 1, [Define to 1 if OSX atomic operations are supported.])])
+
+AC_CHECK_SIZEOF(int)
+
AC_CONFIG_FILES([build_tools/menuselect-deps makeopts])
AC_OUTPUT
Modified: trunk/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/lock.h?rev=36409&r1=36408&r2=36409&view=diff
==============================================================================
--- trunk/include/asterisk/lock.h (original)
+++ trunk/include/asterisk/lock.h Fri Jun 30 10:54:13 2006
@@ -738,6 +738,10 @@
#include "asterisk/inline_api.h"
+#ifdef __Darwin__
+#include "libkern/OSAtomic.h"
+#endif
+
/*! \brief Atomically add v to *p and return * the previous value of *p.
* This can be used to handle reference counts, and the return value
* can be used to generate unique identifiers.
@@ -748,7 +752,16 @@
{
return __sync_fetch_and_add(p, v);
})
-#elif defined ( __i386__)
+#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 4)
+AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
+{
+ return OSAtomicAdd32(v, (int32_t *) p);
+})
+#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 8)
+AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
+{
+ return OSAtomicAdd64(v, (int64_t *) p);
+#elif defined (__i386__)
AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
{
__asm __volatile (
@@ -773,6 +786,15 @@
{
return __sync_sub_and_fetch(p, 1) == 0;
})
+#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 4)
+AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
+{
+ return OSAtomicDecrement32((int32_t *) p) == 0;
+})
+#elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 8)
+AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
+{
+ return OSAtomicDecrement64((int64_t *) p) == 0;
#else
AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
{
More information about the svn-commits
mailing list