diff options
author | Wan-Teh Chang <wtc@google.com> | 2016-12-02 16:56:16 -0800 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2016-12-08 15:53:58 -0500 |
commit | 6a93b596c5c3af31b843d63013a7985ffeea354d (patch) | |
tree | 023ffd3b217ea2541f3f1bd71440d2d6a93c63c4 | |
parent | 2170017a1cd033b6f28e16476921022712a522d8 (diff) | |
download | ffmpeg-streaming-6a93b596c5c3af31b843d63013a7985ffeea354d.zip ffmpeg-streaming-6a93b596c5c3af31b843d63013a7985ffeea354d.tar.gz |
compat/atomics: add typecasts in atomic_compare_exchange_strong()
The Solaris and Windows emulations of atomic_compare_exchange_strong()
need typecasts to avoid compiler warnings, because the functions they
call expect a void* pointer but an intptr_t integer is passed.
Note that the emulations of atomic_compare_exchange_strong() (except
the gcc version) only work for atomic_intptr_t because of the type of
the second argument (|expected|). See
http://en.cppreference.com/w/c/atomic:
_Bool atomic_compare_exchange_strong( volatile A* obj,
C* expected, C desired );
The types of the first argument and second argument are different
(|A| and |C|, respectively). |C| is the non-atomic type corresponding
to |A|. In the emulations of atomic_compare_exchange_strong(), |C| is
intptr_t. This implies |A| can only be sig_intptr_t.
Signed-off-by: Wan-Teh Chang <wtc@google.com>
-rw-r--r-- | compat/atomics/suncc/stdatomic.h | 2 | ||||
-rw-r--r-- | compat/atomics/win32/stdatomic.h | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/compat/atomics/suncc/stdatomic.h b/compat/atomics/suncc/stdatomic.h index 32129aa..aef498d 100644 --- a/compat/atomics/suncc/stdatomic.h +++ b/compat/atomics/suncc/stdatomic.h @@ -108,7 +108,7 @@ static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *exp intptr_t desired) { intptr_t old = *expected; - *expected = atomic_cas_ptr(object, old, desired); + *expected = (intptr_t)atomic_cas_ptr(object, (void *)old, (void *)desired); return *expected == old; } diff --git a/compat/atomics/win32/stdatomic.h b/compat/atomics/win32/stdatomic.h index bdd3933..9cfdaa52 100644 --- a/compat/atomics/win32/stdatomic.h +++ b/compat/atomics/win32/stdatomic.h @@ -104,7 +104,8 @@ static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *exp intptr_t desired) { intptr_t old = *expected; - *expected = InterlockedCompareExchangePointer(object, desired, old); + *expected = (intptr_t)InterlockedCompareExchangePointer( + (PVOID *)object, (PVOID)desired, (PVOID)old); return *expected == old; } |