Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change win32 compat atomic_compare_exchange_strong to match C11 spec #57

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions compat/atomics/win32/stdatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ do { \
#define atomic_exchange_explicit(object, desired, order) \
atomic_exchange(object, desired)

static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected,
intptr_t desired)
{
intptr_t old = *expected;
*expected = (intptr_t)InterlockedCompareExchangePointer(
(PVOID *)object, (PVOID)desired, (PVOID)old);
return *expected == old;
}
#define atomic_compare_exchange_strong(object, expected, desired) \
(sizeof(*object) == 2 ? \
InterlockedCompareExchange16((SHORT *) object, (SHORT) desired, *((SHORT *) expected)) == *expected \
: sizeof(*object) == 4 ? \
InterlockedCompareExchange((LONG *) object, (LONG) desired, *((LONG *) expected)) == *expected \
: sizeof(*object) == 8 ? \
InterlockedCompareExchange64((LONG64 *) object, (LONG64) desired, *((LONG64 *) expected)) == *expected \
: 0)


#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
atomic_compare_exchange_strong(object, expected, desired)
Expand Down
4 changes: 0 additions & 4 deletions libavcodec/vvc_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,7 @@ int ff_vvc_task_run(Task *_t, void *local_context, void *user_data)

if (!atomic_load(&ft->ret)) {
if ((ret = run[t->type](s, lc, t)) < 0) {
#ifdef WIN32
intptr_t zero = 0;
#else
int zero = 0;
#endif
atomic_compare_exchange_strong(&ft->ret, &zero, ret);
}
}
Expand Down