mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
Build System: Add support for __atomic built-in operators.
Add a check to configure.ac for __atomic_fetch_add support. If found use the __atomic built-in operators for ast_atomic_dec_and_test and ast_atomic_fetchadd_int. ASTERISK~27619 Change-Id: I65b4feb02bae368904ed0fb03f585c05f50a690e
This commit is contained in:
@@ -188,6 +188,9 @@
|
||||
/* Define to 1 if you have the curses library. */
|
||||
#undef HAVE_CURSES
|
||||
|
||||
/* Define to 1 if your C compiler provides __atomic operations. */
|
||||
#undef HAVE_C_ATOMICS
|
||||
|
||||
/* Define if your system has the DAHDI headers. */
|
||||
#undef HAVE_DAHDI
|
||||
|
||||
@@ -292,7 +295,7 @@
|
||||
/* Define to 1 if you have the `ftruncate' function. */
|
||||
#undef HAVE_FTRUNCATE
|
||||
|
||||
/* Define to 1 if your GCC C compiler provides atomic operations. */
|
||||
/* Define to 1 if your GCC C compiler provides __sync atomic operations. */
|
||||
#undef HAVE_GCC_ATOMICS
|
||||
|
||||
/* Define to 1 if you have the `getcwd' function. */
|
||||
|
@@ -640,7 +640,12 @@ int ast_atomic_fetchadd_int_slow(volatile int *p, int v);
|
||||
* can be used to generate unique identifiers.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_GCC_ATOMICS)
|
||||
#if defined(HAVE_C_ATOMICS)
|
||||
AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
|
||||
{
|
||||
return __atomic_fetch_add(p, v, __ATOMIC_RELAXED);
|
||||
})
|
||||
#elif defined(HAVE_GCC_ATOMICS)
|
||||
AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
|
||||
{
|
||||
return __sync_fetch_and_add(p, v);
|
||||
@@ -687,7 +692,12 @@ AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
|
||||
/*! \brief decrement *p by 1 and return true if the variable has reached 0.
|
||||
* Useful e.g. to check if a refcount has reached 0.
|
||||
*/
|
||||
#if defined(HAVE_GCC_ATOMICS)
|
||||
#if defined(HAVE_C_ATOMICS)
|
||||
AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
|
||||
{
|
||||
return __atomic_sub_fetch(p, 1, __ATOMIC_RELAXED) == 0;
|
||||
})
|
||||
#elif defined(HAVE_GCC_ATOMICS)
|
||||
AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
|
||||
{
|
||||
return __sync_sub_and_fetch(p, 1) == 0;
|
||||
|
Reference in New Issue
Block a user