diff mbox

[FFmpeg-devel,1/4] avcodec/allcodecs: make avcodec_register_all thread safe

Message ID 65c049ef-4028-0fa2-e096-d0f13e86a1f7@gmail.com
State Accepted
Headers show

Commit Message

James Almer March 7, 2017, 3:07 a.m. UTC
On 3/6/2017 11:55 PM, Michael Niedermayer wrote:
> On Tue, Mar 07, 2017 at 02:47:36AM +0700, Muhammad Faiz wrote:
>> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
>> ---
>>  libavcodec/allcodecs.c | 13 ++++++++++---
>>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> fails to build
> 
> ibavcodec/allcodecs.c: In function ‘avcodec_register_all’:
> libavcodec/allcodecs.c:68:5: error: implicit declaration of function ‘typeof’ [-Werror=implicit-function-declaration]
> libavcodec/allcodecs.c:68:33: error: expected ‘;’ before ‘_obj’
> libavcodec/allcodecs.c:68:78: error: expected ‘;’ before ‘_old’
> libavcodec/allcodecs.c:68:87: error: ‘_old’ undeclared (first use in this function)
> libavcodec/allcodecs.c:68:87: note: each undeclared identifier is reported only once for each function it appears in
> libavcodec/allcodecs.c:68:119: error: ‘_obj’ undeclared (first use in this function)
> libavcodec/allcodecs.c:68:78: error: incompatible type for argument 1 of ‘__sync_bool_compare_and_swap’
> cc1: some warnings being treated as errors
> make: *** [libavcodec/allcodecs.o] Error 1
> make: *** Waiting for unfinished jobs....

This is from the compat header for c11 atomics on old GCC versions.
Looks like it should be using __typeof__ instead.

Try the attached patch.
diff mbox

Patch

From 5af305a9180b691577e48731d9ca84a3b2342404 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Tue, 7 Mar 2017 00:04:46 -0300
Subject: [PATCH] compat/atomics/gcc: use __typeof__ instead of typeof

Signed-off-by: James Almer <jamrial@gmail.com>
---
 compat/atomics/gcc/stdatomic.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/compat/atomics/gcc/stdatomic.h b/compat/atomics/gcc/stdatomic.h
index 41caddec5c..2b64687437 100644
--- a/compat/atomics/gcc/stdatomic.h
+++ b/compat/atomics/gcc/stdatomic.h
@@ -100,8 +100,8 @@  do {                                    \
 
 #define atomic_exchange(object, desired)                            \
 ({                                                                  \
-    typeof(object) _obj = (object);                                 \
-    typeof(*object) _old;                                           \
+    __typeof__(object) _obj = (object);                             \
+    __typeof__(*object) _old;                                       \
     do                                                              \
         _old = atomic_load(_obj);                                   \
     while (!__sync_bool_compare_and_swap(_obj, _old, (desired)));   \
@@ -113,8 +113,8 @@  do {                                    \
 
 #define atomic_compare_exchange_strong(object, expected, desired)   \
 ({                                                                  \
-    typeof(object) _exp = (expected);                               \
-    typeof(*object) _old = *_exp;                                   \
+    __typeof__(object) _exp = (expected);                           \
+    __typeof__(*object) _old = *_exp;                               \
     *_exp = __sync_val_compare_and_swap((object), _old, (desired)); \
     *_exp == _old;                                                  \
 })
-- 
2.12.0