[FFmpeg-devel,4/7] avformat/format: convert to stdatomic

Submitted by James Almer on March 22, 2017, 11:34 p.m.

Details

Message ID 20170322233412.6952-5-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer March 22, 2017, 11:34 p.m.
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/format.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/format.c b/libavformat/format.c
index 38ca2a3465..403dc41b03 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -19,7 +19,8 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavutil/atomic.h"
+#include <stdatomic.h>
+
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
 #include "libavutil/opt.h"
@@ -61,9 +62,10 @@  AVOutputFormat *av_oformat_next(const AVOutputFormat *f)
 void av_register_input_format(AVInputFormat *format)
 {
     AVInputFormat **p = last_iformat;
+    const AVInputFormat *cmp = NULL;
 
     // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
+    while(p != &format->next && !format->next && !atomic_compare_exchange_strong(p, &cmp, format))
         p = &(*p)->next;
 
     if (!format->next)
@@ -73,9 +75,10 @@  void av_register_input_format(AVInputFormat *format)
 void av_register_output_format(AVOutputFormat *format)
 {
     AVOutputFormat **p = last_oformat;
+    const AVOutputFormat *cmp = NULL;
 
     // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
+    while(p != &format->next && !format->next && !atomic_compare_exchange_strong(p, &cmp, format))
         p = &(*p)->next;
 
     if (!format->next)