atomic: fix CAS with armcc.
On the current code, armcc will fail with: "libavutil/atomic_gcc.h", line 52: Error: #2771: first argument must be a pointer to integer or enumeration type
This commit is contained in:
parent
486f0b0cfc
commit
6327c10702
@ -21,6 +21,8 @@
|
|||||||
#ifndef AVUTIL_ATOMIC_GCC_H
|
#ifndef AVUTIL_ATOMIC_GCC_H
|
||||||
#define AVUTIL_ATOMIC_GCC_H
|
#define AVUTIL_ATOMIC_GCC_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "atomic.h"
|
#include "atomic.h"
|
||||||
|
|
||||||
#define avpriv_atomic_int_get atomic_int_get_gcc
|
#define avpriv_atomic_int_get atomic_int_get_gcc
|
||||||
@ -47,7 +49,13 @@ static inline int atomic_int_add_and_fetch_gcc(volatile int *ptr, int inc)
|
|||||||
static inline void *atomic_ptr_cas_gcc(void * volatile *ptr,
|
static inline void *atomic_ptr_cas_gcc(void * volatile *ptr,
|
||||||
void *oldval, void *newval)
|
void *oldval, void *newval)
|
||||||
{
|
{
|
||||||
|
#ifdef __ARMCC_VERSION
|
||||||
|
// armcc will throw an error if ptr is not an integer type
|
||||||
|
volatile uintptr_t *tmp = (volatile uintptr_t*)ptr;
|
||||||
|
return (void*)__sync_val_compare_and_swap(tmp, oldval, newval);
|
||||||
|
#else
|
||||||
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
return __sync_val_compare_and_swap(ptr, oldval, newval);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* AVUTIL_ATOMIC_GCC_H */
|
#endif /* AVUTIL_ATOMIC_GCC_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user