Summary:ASTERISK-27619: Build System: Require compiler to provide built-in support for atomic references.
Reporter:Corey Farrell (coreyfarrell)Labels:
Date Opened:2018-01-24 14:25:38.000-0600Date Closed:2018-01-30 06:57:27.000-0600
Versions:GIT Frequency of
Description:I'm working with the jansson project to get thread safe reference counting \[1\].  I'm getting some push-back on the pieces necessary to emulate atomic operations.  I'm proposing that Asterisk 16+ should require the availability of __sync or __atomic built-ins:
* __sync_fetch_and_add or __atomic_fetch_add (used by AO2)
* __sync_add_and_fetch or __atomic_add_fetch (to be used by jansson)
* __sync_lock_test_and_set / __sync_lock_release or the __atomic equivalents (used by spinlock.h)

All of these __sync functions have been available since gcc-4.1.2 \[2\] (released in 2007).  The __atomic variants are newer and I believe they should be preferred if available.  This is in preparation for Asterisk 16+ hopefully requiring jansson 2.11+ and removing most (or all) locking from main/json.c.

\[1\]: https://github.com/akheron/jansson/pull/389
\[2\]: https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html
Comments:By: Friendly Automation (friendly-automation) 2018-01-30 06:57:28.465-0600

Change 8049 merged by Jenkins2:
Build System: Require __sync or __atomic functions.


By: Friendly Automation (friendly-automation) 2018-01-31 17:08:16.212-0600

Change 8107 merged by Jenkins2:
core: Create ast_atomic macro's.