42 lines · plain
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include <clc/atomic/clc_atomic_compare_exchange.h>10#include <clc/opencl/atomic/atom_cmpxchg.h>11 12// Non-volatile overloads are for backward compatibility with OpenCL 1.0.13 14#define __CLC_IMPL(AS, TYPE) \15 _CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(volatile AS TYPE *p, TYPE cmp, \16 TYPE val) { \17 return __clc_atomic_compare_exchange(p, cmp, val, __ATOMIC_RELAXED, \18 __ATOMIC_RELAXED, \19 __MEMORY_SCOPE_DEVICE); \20 } \21 _CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(AS TYPE *p, TYPE cmp, TYPE val) { \22 return atom_cmpxchg((volatile AS TYPE *)p, cmp, val); \23 }24 25#ifdef cl_khr_global_int32_base_atomics26__CLC_IMPL(global, int)27__CLC_IMPL(global, unsigned int)28#endif // cl_khr_global_int32_base_atomics29#ifdef cl_khr_local_int32_base_atomics30__CLC_IMPL(local, int)31__CLC_IMPL(local, unsigned int)32#endif // cl_khr_local_int32_base_atomics33 34#ifdef cl_khr_int64_base_atomics35 36__CLC_IMPL(global, long)37__CLC_IMPL(global, unsigned long)38__CLC_IMPL(local, long)39__CLC_IMPL(local, unsigned long)40 41#endif // cl_khr_int64_base_atomics42