]> granicus.if.org Git - clang/commitdiff
[OpenCL] Restore ATOMIC_VAR_INIT
authorSven van Haastregt <sven.vanhaastregt@arm.com>
Mon, 24 Jun 2019 10:06:40 +0000 (10:06 +0000)
committerSven van Haastregt <sven.vanhaastregt@arm.com>
Mon, 24 Jun 2019 10:06:40 +0000 (10:06 +0000)
We accidentally lost the ATOMIC_VAR_INIT and ATOMIC_FLAG_INIT macros
in r363794.

Also put the `memory_order` typedef back inside a `>= CL2.0` guard.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364174 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Headers/opencl-c-base.h
test/Headers/opencl-c-header.cl

index 19aaa90c1a742d059778fcd11e4342dd8f743abe..a82954ddd326aff1712462ebccbd3751b246ae1c 100644 (file)
@@ -297,8 +297,11 @@ typedef enum memory_scope {
  * image memory.
  */
 #define CLK_IMAGE_MEM_FENCE  0x04
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
+#ifndef ATOMIC_VAR_INIT
+#define ATOMIC_VAR_INIT(x) (x)
+#endif //ATOMIC_VAR_INIT
+#define ATOMIC_FLAG_INIT 0
 
 // enum values aligned with what clang uses in EmitAtomicExpr()
 typedef enum memory_order
@@ -310,6 +313,8 @@ typedef enum memory_order
   memory_order_seq_cst = __ATOMIC_SEQ_CST
 } memory_order;
 
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
+
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions
 
 // These values need to match the runtime equivalent
index d65a219da30a180c7a3ae1eb108b22eaf0981966..8183a8c1f79a11abb06921d1ee5c92a9bca9ace2 100644 (file)
@@ -80,6 +80,10 @@ void test_atomics(__generic volatile unsigned int* a) {
 }
 #endif
 
+// Verify that ATOMIC_VAR_INIT is defined.
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+global atomic_int z = ATOMIC_VAR_INIT(99);
+#endif //__OPENCL_C_VERSION__
 
 // Verify that non-builtin cl_intel_planar_yuv extension is defined from
 // OpenCL 1.2 onwards.