1#include <clc/clc.h>
2
3#ifdef cl_khr_int64_extended_atomics
4
5unsigned long __clc__sync_fetch_and_min_local_8(volatile local long *, long);
6unsigned long __clc__sync_fetch_and_min_global_8(volatile global long *, long);
7unsigned long __clc__sync_fetch_and_umin_local_8(volatile local unsigned long *, unsigned long);
8unsigned long __clc__sync_fetch_and_umin_global_8(volatile global unsigned long *, unsigned long);
9
10#define IMPL(AS, TYPE, OP) \
11_CLC_OVERLOAD _CLC_DEF TYPE atom_min(volatile AS TYPE *p, TYPE val) { \
12  return __clc__sync_fetch_and_##OP##_##AS##_8(p, val); \
13}
14
15IMPL(global, long, min)
16IMPL(global, unsigned long, umin)
17IMPL(local, long, min)
18IMPL(local, unsigned long, umin)
19#undef IMPL
20
21#endif
22