-#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 *);
-#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 *);
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
--- /dev/null
+#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
--- /dev/null
+#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