]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[libgomp, nvptx] Minimize lifetime of CUDA_ONE_CALL defines
authorTom de Vries <tdevries@suse.de>
Mon, 6 Aug 2018 22:13:46 +0000 (22:13 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 6 Aug 2018 22:13:46 +0000 (22:13 +0000)
This patch makes sure that the lifetimes of the CUDA_ONE_CALL macro (which is
defined twice in plugin-nvptx.c) are minimized, to make it obvious that the
definitions are used only in the lib-cuda.def include.

Build on x86_64 with nvptx accelerator and reg-tested libgomp.

2018-08-07  Tom de Vries  <tdevries@suse.de>

* plugin/plugin-nvptx.c (struct cuda_lib_s, init_cuda_lib): Put
CUDA_ONE_CALL defines right before the cuda-lib.def include, and the
corresponding undefs right after.

From-SVN: r263345

libgomp/ChangeLog
libgomp/plugin/plugin-nvptx.c

index 0742c78c9cce2813b2ca4962e522a7278c44db29..d96ab1f35f8e633c62732e8cb8cab27bc94866f9 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-07  Tom de Vries  <tdevries@suse.de>
+
+       * plugin/plugin-nvptx.c (struct cuda_lib_s, init_cuda_lib): Put
+       CUDA_ONE_CALL defines right before the cuda-lib.def include, and the
+       corresponding undefs right after.
+
 2018-08-04  Tom de Vries  <tdevries@suse.de>
 
        * plugin/configfrag.ac: For --without-cuda-driver, set
index cc465b4addb24514ac6bc03a6bd1bde39ff3c3d5..2e72a6379eb91599a86eb104ede9143e91a81a2a 100644 (file)
 #if PLUGIN_NVPTX_DYNAMIC
 # include <dlfcn.h>
 
-# define CUDA_ONE_CALL(call) \
-  __typeof (call) *call;
 struct cuda_lib_s {
+
+# define CUDA_ONE_CALL(call)                   \
+  __typeof (call) *call;
 #include "cuda-lib.def"
+# undef CUDA_ONE_CALL
+
 } cuda_lib;
 
 /* -1 if init_cuda_lib has not been called yet, false
@@ -74,18 +77,19 @@ init_cuda_lib (void)
   cuda_lib_inited = false;
   if (h == NULL)
     return false;
-# undef CUDA_ONE_CALL
+
 # define CUDA_ONE_CALL(call) CUDA_ONE_CALL_1 (call)
 # define CUDA_ONE_CALL_1(call) \
   cuda_lib.call = dlsym (h, #call);    \
   if (cuda_lib.call == NULL)           \
     return false;
 #include "cuda-lib.def"
+# undef CUDA_ONE_CALL
+# undef CUDA_ONE_CALL_1
+
   cuda_lib_inited = true;
   return true;
 }
-# undef CUDA_ONE_CALL
-# undef CUDA_ONE_CALL_1
 # define CUDA_CALL_PREFIX cuda_lib.
 #else
 # define CUDA_CALL_PREFIX