2014-09-17 06:34:45 +08:00
|
|
|
#include <clc/clc.h>
|
|
|
|
|
|
|
|
_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile global float *p, float val) {
|
2017-09-26 00:07:34 +08:00
|
|
|
return as_float(atomic_xchg((volatile global uint *)p, as_uint(val)));
|
2014-09-17 06:34:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile local float *p, float val) {
|
2017-09-26 00:07:34 +08:00
|
|
|
return as_float(atomic_xchg((volatile local uint *)p, as_uint(val)));
|
2014-09-17 06:34:45 +08:00
|
|
|
}
|
2017-09-26 00:07:34 +08:00
|
|
|
|
|
|
|
#define IMPL(TYPE, AS) \
|
|
|
|
_CLC_OVERLOAD _CLC_DEF TYPE atomic_xchg(volatile AS TYPE *p, TYPE val) { \
|
|
|
|
return __sync_swap_4(p, val); \
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL(int, global)
|
|
|
|
IMPL(unsigned int, global)
|
|
|
|
IMPL(int, local)
|
|
|
|
IMPL(unsigned int, local)
|
|
|
|
#undef IMPL
|