Skip to content

Commit

Permalink
atomic: Check for __sync_val_compare_and_swap instead of __sync_synch…
Browse files Browse the repository at this point in the history
…ronize

Not all gcc configurations have an implementation of all the atomic
operations, and some gcc configurations have some atomic builtins
implemented but not all.

Thus check for the most essential function, whose presence should
indicate that all others are present as well, since it can be used
to implement all the other ones.

Signed-off-by: Martin Storsjö <martin@martin.st>
  • Loading branch information
mstorsjo committed Mar 8, 2013
1 parent f1af3d1 commit e460aa3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions configure
Expand Up @@ -1324,7 +1324,7 @@ HAVE_LIST="
struct_v4l2_frmivalenum_discrete
symver_asm_label
symver_gnu_asm
sync_synchronize
sync_val_compare_and_swap
sysconf
sysctl
sys_mman_h
Expand Down Expand Up @@ -3456,7 +3456,7 @@ check_func strerror_r
check_func strptime
check_func strtok_r
check_func sched_getaffinity
check_builtin sync_synchronize "" "__sync_synchronize()"
check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
check_builtin MemoryBarrier windows.h "MemoryBarrier()"
check_func sysconf
Expand Down
4 changes: 2 additions & 2 deletions libavutil/atomic.c
Expand Up @@ -20,7 +20,7 @@

#include "atomic.h"

#if !HAVE_MEMORYBARRIER && !HAVE_SYNC_SYNCHRONIZE && !HAVE_MACHINE_RW_BARRIER
#if !HAVE_MEMORYBARRIER && !HAVE_SYNC_VAL_COMPARE_AND_SWAP && !HAVE_MACHINE_RW_BARRIER

#if HAVE_PTHREADS

Expand Down Expand Up @@ -102,7 +102,7 @@ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval)

#endif /* HAVE_PTHREADS */

#endif /* !HAVE_MEMORYBARRIER && !HAVE_SYNC_SYNCHRONIZE && !HAVE_MACHINE_RW_BARRIER */
#endif /* !HAVE_MEMORYBARRIER && !HAVE_SYNC_VAL_COMPARE_AND_SWAP && !HAVE_MACHINE_RW_BARRIER */

#ifdef TEST
#include <assert.h>
Expand Down
2 changes: 1 addition & 1 deletion libavutil/atomic.h
Expand Up @@ -25,7 +25,7 @@

#if HAVE_MEMORYBARRIER
#include "atomic_win32.h"
#elif HAVE_SYNC_SYNCHRONIZE
#elif HAVE_SYNC_VAL_COMPARE_AND_SWAP
#include "atomic_gcc.h"
#elif HAVE_MACHINE_RW_BARRIER
#include "atomic_suncc.h"
Expand Down

0 comments on commit e460aa3

Please sign in to comment.