aboutsummaryrefslogtreecommitdiffstats
path: root/utils.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 23:26:22 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-30 23:26:22 +0000
commit1baf6ed3268f3de5f44a2a3569e6e697275f4247 (patch)
treed523df419b44c5c8864b03fcdb19286787e75e01 /utils.c
parent4e54af4b6c019d63964a1fc476a8c6ad7c538d25 (diff)
initial implementation of support for native atomic ops.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@16601 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 32c167780..84ee0b880 100644
--- a/utils.c
+++ b/utils.c
@@ -39,6 +39,7 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#define AST_API_MODULE /* ensure that inlinable API functions will be built in lock.h if required */
#include "asterisk/lock.h"
#include "asterisk/io.h"
#include "asterisk/logger.h"
@@ -1049,6 +1050,16 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
va_end(ap2);
}
+AST_MUTEX_DEFINE_STATIC(fetchadd_m); /* used for all fetc&add ops */
+int ast_atomic_fetchadd_int_slow(volatile int *p, int v)
+{
+ int ret;
+ ast_mutex_lock(&fetchadd_m);
+ ret = *p;
+ *p += v;
+ ast_mutex_unlock(&fetchadd_m);
+ return ret;
+}
/*! \brief
* get values from config variables.