On Thu, Dec 8, 2016 at 2:32 PM, Rémi Denis-Courmont <[email protected]> wrote: > Le perjantaina 2. joulukuuta 2016, 16.56.16 EET Wan-Teh Chang a écrit : >> 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 ); > > FWIW, the function is defined in ISO C; ISO C++ atomic operations are very > similar by design, but also subtly different, so they don´t belong as > reference here.
cppreference.com also has information on the Standard C Library. The URL I cited is the reference for the C function. If you know of a better URL, I will be happy to use that instead. Or I can remove the URL to avoid confusion. Note: The URL of the corresponding C++ reference is http://en.cppreference.com/w/cpp/atomic/atomic_compare_exchange. >> diff --git a/compat/atomics/win32/stdatomic.h >> b/compat/atomics/win32/stdatomic.h index bdd3933..9cfdaa5 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); > > Using InterlockedCompareExchange() directly would seem saner. Agreed. I'm planning to submit another patch that changes the atomic_compare_exchange_strong() emulation to only work for atomic_int. Then it will be able to call InterlockedCompareExchange(). Wan-Teh Chang _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
