aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/lock.h
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-03 20:38:13 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-02-03 20:38:13 +0000
commita0b795f0812a231bc7a0c097931f5cc8d51333d2 (patch)
tree2f5ac9dbc27e12f1fe4c415ab79132b90a09856d /include/asterisk/lock.h
parent8d68ea3d42ef1bcecf2a8f23ab73e875cc529132 (diff)
set the DIALSTATUS variable to contain "INVALIDARGS" when the dial application
exits early because of invalid arguments instead of just leaving it empty. (issue #8975) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@53133 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/lock.h')
-rw-r--r--include/asterisk/lock.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index dc9cf9a28..67deba4dd 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -666,4 +666,31 @@ static inline int ast_cond_timedwait(ast_cond_t *cond, ast_mutex_t *t, const str
#define pthread_create __use_ast_pthread_create_instead__
#endif
+int ast_atomic_fetchadd_int_slow(volatile int *p, int v);
+
+#include "asterisk/inline_api.h"
+
+#if defined (__i386__)
+AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
+{
+ __asm __volatile (
+ " lock xaddl %0, %1 ; "
+ : "+r" (v), /* 0 (result) */
+ "=m" (*p) /* 1 */
+ : "m" (*p)); /* 2 */
+ return (v);
+})
+#else /* low performance version in utils.c */
+AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
+{
+ return ast_atomic_fetchadd_int_slow(p, v);
+})
+#endif
+
+AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
+{
+ int a = ast_atomic_fetchadd_int(p, -1);
+ return a == 1; /* true if the value is 0 now (so it was 1 previously) */
+})
+
#endif /* _ASTERISK_LOCK_H */