forked from OSchip/llvm-project
atomic: Provide function implementation of atomic_{dec,inc}
Reviewed-By: Aaron Watry <awatry@gmail.com> Tested-By: Aaron Watry <awatry@gmail.com> Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> llvm-svn: 335278
This commit is contained in:
parent
b9cbe0bf51
commit
f965b46c8e
|
@ -1 +1,4 @@
|
|||
#define atomic_dec(p) atomic_sub(p, 1)
|
||||
_CLC_OVERLOAD _CLC_DECL int atomic_dec (volatile local int *);
|
||||
_CLC_OVERLOAD _CLC_DECL int atomic_dec (volatile global int *);
|
||||
_CLC_OVERLOAD _CLC_DECL uint atomic_dec (volatile local uint *);
|
||||
_CLC_OVERLOAD _CLC_DECL uint atomic_dec (volatile global uint *);
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
#define atomic_inc(p) atomic_add(p, 1)
|
||||
_CLC_OVERLOAD _CLC_DECL int atomic_inc (volatile local int *);
|
||||
_CLC_OVERLOAD _CLC_DECL int atomic_inc (volatile global int *);
|
||||
_CLC_OVERLOAD _CLC_DECL uint atomic_inc (volatile local uint *);
|
||||
_CLC_OVERLOAD _CLC_DECL uint atomic_inc (volatile global uint *);
|
||||
|
|
|
@ -7,6 +7,8 @@ async/wait_group_events.cl
|
|||
atomic/atomic_add.cl
|
||||
atomic/atomic_and.cl
|
||||
atomic/atomic_cmpxchg.cl
|
||||
atomic/atomic_dec.cl
|
||||
atomic/atomic_inc.cl
|
||||
atomic/atomic_max.cl
|
||||
atomic/atomic_min.cl
|
||||
atomic/atomic_or.cl
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#include <clc/clc.h>
|
||||
|
||||
#define IMPL(TYPE, AS) \
|
||||
_CLC_OVERLOAD _CLC_DEF TYPE atomic_dec(volatile AS TYPE *p) { \
|
||||
return __sync_fetch_and_sub(p, (TYPE)1); \
|
||||
}
|
||||
|
||||
IMPL(int, global)
|
||||
IMPL(unsigned int, global)
|
||||
IMPL(int, local)
|
||||
IMPL(unsigned int, local)
|
||||
#undef IMPL
|
|
@ -0,0 +1,12 @@
|
|||
#include <clc/clc.h>
|
||||
|
||||
#define IMPL(TYPE, AS) \
|
||||
_CLC_OVERLOAD _CLC_DEF TYPE atomic_inc(volatile AS TYPE *p) { \
|
||||
return __sync_fetch_and_add(p, (TYPE)1); \
|
||||
}
|
||||
|
||||
IMPL(int, global)
|
||||
IMPL(unsigned int, global)
|
||||
IMPL(int, local)
|
||||
IMPL(unsigned int, local)
|
||||
#undef IMPL
|
Loading…
Reference in New Issue